Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问怎么用python实现类似的多轮对话功能呢? #3238

Open
taylover-pei opened this issue Feb 24, 2025 · 3 comments
Open

请问怎么用python实现类似的多轮对话功能呢? #3238

taylover-pei opened this issue Feb 24, 2025 · 3 comments

Comments

@taylover-pei
Copy link

infer_batch(engine, infer_requests)

你好,我用上面的方法用python调用大模型,貌似不能实现多轮对话的功能,即输入一张图片,大模型会回答一个相关问题,但是我再提问与刚才图像相关的问题之后,他就说找不到图片了。请问怎么用python实现类似的多轮对话功能呢? 期待答复!

@Jintao-Huang
Copy link
Collaborator

参考一下 推理和部署文档,看看能否解决问题

images不要漏传了

@taylover-pei
Copy link
Author

你好,我构建得infer_requests如下:
infer_requests = [
InferRequest(messages=[{'role': 'user', 'content': '这张图存在小动物吗?'}],
images=[‘./1.jpg’]),
InferRequest(messages=[{'role': 'user', 'content': '请再次确认上面这张图存在小动物吗?'}],
]
resp_list = engine.infer(infer_requests, request_config)

但是模型返回的是:
[ChatCompletionResponse(model='Qwen2.5-VL-7B-Instruct', choices=[ChatCompletionResponseChoice(index=0, message=ChatMessage(role='assistant', content='否。', tool_calls=None), finish_reason='length', logprobs=None)], usage=UsageInfo(prompt_tokens=1108, completion_tokens=3, total_tokens=1111), id='chatcmpl-e994cbf5995f4803b348e2538265fcf4', object='chat.completion', created=1740447964), ChatCompletionResponse(model='Qwen2.5-VL-7B-Instruct', choices=[ChatCompletionResponseChoice(index=0, message=ChatMessage(role='assistant', content='很抱歉,您没有提供任何图片给我查看。如果您能上传一张图片,我会很乐意帮助您确认图片中是否存在小动物。', tool_calls=None), finish_reason='length', logprobs=None)], usage=UsageInfo(prompt_tokens=1108, completion_tokens=30, total_tokens=1138), id='chatcmpl-d14fe86eb4344d49a72c2b238abe64db', object='chat.completion', created=1740447964)]

也就是说,第二个query并不能识别到第一个query中得图片,请问python调用得多轮对话功能还有其他方案可以参考吗?感谢回答!

@taylover-pei
Copy link
Author

@Jintao-Huang 求解答,十分感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants