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

View File

@ -19,14 +19,14 @@ 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(...,
description="历史对话",
example=[
{"role": "user",
"content": "我们来玩成语接龙,我先来,生龙活虎"},
{"role": "assistant",
"content": "虎头虎脑"}]
),
history: List[History] = Body([],
description="历史对话",
example=[
{"role": "user",
"content": "我们来玩成语接龙,我先来,生龙活虎"},
{"role": "assistant",
"content": "虎头虎脑"}]
),
):
kb = KBServiceFactory.get_service_by_name(knowledge_base_name)
if kb is None: