pycoze 0.1.414__py3-none-any.whl → 0.1.416__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycoze/bot/chat_base.py +15 -24
- {pycoze-0.1.414.dist-info → pycoze-0.1.416.dist-info}/METADATA +1 -1
- {pycoze-0.1.414.dist-info → pycoze-0.1.416.dist-info}/RECORD +6 -6
- {pycoze-0.1.414.dist-info → pycoze-0.1.416.dist-info}/LICENSE +0 -0
- {pycoze-0.1.414.dist-info → pycoze-0.1.416.dist-info}/WHEEL +0 -0
- {pycoze-0.1.414.dist-info → pycoze-0.1.416.dist-info}/top_level.txt +0 -0
pycoze/bot/chat_base.py
CHANGED
@@ -112,7 +112,7 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
112
112
|
# 使用 async for 迭代异步生成器
|
113
113
|
try:
|
114
114
|
async for chunk in stream:
|
115
|
-
|
115
|
+
print("chunk", chunk)
|
116
116
|
# 检查是否需要重新创建流
|
117
117
|
if start_new_stream["value"]:
|
118
118
|
break # 退出当前的 async for 循环,进入下一次 while 循环
|
@@ -166,35 +166,26 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
166
166
|
print(f"Error: {e}", style="bold red")
|
167
167
|
break
|
168
168
|
|
169
|
+
print("end", "buffer", buffer, "in_json_block", in_json_block, "json_block_content", json_block_content, "text_content", text_content )
|
170
|
+
# 处理 buffer 中剩余的内容
|
169
171
|
if buffer:
|
170
172
|
if in_json_block:
|
171
173
|
buffer = buffer.split("```")[0]
|
172
174
|
json_block_content += buffer
|
173
|
-
yield ("json", json_block_content.strip())
|
174
175
|
else:
|
175
176
|
text_content += buffer
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
# if in_json_block:
|
189
|
-
# # 如果仍在 JSON 代码块模式,处理剩余的 JSON 内容
|
190
|
-
# if json_block_content.strip():
|
191
|
-
# print("yield json", json_block_content.strip())
|
192
|
-
# yield ("json", json_block_content.strip())
|
193
|
-
# else:
|
194
|
-
# # 如果不在 JSON 代码块模式,处理剩余的文本内容
|
195
|
-
# if text_content.strip():
|
196
|
-
# print("yield json", text_content.strip())
|
197
|
-
# yield ("text", text_content.strip())
|
177
|
+
|
178
|
+
# 处理流结束后的剩余内容
|
179
|
+
if in_json_block:
|
180
|
+
# 如果仍在 JSON 代码块模式,处理剩余的 JSON 内容
|
181
|
+
if json_block_content.strip():
|
182
|
+
print("yield json", json_block_content.strip())
|
183
|
+
yield ("json", json_block_content.strip())
|
184
|
+
else:
|
185
|
+
# 如果不在 JSON 代码块模式,处理剩余的文本内容
|
186
|
+
if text_content.strip():
|
187
|
+
print("yield json", text_content.strip())
|
188
|
+
yield ("text", text_content.strip())
|
198
189
|
|
199
190
|
|
200
191
|
|
@@ -12,7 +12,7 @@ pycoze/api/lib/window.py,sha256=dkzWfLwn5pE_L0DfQ38K8nx9tQyT5KO-GYyXi0rytFc,2073
|
|
12
12
|
pycoze/bot/__init__.py,sha256=rL3Q-ycczRpSFfKn84fg3QBl5k22WpyeIU5qOEjEby8,79
|
13
13
|
pycoze/bot/chat.py,sha256=qEuMxH0cVFU9QSU36FrOsjhRAxtsvOv7CQtuXvM3F6Y,6446
|
14
14
|
pycoze/bot/chat_base copy.py,sha256=WZRB08zN4OeYAjSxccgu69Jb-k8tfbNwskqi5LmBF20,11979
|
15
|
-
pycoze/bot/chat_base.py,sha256=
|
15
|
+
pycoze/bot/chat_base.py,sha256=9AWH1MBiEAELFmnP7zPKc3m1kgKWJEu4gxXFde8yEdY,12096
|
16
16
|
pycoze/bot/lib.py,sha256=_bQ52mKsWgFGAogFHnmRBJbvK_tPOwsAJ8NqJNMR5K4,7210
|
17
17
|
pycoze/bot/message.py,sha256=udnIi-h4QgGzkbr_5VcAsVGjoLp9wXJSfBCeuOz7_Bk,802
|
18
18
|
pycoze/bot/prompt.md,sha256=t7NQdiiNe-jCDVfeVbvTPfq5WK5nF8CxFUQUFMyXJlo,13880
|
@@ -32,8 +32,8 @@ pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
|
32
32
|
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
33
33
|
pycoze/utils/socket.py,sha256=bZbFFRH4mfThzRqt55BAAGQ6eICx_ja4x8UGGrUdAm8,2428
|
34
34
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
35
|
-
pycoze-0.1.
|
36
|
-
pycoze-0.1.
|
37
|
-
pycoze-0.1.
|
38
|
-
pycoze-0.1.
|
39
|
-
pycoze-0.1.
|
35
|
+
pycoze-0.1.416.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
36
|
+
pycoze-0.1.416.dist-info/METADATA,sha256=IoflAIvrdJ27SpOcatLivmdUS3xK8fssZcTuFSTkt4w,854
|
37
|
+
pycoze-0.1.416.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
38
|
+
pycoze-0.1.416.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
39
|
+
pycoze-0.1.416.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|