|
5 | 5 | from mistralai_gcp._hooks import HookContext |
6 | 6 | from mistralai_gcp.types import Nullable, OptionalNullable, UNSET |
7 | 7 | from mistralai_gcp.utils import eventstreaming |
8 | | -from typing import Any, AsyncGenerator, Generator, List, Optional, Union |
| 8 | +from typing import Any, List, Optional, Union |
9 | 9 |
|
10 | 10 |
|
11 | 11 | class Chat(BaseSDK): |
@@ -40,7 +40,7 @@ def stream( |
40 | 40 | retries: OptionalNullable[utils.RetryConfig] = UNSET, |
41 | 41 | server_url: Optional[str] = None, |
42 | 42 | timeout_ms: Optional[int] = None, |
43 | | - ) -> Optional[Generator[models.CompletionEvent, None, None]]: |
| 43 | + ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]: |
44 | 44 | r"""Stream chat completion |
45 | 45 |
|
46 | 46 | Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON. |
@@ -132,7 +132,7 @@ def stream( |
132 | 132 |
|
133 | 133 | data: Any = None |
134 | 134 | if utils.match_response(http_res, "200", "text/event-stream"): |
135 | | - return eventstreaming.stream_events( |
| 135 | + return eventstreaming.EventStream( |
136 | 136 | http_res, |
137 | 137 | lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), |
138 | 138 | sentinel="[DONE]", |
@@ -185,7 +185,7 @@ async def stream_async( |
185 | 185 | retries: OptionalNullable[utils.RetryConfig] = UNSET, |
186 | 186 | server_url: Optional[str] = None, |
187 | 187 | timeout_ms: Optional[int] = None, |
188 | | - ) -> Optional[AsyncGenerator[models.CompletionEvent, None]]: |
| 188 | + ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]: |
189 | 189 | r"""Stream chat completion |
190 | 190 |
|
191 | 191 | Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON. |
@@ -277,7 +277,7 @@ async def stream_async( |
277 | 277 |
|
278 | 278 | data: Any = None |
279 | 279 | if utils.match_response(http_res, "200", "text/event-stream"): |
280 | | - return eventstreaming.stream_events_async( |
| 280 | + return eventstreaming.EventStreamAsync( |
281 | 281 | http_res, |
282 | 282 | lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), |
283 | 283 | sentinel="[DONE]", |
|
0 commit comments