24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
import os
|
||
from openai import OpenAI
|
||
from WxMini.Milvus.Config.MulvusConfig import *
|
||
|
||
client = OpenAI(
|
||
api_key=MODEL_API_KEY,
|
||
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||
)
|
||
completion = client.chat.completions.create(
|
||
model="qwen-vl-max-latest",
|
||
messages=[
|
||
{"role":"system","content":[{"type": "text", "text": "You are a helpful assistant."}]},
|
||
{"role": "user","content": [
|
||
# 第一张图像链接,如果传入本地文件,请将url的值替换为图像的Base64编码格式
|
||
{"type": "image_url","image_url": {"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"},},
|
||
# 第二张图像链接,如果传入本地文件,请将url的值替换为图像的Base64编码格式
|
||
{"type": "image_url","image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"},},
|
||
{"type": "text", "text": "这些图描绘了什么内容?"},
|
||
],
|
||
}
|
||
],
|
||
)
|
||
|
||
print(completion.choices[0].message.content) |