You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

4 months ago
import json
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",
)
# 一盆花
# photo_url = 'https://ylt.oss-cn-hangzhou.aliyuncs.com/Temp/mudan.jpg'
# 狗与女主人
# photo_url = "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"
# 哪吒
# photo_url = 'https://ylt.oss-cn-hangzhou.aliyuncs.com/Temp/nezha.jpg'
# 锅包肉
# photo_url = 'https://ylt.oss-cn-hangzhou.aliyuncs.com/Temp/gbr.jpg'
# 儿童看图说话
# photo_url = 'https://ylt.oss-cn-hangzhou.aliyuncs.com/Temp/xiaoxiong.jpg'
# 詹姆斯与库里
photo_url='https://ylt.oss-cn-hangzhou.aliyuncs.com/Temp/james.png'
completion = client.chat.completions.create(
model="qwen-vl-plus",
# 此处以qwen-vl-plus为例可按需更换模型名称。模型列表https://help.aliyun.com/zh/model-studio/getting-started/models
messages=[{"role": "user", "content": [
{"type": "text", "text": "这是什么"},
{"type": "image_url",
"image_url": {"url": photo_url}}
]}]
)
json_data = completion.model_dump_json()
# 解析 JSON 数据
data = json.loads(json_data)
# 提取 content 内容
content = data['choices'][0]['message']['content']
# 打印 content
print(content)