Register on_connection_error event handler in WebsocketLLMService

This commit is contained in:
Paul Kompfner
2026-03-31 10:52:33 -04:00
parent 0fb45c6114
commit 0a8bcf58c4
2 changed files with 5 additions and 0 deletions

View File

@@ -84,6 +84,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
llm.register_function("get_current_weather", fetch_weather_from_api)
llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation)
@llm.event_handler("on_connection_error")
async def on_connection_error(service, error):
logger.error(f"LLM connection error: {error}")
@llm.event_handler("on_function_calls_started")
async def on_function_calls_started(service, function_calls):
# Avoid appending this filler message to the LLM context — it would

View File

@@ -1051,6 +1051,7 @@ class WebsocketLLMService(LLMService, WebsocketService):
"""
LLMService.__init__(self, **kwargs)
WebsocketService.__init__(self, reconnect_on_error=reconnect_on_error, **kwargs)
self._register_event_handler("on_connection_error")
# -- lifecycle ------------------------------------------------------------