mistralai 1.5.0__py3-none-any.whl → 1.5.2rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistralai/_hooks/types.py +15 -3
- mistralai/_version.py +3 -3
- mistralai/agents.py +32 -12
- mistralai/basesdk.py +8 -0
- mistralai/chat.py +37 -17
- mistralai/classifiers.py +59 -37
- mistralai/embeddings.py +22 -18
- mistralai/extra/utils/response_format.py +3 -3
- mistralai/files.py +36 -0
- mistralai/fim.py +37 -17
- mistralai/httpclient.py +4 -2
- mistralai/jobs.py +30 -0
- mistralai/mistral_jobs.py +24 -0
- mistralai/models/__init__.py +43 -16
- mistralai/models/assistantmessage.py +2 -0
- mistralai/models/chatcompletionrequest.py +3 -10
- mistralai/models/chatcompletionstreamrequest.py +3 -10
- mistralai/models/chatmoderationrequest.py +86 -0
- mistralai/models/classificationrequest.py +7 -36
- mistralai/models/contentchunk.py +8 -1
- mistralai/models/documenturlchunk.py +56 -0
- mistralai/models/embeddingrequest.py +8 -44
- mistralai/models/filepurpose.py +1 -1
- mistralai/models/fimcompletionrequest.py +2 -3
- mistralai/models/fimcompletionstreamrequest.py +2 -3
- mistralai/models/ocrimageobject.py +77 -0
- mistralai/models/ocrpagedimensions.py +25 -0
- mistralai/models/ocrpageobject.py +64 -0
- mistralai/models/ocrrequest.py +97 -0
- mistralai/models/ocrresponse.py +26 -0
- mistralai/models/ocrusageinfo.py +51 -0
- mistralai/models/prediction.py +4 -5
- mistralai/models_.py +66 -18
- mistralai/ocr.py +248 -0
- mistralai/sdk.py +23 -3
- mistralai/sdkconfiguration.py +4 -2
- mistralai/utils/__init__.py +2 -0
- mistralai/utils/serializers.py +10 -6
- mistralai/utils/values.py +4 -1
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/METADATA +70 -19
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/RECORD +88 -76
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +10 -1
- mistralai_azure/_hooks/types.py +15 -3
- mistralai_azure/_version.py +3 -0
- mistralai_azure/basesdk.py +8 -0
- mistralai_azure/chat.py +88 -20
- mistralai_azure/httpclient.py +52 -0
- mistralai_azure/models/__init__.py +7 -0
- mistralai_azure/models/assistantmessage.py +2 -0
- mistralai_azure/models/chatcompletionrequest.py +8 -10
- mistralai_azure/models/chatcompletionstreamrequest.py +8 -10
- mistralai_azure/models/function.py +3 -0
- mistralai_azure/models/jsonschema.py +61 -0
- mistralai_azure/models/prediction.py +25 -0
- mistralai_azure/models/responseformat.py +42 -1
- mistralai_azure/models/responseformats.py +1 -1
- mistralai_azure/models/toolcall.py +3 -0
- mistralai_azure/sdk.py +56 -14
- mistralai_azure/sdkconfiguration.py +14 -6
- mistralai_azure/utils/__init__.py +2 -0
- mistralai_azure/utils/serializers.py +10 -6
- mistralai_azure/utils/values.py +4 -1
- mistralai_gcp/__init__.py +10 -1
- mistralai_gcp/_hooks/types.py +15 -3
- mistralai_gcp/_version.py +3 -0
- mistralai_gcp/basesdk.py +8 -0
- mistralai_gcp/chat.py +89 -21
- mistralai_gcp/fim.py +61 -21
- mistralai_gcp/httpclient.py +52 -0
- mistralai_gcp/models/__init__.py +7 -0
- mistralai_gcp/models/assistantmessage.py +2 -0
- mistralai_gcp/models/chatcompletionrequest.py +8 -10
- mistralai_gcp/models/chatcompletionstreamrequest.py +8 -10
- mistralai_gcp/models/fimcompletionrequest.py +2 -3
- mistralai_gcp/models/fimcompletionstreamrequest.py +2 -3
- mistralai_gcp/models/function.py +3 -0
- mistralai_gcp/models/jsonschema.py +61 -0
- mistralai_gcp/models/prediction.py +25 -0
- mistralai_gcp/models/responseformat.py +42 -1
- mistralai_gcp/models/responseformats.py +1 -1
- mistralai_gcp/models/toolcall.py +3 -0
- mistralai_gcp/sdk.py +63 -19
- mistralai_gcp/sdkconfiguration.py +14 -6
- mistralai_gcp/utils/__init__.py +2 -0
- mistralai_gcp/utils/serializers.py +10 -6
- mistralai_gcp/utils/values.py +4 -1
- mistralai/models/chatclassificationrequest.py +0 -113
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/LICENSE +0 -0
mistralai/_hooks/types.py
CHANGED
|
@@ -7,16 +7,19 @@ from typing import Any, Callable, List, Optional, Tuple, Union
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class HookContext:
|
|
10
|
+
base_url: str
|
|
10
11
|
operation_id: str
|
|
11
12
|
oauth2_scopes: Optional[List[str]] = None
|
|
12
13
|
security_source: Optional[Union[Any, Callable[[], Any]]] = None
|
|
13
14
|
|
|
14
15
|
def __init__(
|
|
15
16
|
self,
|
|
17
|
+
base_url: str,
|
|
16
18
|
operation_id: str,
|
|
17
19
|
oauth2_scopes: Optional[List[str]],
|
|
18
20
|
security_source: Optional[Union[Any, Callable[[], Any]]],
|
|
19
21
|
):
|
|
22
|
+
self.base_url = base_url
|
|
20
23
|
self.operation_id = operation_id
|
|
21
24
|
self.oauth2_scopes = oauth2_scopes
|
|
22
25
|
self.security_source = security_source
|
|
@@ -25,21 +28,30 @@ class HookContext:
|
|
|
25
28
|
class BeforeRequestContext(HookContext):
|
|
26
29
|
def __init__(self, hook_ctx: HookContext):
|
|
27
30
|
super().__init__(
|
|
28
|
-
hook_ctx.
|
|
31
|
+
hook_ctx.base_url,
|
|
32
|
+
hook_ctx.operation_id,
|
|
33
|
+
hook_ctx.oauth2_scopes,
|
|
34
|
+
hook_ctx.security_source,
|
|
29
35
|
)
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
class AfterSuccessContext(HookContext):
|
|
33
39
|
def __init__(self, hook_ctx: HookContext):
|
|
34
40
|
super().__init__(
|
|
35
|
-
hook_ctx.
|
|
41
|
+
hook_ctx.base_url,
|
|
42
|
+
hook_ctx.operation_id,
|
|
43
|
+
hook_ctx.oauth2_scopes,
|
|
44
|
+
hook_ctx.security_source,
|
|
36
45
|
)
|
|
37
46
|
|
|
38
47
|
|
|
39
48
|
class AfterErrorContext(HookContext):
|
|
40
49
|
def __init__(self, hook_ctx: HookContext):
|
|
41
50
|
super().__init__(
|
|
42
|
-
hook_ctx.
|
|
51
|
+
hook_ctx.base_url,
|
|
52
|
+
hook_ctx.operation_id,
|
|
53
|
+
hook_ctx.oauth2_scopes,
|
|
54
|
+
hook_ctx.security_source,
|
|
43
55
|
)
|
|
44
56
|
|
|
45
57
|
|
mistralai/_version.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "mistralai"
|
|
6
|
-
__version__: str = "1.5.
|
|
6
|
+
__version__: str = "1.5.2-rc.1"
|
|
7
7
|
__openapi_doc_version__: str = "0.0.2"
|
|
8
|
-
__gen_version__: str = "2.
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 1.5.
|
|
8
|
+
__gen_version__: str = "2.548.6"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 1.5.2-rc.1 2.548.6 0.0.2 mistralai"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
mistralai/agents.py
CHANGED
|
@@ -78,6 +78,8 @@ class Agents(BaseSDK):
|
|
|
78
78
|
|
|
79
79
|
if server_url is not None:
|
|
80
80
|
base_url = server_url
|
|
81
|
+
else:
|
|
82
|
+
base_url = self._get_url(base_url, url_variables)
|
|
81
83
|
|
|
82
84
|
request = models.AgentsCompletionRequest(
|
|
83
85
|
max_tokens=max_tokens,
|
|
@@ -132,6 +134,7 @@ class Agents(BaseSDK):
|
|
|
132
134
|
|
|
133
135
|
http_res = self.do_request(
|
|
134
136
|
hook_ctx=HookContext(
|
|
137
|
+
base_url=base_url or "",
|
|
135
138
|
operation_id="agents_completion_v1_agents_completions_post",
|
|
136
139
|
oauth2_scopes=[],
|
|
137
140
|
security_source=get_security_from_env(
|
|
@@ -143,12 +146,14 @@ class Agents(BaseSDK):
|
|
|
143
146
|
retry_config=retry_config,
|
|
144
147
|
)
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
response_data: Any = None
|
|
147
150
|
if utils.match_response(http_res, "200", "application/json"):
|
|
148
151
|
return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
|
|
149
152
|
if utils.match_response(http_res, "422", "application/json"):
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
response_data = utils.unmarshal_json(
|
|
154
|
+
http_res.text, models.HTTPValidationErrorData
|
|
155
|
+
)
|
|
156
|
+
raise models.HTTPValidationError(data=response_data)
|
|
152
157
|
if utils.match_response(http_res, "4XX", "*"):
|
|
153
158
|
http_res_text = utils.stream_to_text(http_res)
|
|
154
159
|
raise models.SDKError(
|
|
@@ -236,6 +241,8 @@ class Agents(BaseSDK):
|
|
|
236
241
|
|
|
237
242
|
if server_url is not None:
|
|
238
243
|
base_url = server_url
|
|
244
|
+
else:
|
|
245
|
+
base_url = self._get_url(base_url, url_variables)
|
|
239
246
|
|
|
240
247
|
request = models.AgentsCompletionRequest(
|
|
241
248
|
max_tokens=max_tokens,
|
|
@@ -290,6 +297,7 @@ class Agents(BaseSDK):
|
|
|
290
297
|
|
|
291
298
|
http_res = await self.do_request_async(
|
|
292
299
|
hook_ctx=HookContext(
|
|
300
|
+
base_url=base_url or "",
|
|
293
301
|
operation_id="agents_completion_v1_agents_completions_post",
|
|
294
302
|
oauth2_scopes=[],
|
|
295
303
|
security_source=get_security_from_env(
|
|
@@ -301,12 +309,14 @@ class Agents(BaseSDK):
|
|
|
301
309
|
retry_config=retry_config,
|
|
302
310
|
)
|
|
303
311
|
|
|
304
|
-
|
|
312
|
+
response_data: Any = None
|
|
305
313
|
if utils.match_response(http_res, "200", "application/json"):
|
|
306
314
|
return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
|
|
307
315
|
if utils.match_response(http_res, "422", "application/json"):
|
|
308
|
-
|
|
309
|
-
|
|
316
|
+
response_data = utils.unmarshal_json(
|
|
317
|
+
http_res.text, models.HTTPValidationErrorData
|
|
318
|
+
)
|
|
319
|
+
raise models.HTTPValidationError(data=response_data)
|
|
310
320
|
if utils.match_response(http_res, "4XX", "*"):
|
|
311
321
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
312
322
|
raise models.SDKError(
|
|
@@ -396,6 +406,8 @@ class Agents(BaseSDK):
|
|
|
396
406
|
|
|
397
407
|
if server_url is not None:
|
|
398
408
|
base_url = server_url
|
|
409
|
+
else:
|
|
410
|
+
base_url = self._get_url(base_url, url_variables)
|
|
399
411
|
|
|
400
412
|
request = models.AgentsCompletionStreamRequest(
|
|
401
413
|
max_tokens=max_tokens,
|
|
@@ -450,6 +462,7 @@ class Agents(BaseSDK):
|
|
|
450
462
|
|
|
451
463
|
http_res = self.do_request(
|
|
452
464
|
hook_ctx=HookContext(
|
|
465
|
+
base_url=base_url or "",
|
|
453
466
|
operation_id="stream_agents",
|
|
454
467
|
oauth2_scopes=[],
|
|
455
468
|
security_source=get_security_from_env(
|
|
@@ -462,7 +475,7 @@ class Agents(BaseSDK):
|
|
|
462
475
|
retry_config=retry_config,
|
|
463
476
|
)
|
|
464
477
|
|
|
465
|
-
|
|
478
|
+
response_data: Any = None
|
|
466
479
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
467
480
|
return eventstreaming.EventStream(
|
|
468
481
|
http_res,
|
|
@@ -471,8 +484,10 @@ class Agents(BaseSDK):
|
|
|
471
484
|
)
|
|
472
485
|
if utils.match_response(http_res, "422", "application/json"):
|
|
473
486
|
http_res_text = utils.stream_to_text(http_res)
|
|
474
|
-
|
|
475
|
-
|
|
487
|
+
response_data = utils.unmarshal_json(
|
|
488
|
+
http_res_text, models.HTTPValidationErrorData
|
|
489
|
+
)
|
|
490
|
+
raise models.HTTPValidationError(data=response_data)
|
|
476
491
|
if utils.match_response(http_res, "4XX", "*"):
|
|
477
492
|
http_res_text = utils.stream_to_text(http_res)
|
|
478
493
|
raise models.SDKError(
|
|
@@ -562,6 +577,8 @@ class Agents(BaseSDK):
|
|
|
562
577
|
|
|
563
578
|
if server_url is not None:
|
|
564
579
|
base_url = server_url
|
|
580
|
+
else:
|
|
581
|
+
base_url = self._get_url(base_url, url_variables)
|
|
565
582
|
|
|
566
583
|
request = models.AgentsCompletionStreamRequest(
|
|
567
584
|
max_tokens=max_tokens,
|
|
@@ -616,6 +633,7 @@ class Agents(BaseSDK):
|
|
|
616
633
|
|
|
617
634
|
http_res = await self.do_request_async(
|
|
618
635
|
hook_ctx=HookContext(
|
|
636
|
+
base_url=base_url or "",
|
|
619
637
|
operation_id="stream_agents",
|
|
620
638
|
oauth2_scopes=[],
|
|
621
639
|
security_source=get_security_from_env(
|
|
@@ -628,7 +646,7 @@ class Agents(BaseSDK):
|
|
|
628
646
|
retry_config=retry_config,
|
|
629
647
|
)
|
|
630
648
|
|
|
631
|
-
|
|
649
|
+
response_data: Any = None
|
|
632
650
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
633
651
|
return eventstreaming.EventStreamAsync(
|
|
634
652
|
http_res,
|
|
@@ -637,8 +655,10 @@ class Agents(BaseSDK):
|
|
|
637
655
|
)
|
|
638
656
|
if utils.match_response(http_res, "422", "application/json"):
|
|
639
657
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
640
|
-
|
|
641
|
-
|
|
658
|
+
response_data = utils.unmarshal_json(
|
|
659
|
+
http_res_text, models.HTTPValidationErrorData
|
|
660
|
+
)
|
|
661
|
+
raise models.HTTPValidationError(data=response_data)
|
|
642
662
|
if utils.match_response(http_res, "4XX", "*"):
|
|
643
663
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
644
664
|
raise models.SDKError(
|
mistralai/basesdk.py
CHANGED
|
@@ -231,6 +231,10 @@ class BaseSDK:
|
|
|
231
231
|
req.headers,
|
|
232
232
|
get_body_content(req),
|
|
233
233
|
)
|
|
234
|
+
|
|
235
|
+
if client is None:
|
|
236
|
+
raise ValueError("client is required")
|
|
237
|
+
|
|
234
238
|
http_res = client.send(req, stream=stream)
|
|
235
239
|
except Exception as e:
|
|
236
240
|
_, e = self.sdk_configuration.get_hooks().after_error(
|
|
@@ -303,6 +307,10 @@ class BaseSDK:
|
|
|
303
307
|
req.headers,
|
|
304
308
|
get_body_content(req),
|
|
305
309
|
)
|
|
310
|
+
|
|
311
|
+
if client is None:
|
|
312
|
+
raise ValueError("client is required")
|
|
313
|
+
|
|
306
314
|
http_res = await client.send(req, stream=stream)
|
|
307
315
|
except Exception as e:
|
|
308
316
|
_, e = self.sdk_configuration.get_hooks().after_error(
|
mistralai/chat.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
4
|
from mistralai import models, utils
|
|
5
5
|
from mistralai._hooks import HookContext
|
|
6
|
-
from mistralai.types import
|
|
6
|
+
from mistralai.types import OptionalNullable, UNSET
|
|
7
7
|
from mistralai.utils import eventstreaming, get_security_from_env
|
|
8
8
|
from typing import Any, List, Mapping, Optional, Union
|
|
9
9
|
|
|
@@ -96,7 +96,7 @@ class Chat(BaseSDK):
|
|
|
96
96
|
def complete(
|
|
97
97
|
self,
|
|
98
98
|
*,
|
|
99
|
-
model:
|
|
99
|
+
model: str,
|
|
100
100
|
messages: Union[List[models.Messages], List[models.MessagesTypedDict]],
|
|
101
101
|
temperature: OptionalNullable[float] = UNSET,
|
|
102
102
|
top_p: Optional[float] = None,
|
|
@@ -158,6 +158,8 @@ class Chat(BaseSDK):
|
|
|
158
158
|
|
|
159
159
|
if server_url is not None:
|
|
160
160
|
base_url = server_url
|
|
161
|
+
else:
|
|
162
|
+
base_url = self._get_url(base_url, url_variables)
|
|
161
163
|
|
|
162
164
|
request = models.ChatCompletionRequest(
|
|
163
165
|
model=model,
|
|
@@ -213,6 +215,7 @@ class Chat(BaseSDK):
|
|
|
213
215
|
|
|
214
216
|
http_res = self.do_request(
|
|
215
217
|
hook_ctx=HookContext(
|
|
218
|
+
base_url=base_url or "",
|
|
216
219
|
operation_id="chat_completion_v1_chat_completions_post",
|
|
217
220
|
oauth2_scopes=[],
|
|
218
221
|
security_source=get_security_from_env(
|
|
@@ -224,12 +227,14 @@ class Chat(BaseSDK):
|
|
|
224
227
|
retry_config=retry_config,
|
|
225
228
|
)
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
response_data: Any = None
|
|
228
231
|
if utils.match_response(http_res, "200", "application/json"):
|
|
229
232
|
return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
|
|
230
233
|
if utils.match_response(http_res, "422", "application/json"):
|
|
231
|
-
|
|
232
|
-
|
|
234
|
+
response_data = utils.unmarshal_json(
|
|
235
|
+
http_res.text, models.HTTPValidationErrorData
|
|
236
|
+
)
|
|
237
|
+
raise models.HTTPValidationError(data=response_data)
|
|
233
238
|
if utils.match_response(http_res, "4XX", "*"):
|
|
234
239
|
http_res_text = utils.stream_to_text(http_res)
|
|
235
240
|
raise models.SDKError(
|
|
@@ -253,7 +258,7 @@ class Chat(BaseSDK):
|
|
|
253
258
|
async def complete_async(
|
|
254
259
|
self,
|
|
255
260
|
*,
|
|
256
|
-
model:
|
|
261
|
+
model: str,
|
|
257
262
|
messages: Union[List[models.Messages], List[models.MessagesTypedDict]],
|
|
258
263
|
temperature: OptionalNullable[float] = UNSET,
|
|
259
264
|
top_p: Optional[float] = None,
|
|
@@ -315,6 +320,8 @@ class Chat(BaseSDK):
|
|
|
315
320
|
|
|
316
321
|
if server_url is not None:
|
|
317
322
|
base_url = server_url
|
|
323
|
+
else:
|
|
324
|
+
base_url = self._get_url(base_url, url_variables)
|
|
318
325
|
|
|
319
326
|
request = models.ChatCompletionRequest(
|
|
320
327
|
model=model,
|
|
@@ -370,6 +377,7 @@ class Chat(BaseSDK):
|
|
|
370
377
|
|
|
371
378
|
http_res = await self.do_request_async(
|
|
372
379
|
hook_ctx=HookContext(
|
|
380
|
+
base_url=base_url or "",
|
|
373
381
|
operation_id="chat_completion_v1_chat_completions_post",
|
|
374
382
|
oauth2_scopes=[],
|
|
375
383
|
security_source=get_security_from_env(
|
|
@@ -381,12 +389,14 @@ class Chat(BaseSDK):
|
|
|
381
389
|
retry_config=retry_config,
|
|
382
390
|
)
|
|
383
391
|
|
|
384
|
-
|
|
392
|
+
response_data: Any = None
|
|
385
393
|
if utils.match_response(http_res, "200", "application/json"):
|
|
386
394
|
return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
|
|
387
395
|
if utils.match_response(http_res, "422", "application/json"):
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
response_data = utils.unmarshal_json(
|
|
397
|
+
http_res.text, models.HTTPValidationErrorData
|
|
398
|
+
)
|
|
399
|
+
raise models.HTTPValidationError(data=response_data)
|
|
390
400
|
if utils.match_response(http_res, "4XX", "*"):
|
|
391
401
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
392
402
|
raise models.SDKError(
|
|
@@ -410,7 +420,7 @@ class Chat(BaseSDK):
|
|
|
410
420
|
def stream(
|
|
411
421
|
self,
|
|
412
422
|
*,
|
|
413
|
-
model:
|
|
423
|
+
model: str,
|
|
414
424
|
messages: Union[
|
|
415
425
|
List[models.ChatCompletionStreamRequestMessages],
|
|
416
426
|
List[models.ChatCompletionStreamRequestMessagesTypedDict],
|
|
@@ -482,6 +492,8 @@ class Chat(BaseSDK):
|
|
|
482
492
|
|
|
483
493
|
if server_url is not None:
|
|
484
494
|
base_url = server_url
|
|
495
|
+
else:
|
|
496
|
+
base_url = self._get_url(base_url, url_variables)
|
|
485
497
|
|
|
486
498
|
request = models.ChatCompletionStreamRequest(
|
|
487
499
|
model=model,
|
|
@@ -539,6 +551,7 @@ class Chat(BaseSDK):
|
|
|
539
551
|
|
|
540
552
|
http_res = self.do_request(
|
|
541
553
|
hook_ctx=HookContext(
|
|
554
|
+
base_url=base_url or "",
|
|
542
555
|
operation_id="stream_chat",
|
|
543
556
|
oauth2_scopes=[],
|
|
544
557
|
security_source=get_security_from_env(
|
|
@@ -551,7 +564,7 @@ class Chat(BaseSDK):
|
|
|
551
564
|
retry_config=retry_config,
|
|
552
565
|
)
|
|
553
566
|
|
|
554
|
-
|
|
567
|
+
response_data: Any = None
|
|
555
568
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
556
569
|
return eventstreaming.EventStream(
|
|
557
570
|
http_res,
|
|
@@ -560,8 +573,10 @@ class Chat(BaseSDK):
|
|
|
560
573
|
)
|
|
561
574
|
if utils.match_response(http_res, "422", "application/json"):
|
|
562
575
|
http_res_text = utils.stream_to_text(http_res)
|
|
563
|
-
|
|
564
|
-
|
|
576
|
+
response_data = utils.unmarshal_json(
|
|
577
|
+
http_res_text, models.HTTPValidationErrorData
|
|
578
|
+
)
|
|
579
|
+
raise models.HTTPValidationError(data=response_data)
|
|
565
580
|
if utils.match_response(http_res, "4XX", "*"):
|
|
566
581
|
http_res_text = utils.stream_to_text(http_res)
|
|
567
582
|
raise models.SDKError(
|
|
@@ -585,7 +600,7 @@ class Chat(BaseSDK):
|
|
|
585
600
|
async def stream_async(
|
|
586
601
|
self,
|
|
587
602
|
*,
|
|
588
|
-
model:
|
|
603
|
+
model: str,
|
|
589
604
|
messages: Union[
|
|
590
605
|
List[models.ChatCompletionStreamRequestMessages],
|
|
591
606
|
List[models.ChatCompletionStreamRequestMessagesTypedDict],
|
|
@@ -657,6 +672,8 @@ class Chat(BaseSDK):
|
|
|
657
672
|
|
|
658
673
|
if server_url is not None:
|
|
659
674
|
base_url = server_url
|
|
675
|
+
else:
|
|
676
|
+
base_url = self._get_url(base_url, url_variables)
|
|
660
677
|
|
|
661
678
|
request = models.ChatCompletionStreamRequest(
|
|
662
679
|
model=model,
|
|
@@ -714,6 +731,7 @@ class Chat(BaseSDK):
|
|
|
714
731
|
|
|
715
732
|
http_res = await self.do_request_async(
|
|
716
733
|
hook_ctx=HookContext(
|
|
734
|
+
base_url=base_url or "",
|
|
717
735
|
operation_id="stream_chat",
|
|
718
736
|
oauth2_scopes=[],
|
|
719
737
|
security_source=get_security_from_env(
|
|
@@ -726,7 +744,7 @@ class Chat(BaseSDK):
|
|
|
726
744
|
retry_config=retry_config,
|
|
727
745
|
)
|
|
728
746
|
|
|
729
|
-
|
|
747
|
+
response_data: Any = None
|
|
730
748
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
731
749
|
return eventstreaming.EventStreamAsync(
|
|
732
750
|
http_res,
|
|
@@ -735,8 +753,10 @@ class Chat(BaseSDK):
|
|
|
735
753
|
)
|
|
736
754
|
if utils.match_response(http_res, "422", "application/json"):
|
|
737
755
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
738
|
-
|
|
739
|
-
|
|
756
|
+
response_data = utils.unmarshal_json(
|
|
757
|
+
http_res_text, models.HTTPValidationErrorData
|
|
758
|
+
)
|
|
759
|
+
raise models.HTTPValidationError(data=response_data)
|
|
740
760
|
if utils.match_response(http_res, "4XX", "*"):
|
|
741
761
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
742
762
|
raise models.SDKError(
|