Skip to content

Commit 95f0021

Browse files
authored
chore: OpenAI - explictly filter function tools (#9697)
1 parent 47508bc commit 95f0021

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

haystack/components/generators/chat/openai.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ def _convert_chat_completion_to_chat_message(completion: ChatCompletion, choice:
477477
message: ChatCompletionMessage = choice.message
478478
text = message.content
479479
tool_calls = []
480-
if openai_tool_calls := message.tool_calls:
480+
if message.tool_calls:
481+
# we currently only support function tools (not custom tools)
482+
# https://platform.openai.com/docs/guides/function-calling#custom-tools
483+
openai_tool_calls = [tc for tc in message.tool_calls if tc.type == "function"]
481484
for openai_tc in openai_tool_calls:
482485
arguments_str = openai_tc.function.arguments
483486
try:

0 commit comments

Comments
 (0)