Skip to content

Commit

Permalink
try fixing azure chat generator
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Dec 20, 2024
1 parent 110eefd commit 298062d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions haystack/components/generators/chat/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ def __init__( # pylint: disable=too-many-positional-arguments
self.max_retries = max_retries or int(os.environ.get("OPENAI_MAX_RETRIES", 5))
self.default_headers = default_headers or {}

# This ChatGenerator does not yet supports tools. The following workaround ensures that we do not
# get an error when invoking the run method of the parent class (OpenAIChatGenerator).
self.tools = None
self.tools_strict = False

self.client = AzureOpenAI(
api_version=api_version,
azure_endpoint=azure_endpoint,
Expand Down
5 changes: 1 addition & 4 deletions haystack/components/generators/chat/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,7 @@ def _prepare_api_call( # noqa: PLR0913
openai_tools = None
if tools:
openai_tools = [
{
"type": "function",
"function": {**t.tool_spec, **({"strict": tools_strict} if tools_strict is not None else {})},
}
{"type": "function", "function": {**t.tool_spec, **({"strict": tools_strict} if tools_strict else {})}}
for t in tools
]

Expand Down

0 comments on commit 298062d

Please sign in to comment.