关于在对话框上传图片的功能
#157
-
|
感谢您分享这么棒的工作! |
Beta Was this translation helpful? Give feedback.
Answered by
xerrors
Apr 17, 2025
Replies: 2 comments
-
|
@kamen007 感谢关注,目前的对话接口是通过 chat 这个接口实现的: 所以,你需要在这个参数里面传入用户上传的图片的路径,然后在历史消息管理里面新增消息的时候,除了增加这个 content 之外,也要新增 image(base64编码)。参考各个模型供应商对图片消息的支持,一般都是支持 base64格式的图片的。 尤其需要注意的就是这个 add_user 和 get_history_with_msg。 这个其实比输入文档要复杂一些 如果实现了的话,欢迎PR 😘 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xerrors
-
|
哈哈,好的。我按您的思路试试~ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kamen007 感谢关注,目前的对话接口是通过 chat 这个接口实现的:
https://github.com/xerrors/Yuxi-Know/blob/427f9bbae46709a65e35a6b965668299c141ddac/server/routers/chat_router.py#L23-L28
所以,你需要在这个参数里面传入用户上传的图片的路径,然后在历史消息管理里面新增消息的时候,除了增加这个 content 之外,也要新增 image(base64编码)。参考各个模型供应商对图片消息的支持,一般都是支持 base64格式的图片的。
https://github.com/xerrors/Yuxi-Know/blob/427f9bbae46709a65e35a6b965668299c141ddac/src/core/history.py#L4-L40
尤其需要注意的就是这个 add_user 和 get_history_with_msg。
这个其实比输入文档要复杂一些
如果实现了的话,欢迎PR 😘