Files
QingLong/AI/WxMini/Test/X1_ReadImage_DuoImages.py
2025-08-15 09:13:13 +08:00

24 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)