AI Chat上下文构建格式更新为原始json后, Block Editor的AI流式输出不正常了。
This commit is contained in:
parent
c8dbe8d09f
commit
59344f76db
@ -6287,7 +6287,16 @@ string_decoder@~1.1.1:
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
string-width@^4.1.0, string-width@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.2.3:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
|
||||
@ -40,12 +40,19 @@ def block_editor_action(prompt, action="custom", context=None):
|
||||
return f"id: {event_idx}\nevent: {event_type}\ndata: {json.dumps(data)}\n\n"
|
||||
|
||||
try:
|
||||
for chunk in call_jingrow_model_stream_sync(
|
||||
for ev in call_jingrow_model_stream_sync(
|
||||
messages=messages,
|
||||
max_tokens=4096,
|
||||
):
|
||||
full_content += chunk
|
||||
yield sse_event("delta", {"delta": chunk})
|
||||
if ev["type"] == "content":
|
||||
full_content += ev["data"]
|
||||
yield sse_event("delta", {"delta": ev["data"]})
|
||||
elif ev["type"] == "error":
|
||||
if not full_content:
|
||||
yield sse_event("error", {"error": ev["data"]})
|
||||
return
|
||||
elif ev["type"] == "finish":
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
if not full_content:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user