feat(core): Support simple DB query for sdk (#917)

Co-authored-by: chengfangyin2 <chengfangyin3@jd.com>
This commit is contained in:
FangYin Cheng
2023-12-11 18:33:54 +08:00
committed by GitHub
parent 43190ca333
commit cbba50ab1b
18 changed files with 467 additions and 74 deletions

View File

@@ -251,3 +251,13 @@ def _parse_model_response(response: ResponseTye):
else:
raise ValueError(f"Unsupported response type {type(response)}")
return resp_obj_ex
class SQLOutputParser(BaseOutputParser):
def __init__(self, is_stream_out: bool = False, **kwargs):
super().__init__(is_stream_out=is_stream_out, **kwargs)
def parse_model_nostream_resp(self, response: ResponseTye, sep: str):
model_out_text = super().parse_model_nostream_resp(response, sep)
clean_str = super().parse_prompt_response(model_out_text)
return json.loads(clean_str, strict=True)