Skip to content

Commit 9058b43

Browse files
authored
Fix (#2298)
1 parent 6ab8f7b commit 9058b43

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

  • integrations/meta_llama/src/haystack_integrations/components/generators/meta_llama/chat

integrations/meta_llama/src/haystack_integrations/components/generators/meta_llama/chat/chat_generator.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from haystack import component, default_to_dict, logging
99
from haystack.components.generators.chat import OpenAIChatGenerator
10-
from haystack.dataclasses import StreamingCallbackT
10+
from haystack.dataclasses import ChatMessage, StreamingCallbackT
1111
from haystack.tools import Tool, Toolset
1212
from haystack.utils import serialize_callable
1313
from haystack.utils.auth import Secret
@@ -104,6 +104,27 @@ def __init__(
104104
tools=tools,
105105
)
106106

107+
def _prepare_api_call(
108+
self,
109+
*,
110+
messages: list[ChatMessage],
111+
streaming_callback: Optional[StreamingCallbackT] = None,
112+
generation_kwargs: Optional[dict[str, Any]] = None,
113+
tools: Optional[Union[list[Tool], Toolset]] = None,
114+
tools_strict: Optional[bool] = None,
115+
) -> dict[str, Any]:
116+
api_args = super(MetaLlamaChatGenerator, self)._prepare_api_call( # noqa: UP008
117+
messages=messages,
118+
streaming_callback=streaming_callback,
119+
generation_kwargs=generation_kwargs,
120+
tools=tools,
121+
tools_strict=tools_strict,
122+
)
123+
# Meta Llama API does not support None as a value for response_format
124+
if "response_format" in api_args and api_args["response_format"] is None:
125+
api_args.pop("response_format")
126+
return api_args
127+
107128
def to_dict(self) -> Dict[str, Any]:
108129
"""
109130
Serialize this component to a dictionary.

0 commit comments

Comments
 (0)