|
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
5 | | -from typing import Any, Optional |
| 5 | +from typing import Any |
6 | 6 |
|
7 | 7 | from haystack import component, default_to_dict, logging |
8 | 8 | from haystack.components.generators.chat import OpenAIChatGenerator |
@@ -61,14 +61,14 @@ def __init__( |
61 | 61 | *, |
62 | 62 | api_key: Secret = Secret.from_env_var("OPENROUTER_API_KEY"), |
63 | 63 | model: str = "openai/gpt-5-mini", |
64 | | - streaming_callback: Optional[StreamingCallbackT] = None, |
65 | | - api_base_url: Optional[str] = "https://openrouter.ai/api/v1", |
66 | | - generation_kwargs: Optional[dict[str, Any]] = None, |
67 | | - tools: Optional[ToolsType] = None, |
68 | | - timeout: Optional[float] = None, |
69 | | - extra_headers: Optional[dict[str, Any]] = None, |
70 | | - max_retries: Optional[int] = None, |
71 | | - http_client_kwargs: Optional[dict[str, Any]] = None, |
| 64 | + streaming_callback: StreamingCallbackT | None = None, |
| 65 | + api_base_url: str | None = "https://openrouter.ai/api/v1", |
| 66 | + generation_kwargs: dict[str, Any] | None = None, |
| 67 | + tools: ToolsType | None = None, |
| 68 | + timeout: float | None = None, |
| 69 | + extra_headers: dict[str, Any] | None = None, |
| 70 | + max_retries: int | None = None, |
| 71 | + http_client_kwargs: dict[str, Any] | None = None, |
72 | 72 | ): |
73 | 73 | """ |
74 | 74 | Creates an instance of OpenRouterChatGenerator. Unless specified otherwise, |
@@ -167,10 +167,10 @@ def _prepare_api_call( |
167 | 167 | self, |
168 | 168 | *, |
169 | 169 | messages: list[ChatMessage], |
170 | | - streaming_callback: Optional[StreamingCallbackT] = None, |
171 | | - generation_kwargs: Optional[dict[str, Any]] = None, |
172 | | - tools: Optional[ToolsType] = None, |
173 | | - tools_strict: Optional[bool] = None, |
| 170 | + streaming_callback: StreamingCallbackT | None = None, |
| 171 | + generation_kwargs: dict[str, Any] | None = None, |
| 172 | + tools: ToolsType | None = None, |
| 173 | + tools_strict: bool | None = None, |
174 | 174 | ) -> dict[str, Any]: |
175 | 175 | # update generation kwargs by merging with the generation kwargs passed to the run method |
176 | 176 | generation_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})} |
|
0 commit comments