赞
踩
多轮对话时可选择加入history,history是一个数组,格式如下:
hisotyr = [{'role': 'user', 'content': user_content},
{'role': 'assistant', 'content': assistant_content}]
调用的代码如下:
import requests # 调用langchain-chatchat的chat接口 def chat(param: str, history: list) -> str: url = 'http://ip:端口/chat/chat' response = requests.post(url, headers={ 'Authorization': '', 'Content-Type': 'application/json' }, json={ "query": param, "history": history, "model_name": "chatglm2-6b", "temperature": 0.7, "prompt_name": "llm_chat" }, ) if response.status_code == 200: return response.text return ''
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。