update: 增加了智谱大模型,增加了修改max_tokens接口

This commit is contained in:
killua committed 2024-06-20 14:12:51 +08:00
1 parent 5a47440e0f
commit 6354fe49f0
5 files changed
+72 -7

No files matched your search

+14 -1
View File
@@ -130,6 +130,19 @@ async def update_assistant_deatil_params(id: str,request: update_assistant_deati
return {"code":200,"msg":"success","data":{}}
else:
return {"code":404,'msg':"assistant not found","data":{}}
# 更新max_tokens
@app.put("/api/assistants/{id}/max_tokens")
async def update_assistant_max_tokens(id: str,request: update_assistant_max_tokens_request,db=Depends(get_db)):
assistant = db.query(Assistant).filter(Assistant.id == id).first()
if assistant:
llm_info = json.loads(assistant.llm_info)
llm_info['max_tokens'] = request.max_tokens
assistant.llm_info = json.dumps(llm_info, ensure_ascii=False)
db.commit()
return {"code":200,"msg":"success","data":{}}
else:
return {"code":404,'msg':"assistant not found","data":{}}
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -207,7 +220,7 @@ async def streaming_chat(ws: WebSocket):
agent = Agent(asr_type=user_info['asr_type'], llm_type=user_info['llm_type'], tts_type=user_info['tts_type'])
agent.init_recorder(assistant.user_id)
chunk["audio"] = agent.user_audio_process(chunk["audio"])
asr_results = await agent.stream_recognize(chunk)
asr_results = await agent.stream_recognize(assistant, chunk)
kid_text = asr_results[0]['text'] #asr结果的[0]默认为孩子(主要用户)的asr结果
prompt = agent.prompt_process(asr_results)
agent.recorder.input_text = prompt