HildaM / sparkdesk-api

讯飞星火大模型 Python api 接口,快捷方便地在 Python 项目中引入星火模型。支持讯飞星火v3.0 v2.0 v1.0。支持接入”星火知识库“
GNU General Public License v3.0
231 stars 44 forks source link

请问api 模式中stream_chat中history的传入格式是啥 #6

Closed YYGe01 closed 1 year ago

YYGe01 commented 1 year ago

作者好,感觉开源。

函数稍微改了下,问下history格式可以从哪里查的到呢,主要想试试多轮问答。

    def stream_chat(self,
                    query,
                    history=[],
                    temperature=0.8,
                    top_p=0.8,
                    max_length=2048):
        for response, _ in self.__streaming_output(query, history):
            yield response
HildaM commented 1 year ago

直接参考讯飞的Web接口文档即可:https://www.xfyun.cn/doc/spark/Web.html#_1-%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E 关于多轮回答的实践,感谢您的代码贡献,最近秋招比较忙,可能没什么时间看代码 /(ㄒoㄒ)/~~

HildaM commented 1 year ago

其实您也可以抓包一下讯飞web端的response,这个可以立即看到结果的

YYGe01 commented 1 year ago

其实您也可以抓包一下讯飞web端的response,这个可以立即看到结果的

感谢,已经debug出来了。数据格式如下:

history: [{'role': 'user', 'content': '你叫什么名字'}, {'role': 'assistant', 'content': '我是科大讯飞...'}]