From 7ade6a28f166d4f3b17b1db6cf0275d143a8c5d2 Mon Sep 17 00:00:00 2001 From: Emil <134269730+Emil-io@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:58:21 +0100 Subject: [PATCH] feat: Update handling of tools_strict to ensure compatibility with vLLM (#150) * update handling of tools_strict * Update haystack_experimental/components/generators/chat/openai.py Co-authored-by: Julian Risch --------- Co-authored-by: Julian Risch --- haystack_experimental/components/generators/chat/openai.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/haystack_experimental/components/generators/chat/openai.py b/haystack_experimental/components/generators/chat/openai.py index 19337b46..51d85299 100644 --- a/haystack_experimental/components/generators/chat/openai.py +++ b/haystack_experimental/components/generators/chat/openai.py @@ -447,7 +447,10 @@ def _prepare_api_call( # noqa: PLR0913 openai_tools = [ { "type": "function", - "function": {**t.tool_spec, "strict": tools_strict}, + "function": { + **t.tool_spec, + **({"strict": tools_strict} if tools_strict is not None else {}), + }, } for t in tools ]