hadadrjt commited on
Commit
9a014e8
·
1 Parent(s): a4cdda6

fixup! ai: Hide reasoning status after complete.

Browse files
Files changed (1) hide show
  1. jarvis.py +13 -9
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
- display_text = ""
 
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 content_started:
307
  continue
308
- display_text += chunk
309
- await queue.put(("set", display_text))
310
  elif typ == "content":
311
  if not content_started:
312
  content_started = True
313
- display_text = chunk
314
- await queue.put(("replace", display_text))
 
 
315
  else:
316
- display_text += chunk
317
- await queue.put(("append", display_text))
318
  await queue.put(None)
319
- return display_text
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: