WEB API independent

This commit is contained in:
tuyang.yhj 2023-07-05 11:52:19 +08:00
parent 4475c0eabe
commit 6c90740fbe
2 changed files with 12 additions and 7 deletions

View File

@ -27,8 +27,11 @@ class DbChatOutputParser(BaseOutputParser):
clean_str = super().parse_prompt_response(model_out_text)
print("clean prompt response:", clean_str)
response = json.loads(clean_str)
sql, thoughts = response["sql"], response["thoughts"]
for key in sorted(response):
if key.strip() == 'sql':
sql =response[key]
if key.strip() == 'thoughts':
thoughts =response[key]
return SqlAction(sql, thoughts)
def parse_view_response(self, speak, data) -> str:

View File

@ -28,11 +28,13 @@ class PluginChatOutputParser(BaseOutputParser):
except Exception as e:
raise ValueError("model server out not fllow the prompt!")
command, thoughts, speak = (
response["command"],
response["thoughts"],
response["speak"],
)
for key in sorted(response):
if key.strip() == 'command':
command =response[key]
if key.strip() == 'thoughts':
thoughts =response[key]
if key.strip() == 'speak':
speak =response[key]
return PluginAction(command, speak, thoughts)
def parse_view_response(self, speak, data) -> str: