Skip to content

Commit

Permalink
Added check for unknown tool names (#1924)
Browse files Browse the repository at this point in the history
* answer.py

* Let it continue if broken
  • Loading branch information
hagen-danswer authored Jul 25, 2024
1 parent 546bfbd commit a4d71e0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions backend/danswer/llm/answering/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,22 @@ def _raw_output_for_explicit_tool_calling_llms(
# if we have a tool call, we need to call the tool
tool_call_requests = tool_call_chunk.tool_calls
for tool_call_request in tool_call_requests:
tool = [
known_tools_by_name = [
tool for tool in self.tools if tool.name == tool_call_request["name"]
][0]
]

if not known_tools_by_name:
logger.error(
"Tool call requested with unknown name field. \n"
f"self.tools: {self.tools}"
f"tool_call_request: {tool_call_request}"
)
if self.tools:
tool = self.tools[0]
else:
continue
else:
tool = known_tools_by_name[0]
tool_args = (
self.force_use_tool.args
if self.force_use_tool.tool_name == tool.name
Expand Down

0 comments on commit a4d71e0

Please sign in to comment.