From 9118d86b8bb2c10710c456ce43f7105af0f724d8 Mon Sep 17 00:00:00 2001 From: Dmitry Paramonov Date: Sat, 14 Sep 2024 00:31:54 +0300 Subject: [PATCH] fix: Handle empty tools --- agents-api/agents_api/common/protocol/sessions.py | 4 +++- agents-api/agents_api/routers/sessions/chat.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/agents-api/agents_api/common/protocol/sessions.py b/agents-api/agents_api/common/protocol/sessions.py index a675a479f..9da59e4f4 100644 --- a/agents-api/agents_api/common/protocol/sessions.py +++ b/agents-api/agents_api/common/protocol/sessions.py @@ -96,7 +96,9 @@ def get_active_tools(self) -> list[Tool]: active_agent = self.get_active_agent() try: active_toolset = next( - toolset for toolset in self.toolsets if toolset.agent_id == active_agent.id + toolset + for toolset in self.toolsets + if toolset.agent_id == active_agent.id ) except StopIteration: return [] diff --git a/agents-api/agents_api/routers/sessions/chat.py b/agents-api/agents_api/routers/sessions/chat.py index c658ef396..fdca52f27 100644 --- a/agents-api/agents_api/routers/sessions/chat.py +++ b/agents-api/agents_api/routers/sessions/chat.py @@ -70,7 +70,7 @@ async def chat( # Get the response from the model model_response = await litellm.acompletion( messages=messages, - tools=tools, + tools=tools or None, user=str(developer.id), # For tracking usage tags=developer.tags, # For filtering models in litellm **settings,