Skip to content

Commit

Permalink
chore: Remove unnecessary use of scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Dec 10, 2024
1 parent a282db0 commit 02ea4ac
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions app/helpers/call_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,22 @@ async def _tts_callback(text: str, style: MessageStyleEnum) -> None:
if play_loading_sound:
play_loading_sound = False
# Play the TTS
await scheduler.spawn(
handle_realtime_tts(
call=call,
scheduler=scheduler,
style=style,
text=text,
tts_client=tts_client,
)
await handle_realtime_tts(
call=call,
scheduler=scheduler,
style=style,
text=text,
tts_client=tts_client,
)

# Chat
chat_task = asyncio.create_task(
_execute_llm_chat(
_generate_chat_completion(
call=call,
client=client,
post_callback=post_callback,
scheduler=scheduler,
tool_blacklist=tool_blacklist,
tts_callback=_tts_callback,
tts_client=tts_client,
use_tools=_iterations_remaining > 0,
Expand Down Expand Up @@ -349,14 +348,12 @@ def _clear_tasks() -> None:
)
soft_timeout_triggered = True
# Never store the error message in the call history, it has caused hallucinations in the LLM
await scheduler.spawn(
handle_realtime_tts(
call=call,
scheduler=scheduler,
store=False,
text=await CONFIG.prompts.tts.timeout_loading(call),
tts_client=tts_client,
)
await handle_realtime_tts(
call=call,
scheduler=scheduler,
store=False,
text=await CONFIG.prompts.tts.timeout_loading(call),
tts_client=tts_client,
)

# Do not play timeout prompt plus loading, it can be frustrating for the user
Expand Down Expand Up @@ -751,14 +748,12 @@ async def wrapper(
return

# Play the TTS
await scheduler.spawn(
handle_realtime_tts(
call=call,
scheduler=scheduler,
style=style,
text=text,
tts_client=tts_client,
)
await handle_realtime_tts(
call=call,
scheduler=scheduler,
style=style,
text=text,
tts_client=tts_client,
)

return wrapper

0 comments on commit 02ea4ac

Please sign in to comment.