mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-23 10:20:01 +00:00
feat(core): Support multi round conversation operator (#986)
This commit is contained in:
@@ -44,11 +44,20 @@ async def _do_chat_completion(
|
||||
decoded_line = line.split("data: ", 1)[1]
|
||||
if decoded_line.lower().strip() != "[DONE]".lower():
|
||||
obj = json.loads(decoded_line)
|
||||
if obj["choices"][0]["delta"].get("content") is not None:
|
||||
text = obj["choices"][0]["delta"].get("content")
|
||||
if "error_code" in obj and obj["error_code"] != 0:
|
||||
if caller:
|
||||
await caller(text)
|
||||
yield text
|
||||
await caller(obj.get("text"))
|
||||
yield obj.get("text")
|
||||
else:
|
||||
if (
|
||||
"choices" in obj
|
||||
and obj["choices"][0]["delta"].get("content")
|
||||
is not None
|
||||
):
|
||||
text = obj["choices"][0]["delta"].get("content")
|
||||
if caller:
|
||||
await caller(text)
|
||||
yield text
|
||||
await asyncio.sleep(0.02)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user