fix: support bard in chatdb

support bard proxy llm  in chatdb
This commit is contained in:
xuyuan23 2023-07-27 19:22:23 +08:00
parent c4638bfde3
commit ca50e87b8f
2 changed files with 6 additions and 2 deletions

View File

@ -31,7 +31,11 @@ def bard_generate_stream(model, tokenizer, params, device, context_len=2048):
history.remove(last_user_input)
history.append(last_user_input)
response = bardapi.core.Bard(token).get_answer(last_user_input["content"])
msgs = []
for msg in history:
if msg.get("content"):
msgs.append(msg["content"])
response = bardapi.core.Bard(token).get_answer("\n".join(msgs))
if response is not None and response.get("content") is not None:
yield str(response["content"])
else:

View File

@ -38,7 +38,7 @@ class ChatDashboard(BaseChat):
current_user_input=user_input,
)
if not db_name:
raise ValueError(f"{ChatScene.ChatDashboard.value} mode should chose db!")
raise ValueError(f"{ChatScene.ChatDashboard.value} mode should choose db!")
self.db_name = db_name
self.report_name = report_name
self.database = CFG.local_db