fixup! ai: Hide reasoning status after complete.
Browse files
jarvis.py
CHANGED
|
@@ -297,26 +297,30 @@ async def respond_async(multi, history, model_display, sess, custom_prompt):
|
|
| 297 |
yield history, gr.update(interactive=False, submit_btn=False, stop_btn=True), sess
|
| 298 |
queue = asyncio.Queue()
|
| 299 |
async def background():
|
| 300 |
-
|
|
|
|
| 301 |
content_started = False
|
|
|
|
| 302 |
async for typ, chunk in chat_with_model_async(history, inp, model_display, sess, custom_prompt):
|
| 303 |
if sess.stop_event.is_set():
|
| 304 |
break
|
| 305 |
if typ == "reasoning":
|
| 306 |
-
if
|
| 307 |
continue
|
| 308 |
-
|
| 309 |
-
await queue.put(("
|
| 310 |
elif typ == "content":
|
| 311 |
if not content_started:
|
| 312 |
content_started = True
|
| 313 |
-
|
| 314 |
-
|
|
|
|
|
|
|
| 315 |
else:
|
| 316 |
-
|
| 317 |
-
await queue.put(("append",
|
| 318 |
await queue.put(None)
|
| 319 |
-
return
|
| 320 |
bg_task = asyncio.create_task(background())
|
| 321 |
stop_task = asyncio.create_task(sess.stop_event.wait())
|
| 322 |
try:
|
|
|
|
| 297 |
yield history, gr.update(interactive=False, submit_btn=False, stop_btn=True), sess
|
| 298 |
queue = asyncio.Queue()
|
| 299 |
async def background():
|
| 300 |
+
reasoning = ""
|
| 301 |
+
responses = ""
|
| 302 |
content_started = False
|
| 303 |
+
ignore_reasoning = False
|
| 304 |
async for typ, chunk in chat_with_model_async(history, inp, model_display, sess, custom_prompt):
|
| 305 |
if sess.stop_event.is_set():
|
| 306 |
break
|
| 307 |
if typ == "reasoning":
|
| 308 |
+
if ignore_reasoning:
|
| 309 |
continue
|
| 310 |
+
reasoning += chunk
|
| 311 |
+
await queue.put(("reasoning", reasoning))
|
| 312 |
elif typ == "content":
|
| 313 |
if not content_started:
|
| 314 |
content_started = True
|
| 315 |
+
ignore_reasoning = True
|
| 316 |
+
responses = chunk
|
| 317 |
+
await queue.put(("reasoning", ""))
|
| 318 |
+
await queue.put(("replace", responses))
|
| 319 |
else:
|
| 320 |
+
responses += chunk
|
| 321 |
+
await queue.put(("append", responses))
|
| 322 |
await queue.put(None)
|
| 323 |
+
return responses
|
| 324 |
bg_task = asyncio.create_task(background())
|
| 325 |
stop_task = asyncio.create_task(sess.stop_event.wait())
|
| 326 |
try:
|