Merge pull request #87 from devchat-ai/sync-240719-113725
🔄 Sync: [main](5da5b4d7) Merge pull request #410 from devchat-ai/fix_workflow_openai_error (240719-113725)
This commit is contained in:
commit
0acb846745
@ -123,7 +123,7 @@ devchat/llm/__pycache__/pipeline.cpython-38.pyc,,
|
||||
devchat/llm/__pycache__/text_confirm.cpython-38.pyc,,
|
||||
devchat/llm/__pycache__/tools_call.cpython-38.pyc,,
|
||||
devchat/llm/chat.py,sha256=3xTtBQdaoZosxXxqiDaFzka9phgF2SgFu1hvaDv8JEw,3279
|
||||
devchat/llm/openai.py,sha256=6o551AdNRdFkD5HGPJ4POsW4NlTkdn7caKEAUy3HNTs,6353
|
||||
devchat/llm/openai.py,sha256=izaocQiDBGCpJUgK18-XEA7Z2u9PLYvWez9Xwaoc3G0,6557
|
||||
devchat/llm/pipeline.py,sha256=u0NyaiIRNB4xCcbxYxZ3E3Im2dHLIcA3fZZ6QiUcpf0,2120
|
||||
devchat/llm/text_confirm.py,sha256=sdt7AUFDcsOZ0fLfS0vtjdS2_8xhkTF6aF8Sn05OlI0,1462
|
||||
devchat/llm/tools_call.py,sha256=OBObtFAzuqEJPq7Ro9hR4oirrcMtxGchlMQl8vL1CBc,8038
|
||||
|
@ -74,10 +74,11 @@ def chat_completion_stream_raw(**kwargs):
|
||||
def stream_out_chunk(chunks):
|
||||
for chunk in chunks:
|
||||
chunk_dict = chunk.dict()
|
||||
delta = chunk_dict["choices"][0]["delta"]
|
||||
if delta.get("content", None):
|
||||
print(delta["content"], end="", flush=True)
|
||||
yield chunk
|
||||
if len(chunk_dict["choices"]) > 0:
|
||||
delta = chunk_dict["choices"][0]["delta"]
|
||||
if delta.get("content", None):
|
||||
print(delta["content"], end="", flush=True)
|
||||
yield chunk
|
||||
|
||||
|
||||
def retry_timeout(chunks):
|
||||
@ -97,11 +98,12 @@ def chunks_content(chunks):
|
||||
content = None
|
||||
for chunk in chunks:
|
||||
chunk_dict = chunk.dict()
|
||||
delta = chunk_dict["choices"][0]["delta"]
|
||||
if delta.get("content", None):
|
||||
if content is None:
|
||||
content = ""
|
||||
content += delta["content"]
|
||||
if len(chunk_dict["choices"]) > 0:
|
||||
delta = chunk_dict["choices"][0]["delta"]
|
||||
if delta.get("content", None):
|
||||
if content is None:
|
||||
content = ""
|
||||
content += delta["content"]
|
||||
return content
|
||||
|
||||
|
||||
@ -110,17 +112,18 @@ def chunks_call(chunks):
|
||||
|
||||
for chunk in chunks:
|
||||
chunk = chunk.dict()
|
||||
delta = chunk["choices"][0]["delta"]
|
||||
if "tool_calls" in delta and delta["tool_calls"]:
|
||||
tool_call = delta["tool_calls"][0]["function"]
|
||||
if delta["tool_calls"][0].get("index", None) is not None:
|
||||
index = delta["tool_calls"][0]["index"]
|
||||
if index >= len(tool_calls):
|
||||
tool_calls.append({"name": None, "arguments": ""})
|
||||
if tool_call.get("name", None):
|
||||
tool_calls[-1]["name"] = tool_call["name"]
|
||||
if tool_call.get("arguments", None):
|
||||
tool_calls[-1]["arguments"] += tool_call["arguments"]
|
||||
if len(chunk["choices"]) > 0:
|
||||
delta = chunk["choices"][0]["delta"]
|
||||
if "tool_calls" in delta and delta["tool_calls"]:
|
||||
tool_call = delta["tool_calls"][0]["function"]
|
||||
if delta["tool_calls"][0].get("index", None) is not None:
|
||||
index = delta["tool_calls"][0]["index"]
|
||||
if index >= len(tool_calls):
|
||||
tool_calls.append({"name": None, "arguments": ""})
|
||||
if tool_call.get("name", None):
|
||||
tool_calls[-1]["name"] = tool_call["name"]
|
||||
if tool_call.get("arguments", None):
|
||||
tool_calls[-1]["arguments"] += tool_call["arguments"]
|
||||
return tool_calls
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user