mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
b72a4cab63
commit
9aae08baa1
1 file changed
+7
-2
+7
-2
@@ -554,9 +554,14 @@ async def stream_openai_completions(
|
||||
return item
|
||||
|
||||
async for line in resp.aiter_lines():
|
||||
if not line.startswith("data: ") or line == "data: [DONE]":
|
||||
if not line.startswith("data:"):
|
||||
continue
|
||||
chunk = json.loads(line[6:])
|
||||
raw = line.removeprefix("data:").strip()
|
||||
if raw == "[DONE]":
|
||||
break
|
||||
if not raw:
|
||||
continue
|
||||
chunk = json.loads(raw)
|
||||
choices = chunk.get("choices", [])
|
||||
delta = choices[0].get("delta", {}) if choices else {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user