ai: Adjust chunk process logic.
Browse files
jarvis.py
CHANGED
@@ -297,10 +297,11 @@ async def respond_async(multi, history, model_display, sess, custom_prompt):
|
|
297 |
content_started = False
|
298 |
async for typ, chunk in chat_with_model_async(history, inp, model_display, sess, custom_prompt):
|
299 |
if typ == "reasoning":
|
300 |
-
if
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
304 |
if not content_started:
|
305 |
content_started = True
|
306 |
display_text = chunk
|
@@ -312,7 +313,6 @@ async def respond_async(multi, history, model_display, sess, custom_prompt):
|
|
312 |
return display_text
|
313 |
bg_task = asyncio.create_task(background())
|
314 |
stop_task = asyncio.create_task(sess.stop_event.wait())
|
315 |
-
first_update = False
|
316 |
try:
|
317 |
while True:
|
318 |
done, _ = await asyncio.wait({stop_task, asyncio.create_task(queue.get())}, return_when=asyncio.FIRST_COMPLETED)
|
|
|
297 |
content_started = False
|
298 |
async for typ, chunk in chat_with_model_async(history, inp, model_display, sess, custom_prompt):
|
299 |
if typ == "reasoning":
|
300 |
+
if content_started:
|
301 |
+
continue
|
302 |
+
display_text += chunk
|
303 |
+
await queue.put(("set", display_text))
|
304 |
+
elif typ == "content":
|
305 |
if not content_started:
|
306 |
content_started = True
|
307 |
display_text = chunk
|
|
|
313 |
return display_text
|
314 |
bg_task = asyncio.create_task(background())
|
315 |
stop_task = asyncio.create_task(sess.stop_event.wait())
|
|
|
316 |
try:
|
317 |
while True:
|
318 |
done, _ = await asyncio.wait({stop_task, asyncio.create_task(queue.get())}, return_when=asyncio.FIRST_COMPLETED)
|