Skip to content

关于在对话框上传图片的功能 #155

Closed

Description

@kamen007

感谢您分享这么棒的工作!
我现在在对话框中,可以进行联网和知识库的文字对答;想问下您,如果我要在对话框上传本地图片进行解析或分析,请问大致该如何去做?谢谢

Activity

  1. xerrors commented on Apr 17, 2025

    @xerrors
    Owner

    @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 😘

  2. kamen007 commented on Apr 18, 2025

    @kamen007
    Author

    哈哈,好的。我按您的思路试试~

  3. Repository owner locked and limited conversation to collaborators on Apr 18, 2025
  4. converted this issue into a discussion #157 on Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions