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.
47 lines
1.4 KiB
47 lines
1.4 KiB
|
|
# https://qwenlm.github.io/zh/blog/qwen2.5-vl-32b/
|
|
from openai import OpenAI
|
|
from WxMini.Milvus.Config.MulvusConfig import *
|
|
|
|
client = OpenAI(
|
|
api_key=MODELSCOPE_ACCESS_TOKEN,
|
|
base_url="https://api-inference.modelscope.cn/v1"
|
|
)
|
|
# 提示词
|
|
prompt = "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."
|
|
|
|
# 要解决的图片问题
|
|
#img_url = 'https://qianwen-res.oss-cn-beijing.aliyuncs.com/QVQ/demo.png'
|
|
# 答案=46
|
|
|
|
#img_url='https://hzkc.oss-cn-beijing.aliyuncs.com/Temp/simple_math.jpeg'
|
|
# 答案应该是80度
|
|
|
|
img_url='https://hzkc.oss-cn-beijing.aliyuncs.com/Temp/hard_math.jpeg'
|
|
|
|
response = client.chat.completions.create(
|
|
#model="Qwen/QVQ-72B-Preview",
|
|
model="Qwen/Qwen2.5-VL-32B-Instruct",
|
|
messages=[
|
|
{
|
|
"role": "system",
|
|
"content": [
|
|
{"type": "text", "text": prompt}
|
|
],
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{
|
|
"type": "image_url",
|
|
"image_url": {"url": img_url}
|
|
},
|
|
{"type": "text", "text": "请使用中文回答:空白位置应该填入什么值?"},
|
|
],
|
|
}
|
|
],
|
|
stream=True
|
|
)
|
|
for chunk in response:
|
|
print(chunk.choices[0].delta.content, end='', flush=True)
|