update server.chat.*: set default value [] to history parameter.

This commit is contained in:
liunux4odoo 2023-08-09 10:48:37 +08:00
parent b98f5fd0b9
commit 9883341924
2 changed files with 15 additions and 15 deletions

View File

@ -13,7 +13,7 @@ from server.chat.utils import History
def chat(query: str = Body(..., description="用户输入", example="恼羞成怒"),
history: Optional[List[History]] = Body(...,
history: List[History] = Body([],
description="历史对话",
example=[
{"role": "user", "content": "我们来玩成语接龙,我先来,生龙活虎"},
@ -21,7 +21,7 @@ def chat(query: str = Body(..., description="用户输入", example="恼羞成
),
):
async def chat_iterator(query: str,
history: Optional[List[History]]
history: List[History] = [],
) -> AsyncIterable[str]:
callback = AsyncIteratorCallbackHandler()

View File

@ -19,7 +19,7 @@ import json
def knowledge_base_chat(query: str = Body(..., description="用户输入", example="你好"),
knowledge_base_name: str = Body(..., description="知识库名称", example="samples"),
top_k: int = Body(VECTOR_SEARCH_TOP_K, description="匹配向量数"),
history: Optional[List[History]] = Body(...,
history: List[History] = Body([],
description="历史对话",
example=[
{"role": "user",