Skip to content

Commit

Permalink
Handle minor issue: tools name shouldn't contain space for openai (#961)
Browse files Browse the repository at this point in the history
As per (langchain-ai/langchain#16395), OpenAI functions don't accept tool names with space. Therefore, I added an exception handling snippet to raise an issue if a custom tool name has a space.
  • Loading branch information
anonstudy authored Aug 10, 2024
1 parent 638a8f0 commit 82b1db1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/crewai/tools/tool_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ def __init__(
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
Expand Down

0 comments on commit 82b1db1

Please sign in to comment.