22#
33# SPDX-License-Identifier: Apache-2.0
44
5- from typing import Any , Dict , Optional , cast
5+ from typing import Any , Dict , Optional , Union , cast
66
77from haystack import component , default_to_dict , logging
88from haystack .dataclasses import ChatMessage , StreamingCallbackT
@@ -141,9 +141,9 @@ def run( # type: ignore[override]
141141 self ,
142142 * ,
143143 prompt : str ,
144- system_prompt : str | None = None ,
145- streaming_callback : StreamingCallbackT | None = None ,
146- generation_kwargs : dict [str , Any ] | None = None ,
144+ system_prompt : Optional [ str ] = None ,
145+ streaming_callback : Optional [ StreamingCallbackT ] = None ,
146+ generation_kwargs : Optional [ dict [str , Any ]] = None ,
147147 ) -> dict [str , Any ]:
148148 """
149149 Generate text completions synchronously.
@@ -179,9 +179,9 @@ async def run_async( # type: ignore[override]
179179 self ,
180180 * ,
181181 prompt : str ,
182- system_prompt : str | None = None ,
183- streaming_callback : StreamingCallbackT | None = None ,
184- generation_kwargs : dict [str , Any ] | None = None ,
182+ system_prompt : Optional [ str ] = None ,
183+ streaming_callback : Optional [ StreamingCallbackT ] = None ,
184+ generation_kwargs : Optional [ dict [str , Any ]] = None ,
185185 ) -> dict [str , Any ]:
186186 """
187187 Generate text completions asynchronously.
@@ -211,7 +211,7 @@ async def run_async( # type: ignore[override]
211211 replies = chat_response ["replies" ]
212212 return self ._convert_chat_response_to_generator_format (replies )
213213
214- def _prepare_messages (self , prompt : str , system_prompt : str | None = None ) -> list [ChatMessage ]:
214+ def _prepare_messages (self , prompt : str , system_prompt : Optional [ str ] = None ) -> list [ChatMessage ]:
215215 """
216216 Convert prompt and system_prompt to ChatMessage format.
217217
@@ -228,7 +228,7 @@ def _prepare_messages(self, prompt: str, system_prompt: str | None = None) -> li
228228
229229 def _convert_chat_response_to_generator_format (
230230 self , chat_messages : list [ChatMessage ]
231- ) -> dict [str , list [str ] | list [dict [str , Any ]]]:
231+ ) -> dict [str , Union [ list [str ], list [dict [str , Any ] ]]]:
232232 """
233233 Convert ChatGenerator response format to Generator format.
234234
0 commit comments