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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
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 )