Open ruifengma opened 8 months ago
补充一下:用openai调用的话,调用代码
from openai import OpenAI
client = OpenAI(
api_key = "Null",
base_url = http://10.84.16.179:8093/v1/
)
messages = [{"role": "user", "content": [
{'type':"text", 'text':'这是什么?'},
{'type':'image', 'image':'/home/demo.jpeg'}
]}]
response = client.chat.completions.create(
model="Qwen-VL-Chat",
messages=messages,
temperature=0.7
)
print(response)
报错
UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'type': 'text', 'text': '这是什么?'}, {'type': 'image', 'image': '/data/mrx/demo.jpeg'}], 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}
补充一下:用openai调用的话,调用代码
from openai import OpenAI client = OpenAI( api_key = "Null", base_url = http://10.84.16.179:8093/v1/ ) messages = [{"role": "user", "content": [ {'type':"text", 'text':'这是什么?'}, {'type':'image', 'image':'/home/demo.jpeg'} ]}] response = client.chat.completions.create( model="Qwen-VL-Chat", messages=messages, temperature=0.7 ) print(response)
报错
UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'type': 'text', 'text': '这是什么?'}, {'type': 'image', 'image': '/data/mrx/demo.jpeg'}], 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}
这个是说 "content": 应该是个字符串,而不是数组对象。 但是,即便我解决了这个问题,就会报 Internal Server Error。 从api控制台日志可以看到报错信息 RuntimeError: probability tensor contains either inf
, nan
or element < 0
你从api控制台看看是不是也是报这个错
补充一下:用openai调用的话,调用代码
from openai import OpenAI client = OpenAI( api_key = "Null", base_url = http://10.84.16.179:8093/v1/ ) messages = [{"role": "user", "content": [ {'type':"text", 'text':'这是什么?'}, {'type':'image', 'image':'/home/demo.jpeg'} ]}] response = client.chat.completions.create( model="Qwen-VL-Chat", messages=messages, temperature=0.7 ) print(response)
报错
UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'type': 'text', 'text': '这是什么?'}, {'type': 'image', 'image': '/data/mrx/demo.jpeg'}], 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}
这个是说 "content": 应该是个字符串,而不是数组对象。 但是,即便我解决了这个问题,就会报 Internal Server Error。 从api控制台日志可以看到报错信息 RuntimeError: probability tensor contains either
inf
,nan
or element < 0 你从api控制台看看是不是也是报这个错
我没有这个错误因为我还没有真正的进入模型计算,你的输入格式是什么?
补充一下:用openai调用的话,调用代码
from openai import OpenAI client = OpenAI( api_key = "Null", base_url = http://10.84.16.179:8093/v1/ ) messages = [{"role": "user", "content": [ {'type':"text", 'text':'这是什么?'}, {'type':'image', 'image':'/home/demo.jpeg'} ]}] response = client.chat.completions.create( model="Qwen-VL-Chat", messages=messages, temperature=0.7 ) print(response)
报错
UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'type': 'text', 'text': '这是什么?'}, {'type': 'image', 'image': '/data/mrx/demo.jpeg'}], 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}
这个是说 "content": 应该是个字符串,而不是数组对象。 但是,即便我解决了这个问题,就会报 Internal Server Error。 从api控制台日志可以看到报错信息 RuntimeError: probability tensor contains either
inf
,nan
or element < 0 你从api控制台看看是不是也是报这个错我没有这个错误因为我还没有真正的进入模型计算,你的输入格式是什么?
输入参数message. content 要求字符串类型,我就把 content的json对象转换成字符串类型
messages.append({"role": role, "content": json.dumps([{"text" : prompt }]) })
补充一下:用openai调用的话,调用代码
from openai import OpenAI client = OpenAI( api_key = "Null", base_url = http://10.84.16.179:8093/v1/ ) messages = [{"role": "user", "content": [ {'type':"text", 'text':'这是什么?'}, {'type':'image', 'image':'/home/demo.jpeg'} ]}] response = client.chat.completions.create( model="Qwen-VL-Chat", messages=messages, temperature=0.7 ) print(response)
报错
UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'type': 'text', 'text': '这是什么?'}, {'type': 'image', 'image': '/data/mrx/demo.jpeg'}], 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}
这个是说 "content": 应该是个字符串,而不是数组对象。 但是,即便我解决了这个问题,就会报 Internal Server Error。 从api控制台日志可以看到报错信息 RuntimeError: probability tensor contains either
inf
,nan
or element < 0 你从api控制台看看是不是也是报这个错我没有这个错误因为我还没有真正的进入模型计算,你的输入格式是什么?
输入参数message. content 要求字符串类型,我就把 content的json对象转换成字符串类型
messages.append({"role": role, "content": json.dumps([{"text" : prompt }]) })
奇怪,这部分就是没有一个明确的说明到底该怎么调用
其他人只玩web_demo ?
Internal Server Error错误的话,你看一下服务器的日志通常就是文件不存在。 我用idea的http客户端调用openai_api的方式就是
POST http://ip:port/v1/chat/completions
Content-Type: application/json
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.9)
Accept-Encoding: br,deflate,gzip,x-gzip
Content-Length: 196
{
"messages": [
{
"role": "user",
"content": "Picture 1: <img>/tmp/upload/img.jpg</img>图片上有什么"
}
],
"model": "qwen"
}
其中< img >服务器本地文件< /img >就是关键,因为content本质上就是一个串。 另外我修改了openai_api.py。增加一个文件上传的接口,这样就可以先把文件上传到/tmp/uplaod下,然后再调用chat接口交互。
您好 请问问题解决了吗 这也遇到了相同的问题 openai.UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'text
您好 请问问题解决了吗 这也遇到了相同的问题 openai.UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 0, 'content'], 'msg': 'Input should be a valid string', 'input': [{'text
这个只能自己重新改写一下openai_api.py了,repo里面提供的是大模型的,不支持多模态
是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?
该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?
当前行为 | Current Behavior
我现在已经通过openai_api.py成功启动Qwen-VL-Chat服务,但是仅仅能通过curl或openai进行基础的对话服务,用curl举个例子,我输入
curl http://10.84.16.179:8093/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "Qwen-VL-Chat", "messages": [{"role": "user", "content": "Hello!"}]}'
可以得到反馈{"model":"Qwen-VL-Chat","object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! How can I help you today?","function_call":null},"finish_reason":"stop"}],"created":1708668152}
但如果我想用image进行输入的时候,比如curl http://10.84.16.179:8093/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "Qwen-VL-Chat", "messages": [{"role": "user", "content": "<img>/home/demo.jpeg</img>这是什么"}]}'
他就报错了Internal Server Error
我想问一下是输入格式的问题还是api的bug,如果是格式的问题,那么想要输入图片的话,正确调用的格式是什么,非常感谢期望行为 | Expected Behavior
如上
复现方法 | Steps To Reproduce
如上
运行环境 | Environment
备注 | Anything else?
No response