Skip to content

Commit 222da22

Browse files
committed
Add noqa and type ignore comments, update message list
Added `# noqa: T201` to print statements in example scripts to suppress linter warnings. Updated the message list construction in `aimlapi_with_tools_example.py` for clarity. In `chat_generator.py`, added a type ignore comment for messages and included the `openai_endpoint` parameter in the returned dictionary.
1 parent 47238e4 commit 222da22

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

integrations/aimlapi/examples/aimlapi_basic_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main() -> None:
2323

2424
reply = generator.run(messages=messages)["replies"][0]
2525

26-
print(f"assistant response: {reply.text}")
26+
print(f"assistant response: {reply.text}") # noqa: T201
2727

2828

2929
if __name__ == "__main__":

integrations/aimlapi/examples/aimlapi_with_tools_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main() -> None:
4646
ChatMessage.from_user("What's the weather in Tokyo today?"),
4747
]
4848

49-
print("Requesting a tool call from the model...")
49+
print("Requesting a tool call from the model...") # noqa: T201
5050
tool_request = client.run(
5151
messages=messages,
5252
tools=[weather_tool],
@@ -55,26 +55,26 @@ def main() -> None:
5555
},
5656
)["replies"][0]
5757

58-
print(f"assistant tool request: {tool_request}")
58+
print(f"assistant tool request: {tool_request}") # noqa: T201
5959

6060
if not tool_request.tool_calls:
61-
print("No tool call was produced by the model.")
61+
print("No tool call was produced by the model.") # noqa: T201
6262
return
6363

6464
tool_messages = tool_invoker.run(messages=[tool_request])["tool_messages"]
6565
for tool_message in tool_messages:
6666
for tool_result in tool_message.tool_call_results:
67-
print(f"tool output: {tool_result.result}")
67+
print(f"tool output: {tool_result.result}") # noqa: T201
6868

69-
follow_up_messages = messages + [tool_request, *tool_messages]
69+
follow_up_messages = [*messages, tool_request, *tool_messages]
7070

7171
final_reply = client.run(
7272
messages=follow_up_messages,
7373
tools=[weather_tool],
7474
generation_kwargs={"tool_choice": "none"},
7575
)["replies"][0]
7676

77-
print(f"assistant final answer: {final_reply.text}")
77+
print(f"assistant final answer: {final_reply.text}") # noqa: T201
7878

7979

8080
if __name__ == "__main__":

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ def _prepare_api_call(
189189

190190
return {
191191
"model": self.model,
192-
"messages": aimlapi_formatted_messages,
192+
"messages": aimlapi_formatted_messages, # type: ignore[arg-type] # openai expects list of specific message types
193193
"stream": streaming_callback is not None,
194194
"n": num_responses,
195195
**aimlapi_tools,
196196
"extra_body": {**generation_kwargs},
197197
"extra_headers": {**extra_headers},
198+
"openai_endpoint": "create",
198199
}

0 commit comments

Comments
 (0)