pycoze 0.1.404__tar.gz → 0.1.405__tar.gz
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-0.1.404 → pycoze-0.1.405}/PKG-INFO +1 -1
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/chat_base.py +11 -11
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze.egg-info/PKG-INFO +1 -1
- {pycoze-0.1.404 → pycoze-0.1.405}/setup.py +1 -1
- {pycoze-0.1.404 → pycoze-0.1.405}/LICENSE +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/README.md +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ai/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ai/llm/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ai/llm/chat.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/lib/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/lib/tab.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/lib/view.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/lib/web.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/api/lib/window.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/chat.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/lib.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/message.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/prompt.md +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/bot/tools.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/reference/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/reference/bot.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/reference/lib.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/reference/tool.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/reference/workflow.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ui/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ui/base.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ui/color.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ui/typ.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/ui/ui_def.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/utils/__init__.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/utils/arg.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/utils/env.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/utils/socket.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze/utils/text_or_file.py +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze.egg-info/SOURCES.txt +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.404 → pycoze-0.1.405}/setup.cfg +0 -0
@@ -128,6 +128,7 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
128
128
|
if json_start_match:
|
129
129
|
# 提取 JSON 代码块之前的文本
|
130
130
|
text_content += buffer[:json_start_match.start()]
|
131
|
+
# 如果 text_content 不为空,先 yield 文本
|
131
132
|
if text_content.strip():
|
132
133
|
yield ("text", text_content.strip())
|
133
134
|
text_content = ""
|
@@ -135,7 +136,7 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
135
136
|
in_json_block = True
|
136
137
|
buffer = buffer[json_start_match.end():]
|
137
138
|
else:
|
138
|
-
# 如果没有找到 JSON
|
139
|
+
# 如果没有找到 JSON 代码块,直接累积到 text_content
|
139
140
|
text_content += buffer
|
140
141
|
buffer = ""
|
141
142
|
else:
|
@@ -144,6 +145,7 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
144
145
|
if json_end_match:
|
145
146
|
# 提取 JSON 代码块内容
|
146
147
|
json_block_content += buffer[:json_end_match.start()]
|
148
|
+
# yield JSON 代码块
|
147
149
|
yield ("json", json_block_content.strip())
|
148
150
|
json_block_content = ""
|
149
151
|
in_json_block = False
|
@@ -152,7 +154,6 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
152
154
|
# 如果没有找到结束标记,继续累积 JSON 内容
|
153
155
|
json_block_content += buffer
|
154
156
|
buffer = ""
|
155
|
-
print(".")
|
156
157
|
|
157
158
|
# 如果流正常结束,退出 while 循环
|
158
159
|
break
|
@@ -162,16 +163,15 @@ async def stream_openai_response(conversation_history, start_new_stream):
|
|
162
163
|
print(f"Error: {e}", style="bold red")
|
163
164
|
break
|
164
165
|
|
165
|
-
#
|
166
|
-
if
|
167
|
-
|
168
|
-
|
169
|
-
json_block_content += buffer
|
166
|
+
# 处理流结束后的剩余内容
|
167
|
+
if in_json_block:
|
168
|
+
# 如果仍在 JSON 代码块模式,处理剩余的 JSON 内容
|
169
|
+
if json_block_content.strip():
|
170
170
|
yield ("json", json_block_content.strip())
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
else:
|
172
|
+
# 如果不在 JSON 代码块模式,处理剩余的文本内容
|
173
|
+
if text_content.strip():
|
174
|
+
yield ("text", text_content.strip())
|
175
175
|
|
176
176
|
|
177
177
|
async def handle_user_inputs(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|