tech-envision commited on
Commit
9ecde57
·
1 Parent(s): d37f200

Emit waiting placeholder for tools

Browse files
Files changed (1) hide show
  1. src/chat.py +6 -0
src/chat.py CHANGED
@@ -224,6 +224,11 @@ class ChatSession:
224
  exec_task = asyncio.create_task(
225
  execute_terminal_async(**call.function.arguments)
226
  )
 
 
 
 
 
227
  follow_task = asyncio.create_task(self.ask(messages, think=True))
228
 
229
  async with self._lock:
@@ -241,6 +246,7 @@ class ChatSession:
241
  await follow_task
242
  except asyncio.CancelledError:
243
  pass
 
244
  result = await exec_task
245
  messages.append(
246
  {
 
224
  exec_task = asyncio.create_task(
225
  execute_terminal_async(**call.function.arguments)
226
  )
227
+
228
+ placeholder = {"role": "assistant", "content": "Awaiting tool response..."}
229
+ messages.append(placeholder)
230
+ yield ChatResponse(message=Message(**placeholder))
231
+
232
  follow_task = asyncio.create_task(self.ask(messages, think=True))
233
 
234
  async with self._lock:
 
246
  await follow_task
247
  except asyncio.CancelledError:
248
  pass
249
+ messages.pop() # remove placeholder
250
  result = await exec_task
251
  messages.append(
252
  {