Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Handle minor issue: tools name shouldn't contain space for openai (#961)

Abebe M.82b1db1711ea
diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py
index 3beb99461..ef0527035 100644
--- a/src/crewai/tools/tool_usage.py
+++ b/src/crewai/tools/tool_usage.py
@@ -71,7 +71,14 @@ class ToolUsage:
self.task = task
self.action = action
self.function_calling_llm = function_calling_llm
-
+
+ # Handling bug (see https://github.com/langchain-ai/langchain/pull/16395): raise an error if tools_names have space for ChatOpenAI
+ if isinstance(self.function_calling_llm, ChatOpenAI):
+ if " " in self.tools_names:
+ raise Exception(
+ "Tools names should not have spaces for ChatOpenAI models."
+ )
+
# Set the maximum parsing attempts for bigger models
if (isinstance(self.function_calling_llm, ChatOpenAI)) and (
self.function_calling_llm.openai_api_base is None