mistralai 1.5.2__py3-none-any.whl → 1.6.0__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.
Files changed (80) hide show
  1. mistralai/_hooks/types.py +15 -3
  2. mistralai/_version.py +3 -3
  3. mistralai/agents.py +44 -12
  4. mistralai/basesdk.py +8 -0
  5. mistralai/chat.py +44 -12
  6. mistralai/classifiers.py +36 -16
  7. mistralai/embeddings.py +16 -6
  8. mistralai/files.py +36 -0
  9. mistralai/fim.py +32 -12
  10. mistralai/httpclient.py +4 -2
  11. mistralai/jobs.py +30 -0
  12. mistralai/mistral_jobs.py +24 -0
  13. mistralai/models/agentscompletionrequest.py +4 -0
  14. mistralai/models/agentscompletionstreamrequest.py +4 -0
  15. mistralai/models/chatcompletionrequest.py +4 -0
  16. mistralai/models/chatcompletionstreamrequest.py +4 -0
  17. mistralai/models/function.py +2 -2
  18. mistralai/models/jsonschema.py +1 -1
  19. mistralai/models_.py +66 -18
  20. mistralai/ocr.py +16 -6
  21. mistralai/sdk.py +19 -3
  22. mistralai/sdkconfiguration.py +4 -2
  23. mistralai/utils/__init__.py +2 -0
  24. mistralai/utils/serializers.py +10 -6
  25. mistralai/utils/values.py +4 -1
  26. {mistralai-1.5.2.dist-info → mistralai-1.6.0.dist-info}/METADATA +63 -16
  27. {mistralai-1.5.2.dist-info → mistralai-1.6.0.dist-info}/RECORD +80 -72
  28. mistralai_azure/__init__.py +10 -1
  29. mistralai_azure/_hooks/types.py +15 -3
  30. mistralai_azure/_version.py +4 -1
  31. mistralai_azure/basesdk.py +8 -0
  32. mistralai_azure/chat.py +100 -20
  33. mistralai_azure/httpclient.py +52 -0
  34. mistralai_azure/models/__init__.py +22 -0
  35. mistralai_azure/models/assistantmessage.py +2 -0
  36. mistralai_azure/models/chatcompletionrequest.py +12 -10
  37. mistralai_azure/models/chatcompletionstreamrequest.py +12 -10
  38. mistralai_azure/models/contentchunk.py +6 -2
  39. mistralai_azure/models/function.py +4 -1
  40. mistralai_azure/models/imageurl.py +53 -0
  41. mistralai_azure/models/imageurlchunk.py +33 -0
  42. mistralai_azure/models/jsonschema.py +61 -0
  43. mistralai_azure/models/prediction.py +25 -0
  44. mistralai_azure/models/responseformat.py +42 -1
  45. mistralai_azure/models/responseformats.py +1 -1
  46. mistralai_azure/models/toolcall.py +3 -0
  47. mistralai_azure/sdk.py +56 -14
  48. mistralai_azure/sdkconfiguration.py +14 -6
  49. mistralai_azure/utils/__init__.py +2 -0
  50. mistralai_azure/utils/serializers.py +10 -6
  51. mistralai_azure/utils/values.py +4 -1
  52. mistralai_gcp/__init__.py +10 -1
  53. mistralai_gcp/_hooks/types.py +15 -3
  54. mistralai_gcp/_version.py +4 -1
  55. mistralai_gcp/basesdk.py +8 -0
  56. mistralai_gcp/chat.py +101 -21
  57. mistralai_gcp/fim.py +61 -21
  58. mistralai_gcp/httpclient.py +52 -0
  59. mistralai_gcp/models/__init__.py +22 -0
  60. mistralai_gcp/models/assistantmessage.py +2 -0
  61. mistralai_gcp/models/chatcompletionrequest.py +12 -10
  62. mistralai_gcp/models/chatcompletionstreamrequest.py +12 -10
  63. mistralai_gcp/models/contentchunk.py +6 -2
  64. mistralai_gcp/models/fimcompletionrequest.py +2 -3
  65. mistralai_gcp/models/fimcompletionstreamrequest.py +2 -3
  66. mistralai_gcp/models/function.py +4 -1
  67. mistralai_gcp/models/imageurl.py +53 -0
  68. mistralai_gcp/models/imageurlchunk.py +33 -0
  69. mistralai_gcp/models/jsonschema.py +61 -0
  70. mistralai_gcp/models/prediction.py +25 -0
  71. mistralai_gcp/models/responseformat.py +42 -1
  72. mistralai_gcp/models/responseformats.py +1 -1
  73. mistralai_gcp/models/toolcall.py +3 -0
  74. mistralai_gcp/sdk.py +63 -19
  75. mistralai_gcp/sdkconfiguration.py +14 -6
  76. mistralai_gcp/utils/__init__.py +2 -0
  77. mistralai_gcp/utils/serializers.py +10 -6
  78. mistralai_gcp/utils/values.py +4 -1
  79. {mistralai-1.5.2.dist-info → mistralai-1.6.0.dist-info}/LICENSE +0 -0
  80. {mistralai-1.5.2.dist-info → mistralai-1.6.0.dist-info}/WHEEL +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.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source
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.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source
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.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source
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.2"
6
+ __version__: str = "1.6.0"
7
7
  __openapi_doc_version__: str = "0.0.2"
8
- __gen_version__: str = "2.497.0"
9
- __user_agent__: str = "speakeasy-sdk/python 1.5.2 2.497.0 0.0.2 mistralai"
8
+ __gen_version__: str = "2.548.6"
9
+ __user_agent__: str = "speakeasy-sdk/python 1.6.0 2.548.6 0.0.2 mistralai"
10
10
 
11
11
  try:
12
12
  if __package__ is not None:
mistralai/agents.py CHANGED
@@ -46,6 +46,7 @@ class Agents(BaseSDK):
46
46
  prediction: Optional[
47
47
  Union[models.Prediction, models.PredictionTypedDict]
48
48
  ] = None,
49
+ parallel_tool_calls: Optional[bool] = None,
49
50
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
50
51
  server_url: Optional[str] = None,
51
52
  timeout_ms: Optional[int] = None,
@@ -66,6 +67,7 @@ class Agents(BaseSDK):
66
67
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
67
68
  :param n: Number of completions to return for each request, input tokens are only billed once.
68
69
  :param prediction:
70
+ :param parallel_tool_calls:
69
71
  :param retries: Override the default retry configuration for this method
70
72
  :param server_url: Override the default server URL for this method
71
73
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -78,6 +80,8 @@ class Agents(BaseSDK):
78
80
 
79
81
  if server_url is not None:
80
82
  base_url = server_url
83
+ else:
84
+ base_url = self._get_url(base_url, url_variables)
81
85
 
82
86
  request = models.AgentsCompletionRequest(
83
87
  max_tokens=max_tokens,
@@ -100,6 +104,7 @@ class Agents(BaseSDK):
100
104
  prediction=utils.get_pydantic_model(
101
105
  prediction, Optional[models.Prediction]
102
106
  ),
107
+ parallel_tool_calls=parallel_tool_calls,
103
108
  agent_id=agent_id,
104
109
  )
105
110
 
@@ -132,6 +137,7 @@ class Agents(BaseSDK):
132
137
 
133
138
  http_res = self.do_request(
134
139
  hook_ctx=HookContext(
140
+ base_url=base_url or "",
135
141
  operation_id="agents_completion_v1_agents_completions_post",
136
142
  oauth2_scopes=[],
137
143
  security_source=get_security_from_env(
@@ -143,12 +149,14 @@ class Agents(BaseSDK):
143
149
  retry_config=retry_config,
144
150
  )
145
151
 
146
- data: Any = None
152
+ response_data: Any = None
147
153
  if utils.match_response(http_res, "200", "application/json"):
148
154
  return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
149
155
  if utils.match_response(http_res, "422", "application/json"):
150
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
151
- raise models.HTTPValidationError(data=data)
156
+ response_data = utils.unmarshal_json(
157
+ http_res.text, models.HTTPValidationErrorData
158
+ )
159
+ raise models.HTTPValidationError(data=response_data)
152
160
  if utils.match_response(http_res, "4XX", "*"):
153
161
  http_res_text = utils.stream_to_text(http_res)
154
162
  raise models.SDKError(
@@ -204,6 +212,7 @@ class Agents(BaseSDK):
204
212
  prediction: Optional[
205
213
  Union[models.Prediction, models.PredictionTypedDict]
206
214
  ] = None,
215
+ parallel_tool_calls: Optional[bool] = None,
207
216
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
208
217
  server_url: Optional[str] = None,
209
218
  timeout_ms: Optional[int] = None,
@@ -224,6 +233,7 @@ class Agents(BaseSDK):
224
233
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
225
234
  :param n: Number of completions to return for each request, input tokens are only billed once.
226
235
  :param prediction:
236
+ :param parallel_tool_calls:
227
237
  :param retries: Override the default retry configuration for this method
228
238
  :param server_url: Override the default server URL for this method
229
239
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -236,6 +246,8 @@ class Agents(BaseSDK):
236
246
 
237
247
  if server_url is not None:
238
248
  base_url = server_url
249
+ else:
250
+ base_url = self._get_url(base_url, url_variables)
239
251
 
240
252
  request = models.AgentsCompletionRequest(
241
253
  max_tokens=max_tokens,
@@ -258,6 +270,7 @@ class Agents(BaseSDK):
258
270
  prediction=utils.get_pydantic_model(
259
271
  prediction, Optional[models.Prediction]
260
272
  ),
273
+ parallel_tool_calls=parallel_tool_calls,
261
274
  agent_id=agent_id,
262
275
  )
263
276
 
@@ -290,6 +303,7 @@ class Agents(BaseSDK):
290
303
 
291
304
  http_res = await self.do_request_async(
292
305
  hook_ctx=HookContext(
306
+ base_url=base_url or "",
293
307
  operation_id="agents_completion_v1_agents_completions_post",
294
308
  oauth2_scopes=[],
295
309
  security_source=get_security_from_env(
@@ -301,12 +315,14 @@ class Agents(BaseSDK):
301
315
  retry_config=retry_config,
302
316
  )
303
317
 
304
- data: Any = None
318
+ response_data: Any = None
305
319
  if utils.match_response(http_res, "200", "application/json"):
306
320
  return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
307
321
  if utils.match_response(http_res, "422", "application/json"):
308
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
309
- raise models.HTTPValidationError(data=data)
322
+ response_data = utils.unmarshal_json(
323
+ http_res.text, models.HTTPValidationErrorData
324
+ )
325
+ raise models.HTTPValidationError(data=response_data)
310
326
  if utils.match_response(http_res, "4XX", "*"):
311
327
  http_res_text = await utils.stream_to_text_async(http_res)
312
328
  raise models.SDKError(
@@ -362,6 +378,7 @@ class Agents(BaseSDK):
362
378
  prediction: Optional[
363
379
  Union[models.Prediction, models.PredictionTypedDict]
364
380
  ] = None,
381
+ parallel_tool_calls: Optional[bool] = None,
365
382
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
366
383
  server_url: Optional[str] = None,
367
384
  timeout_ms: Optional[int] = None,
@@ -384,6 +401,7 @@ class Agents(BaseSDK):
384
401
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
385
402
  :param n: Number of completions to return for each request, input tokens are only billed once.
386
403
  :param prediction:
404
+ :param parallel_tool_calls:
387
405
  :param retries: Override the default retry configuration for this method
388
406
  :param server_url: Override the default server URL for this method
389
407
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -396,6 +414,8 @@ class Agents(BaseSDK):
396
414
 
397
415
  if server_url is not None:
398
416
  base_url = server_url
417
+ else:
418
+ base_url = self._get_url(base_url, url_variables)
399
419
 
400
420
  request = models.AgentsCompletionStreamRequest(
401
421
  max_tokens=max_tokens,
@@ -418,6 +438,7 @@ class Agents(BaseSDK):
418
438
  prediction=utils.get_pydantic_model(
419
439
  prediction, Optional[models.Prediction]
420
440
  ),
441
+ parallel_tool_calls=parallel_tool_calls,
421
442
  agent_id=agent_id,
422
443
  )
423
444
 
@@ -450,6 +471,7 @@ class Agents(BaseSDK):
450
471
 
451
472
  http_res = self.do_request(
452
473
  hook_ctx=HookContext(
474
+ base_url=base_url or "",
453
475
  operation_id="stream_agents",
454
476
  oauth2_scopes=[],
455
477
  security_source=get_security_from_env(
@@ -462,7 +484,7 @@ class Agents(BaseSDK):
462
484
  retry_config=retry_config,
463
485
  )
464
486
 
465
- data: Any = None
487
+ response_data: Any = None
466
488
  if utils.match_response(http_res, "200", "text/event-stream"):
467
489
  return eventstreaming.EventStream(
468
490
  http_res,
@@ -471,8 +493,10 @@ class Agents(BaseSDK):
471
493
  )
472
494
  if utils.match_response(http_res, "422", "application/json"):
473
495
  http_res_text = utils.stream_to_text(http_res)
474
- data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
475
- raise models.HTTPValidationError(data=data)
496
+ response_data = utils.unmarshal_json(
497
+ http_res_text, models.HTTPValidationErrorData
498
+ )
499
+ raise models.HTTPValidationError(data=response_data)
476
500
  if utils.match_response(http_res, "4XX", "*"):
477
501
  http_res_text = utils.stream_to_text(http_res)
478
502
  raise models.SDKError(
@@ -528,6 +552,7 @@ class Agents(BaseSDK):
528
552
  prediction: Optional[
529
553
  Union[models.Prediction, models.PredictionTypedDict]
530
554
  ] = None,
555
+ parallel_tool_calls: Optional[bool] = None,
531
556
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
532
557
  server_url: Optional[str] = None,
533
558
  timeout_ms: Optional[int] = None,
@@ -550,6 +575,7 @@ class Agents(BaseSDK):
550
575
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
551
576
  :param n: Number of completions to return for each request, input tokens are only billed once.
552
577
  :param prediction:
578
+ :param parallel_tool_calls:
553
579
  :param retries: Override the default retry configuration for this method
554
580
  :param server_url: Override the default server URL for this method
555
581
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -562,6 +588,8 @@ class Agents(BaseSDK):
562
588
 
563
589
  if server_url is not None:
564
590
  base_url = server_url
591
+ else:
592
+ base_url = self._get_url(base_url, url_variables)
565
593
 
566
594
  request = models.AgentsCompletionStreamRequest(
567
595
  max_tokens=max_tokens,
@@ -584,6 +612,7 @@ class Agents(BaseSDK):
584
612
  prediction=utils.get_pydantic_model(
585
613
  prediction, Optional[models.Prediction]
586
614
  ),
615
+ parallel_tool_calls=parallel_tool_calls,
587
616
  agent_id=agent_id,
588
617
  )
589
618
 
@@ -616,6 +645,7 @@ class Agents(BaseSDK):
616
645
 
617
646
  http_res = await self.do_request_async(
618
647
  hook_ctx=HookContext(
648
+ base_url=base_url or "",
619
649
  operation_id="stream_agents",
620
650
  oauth2_scopes=[],
621
651
  security_source=get_security_from_env(
@@ -628,7 +658,7 @@ class Agents(BaseSDK):
628
658
  retry_config=retry_config,
629
659
  )
630
660
 
631
- data: Any = None
661
+ response_data: Any = None
632
662
  if utils.match_response(http_res, "200", "text/event-stream"):
633
663
  return eventstreaming.EventStreamAsync(
634
664
  http_res,
@@ -637,8 +667,10 @@ class Agents(BaseSDK):
637
667
  )
638
668
  if utils.match_response(http_res, "422", "application/json"):
639
669
  http_res_text = await utils.stream_to_text_async(http_res)
640
- data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
641
- raise models.HTTPValidationError(data=data)
670
+ response_data = utils.unmarshal_json(
671
+ http_res_text, models.HTTPValidationErrorData
672
+ )
673
+ raise models.HTTPValidationError(data=response_data)
642
674
  if utils.match_response(http_res, "4XX", "*"):
643
675
  http_res_text = await utils.stream_to_text_async(http_res)
644
676
  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
@@ -122,6 +122,7 @@ class Chat(BaseSDK):
122
122
  prediction: Optional[
123
123
  Union[models.Prediction, models.PredictionTypedDict]
124
124
  ] = None,
125
+ parallel_tool_calls: Optional[bool] = None,
125
126
  safe_prompt: Optional[bool] = None,
126
127
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
127
128
  server_url: Optional[str] = None,
@@ -145,6 +146,7 @@ class Chat(BaseSDK):
145
146
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
146
147
  :param n: Number of completions to return for each request, input tokens are only billed once.
147
148
  :param prediction:
149
+ :param parallel_tool_calls:
148
150
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
149
151
  :param retries: Override the default retry configuration for this method
150
152
  :param server_url: Override the default server URL for this method
@@ -158,6 +160,8 @@ class Chat(BaseSDK):
158
160
 
159
161
  if server_url is not None:
160
162
  base_url = server_url
163
+ else:
164
+ base_url = self._get_url(base_url, url_variables)
161
165
 
162
166
  request = models.ChatCompletionRequest(
163
167
  model=model,
@@ -181,6 +185,7 @@ class Chat(BaseSDK):
181
185
  prediction=utils.get_pydantic_model(
182
186
  prediction, Optional[models.Prediction]
183
187
  ),
188
+ parallel_tool_calls=parallel_tool_calls,
184
189
  safe_prompt=safe_prompt,
185
190
  )
186
191
 
@@ -213,6 +218,7 @@ class Chat(BaseSDK):
213
218
 
214
219
  http_res = self.do_request(
215
220
  hook_ctx=HookContext(
221
+ base_url=base_url or "",
216
222
  operation_id="chat_completion_v1_chat_completions_post",
217
223
  oauth2_scopes=[],
218
224
  security_source=get_security_from_env(
@@ -224,12 +230,14 @@ class Chat(BaseSDK):
224
230
  retry_config=retry_config,
225
231
  )
226
232
 
227
- data: Any = None
233
+ response_data: Any = None
228
234
  if utils.match_response(http_res, "200", "application/json"):
229
235
  return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
230
236
  if utils.match_response(http_res, "422", "application/json"):
231
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
232
- raise models.HTTPValidationError(data=data)
237
+ response_data = utils.unmarshal_json(
238
+ http_res.text, models.HTTPValidationErrorData
239
+ )
240
+ raise models.HTTPValidationError(data=response_data)
233
241
  if utils.match_response(http_res, "4XX", "*"):
234
242
  http_res_text = utils.stream_to_text(http_res)
235
243
  raise models.SDKError(
@@ -279,6 +287,7 @@ class Chat(BaseSDK):
279
287
  prediction: Optional[
280
288
  Union[models.Prediction, models.PredictionTypedDict]
281
289
  ] = None,
290
+ parallel_tool_calls: Optional[bool] = None,
282
291
  safe_prompt: Optional[bool] = None,
283
292
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
284
293
  server_url: Optional[str] = None,
@@ -302,6 +311,7 @@ class Chat(BaseSDK):
302
311
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
303
312
  :param n: Number of completions to return for each request, input tokens are only billed once.
304
313
  :param prediction:
314
+ :param parallel_tool_calls:
305
315
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
306
316
  :param retries: Override the default retry configuration for this method
307
317
  :param server_url: Override the default server URL for this method
@@ -315,6 +325,8 @@ class Chat(BaseSDK):
315
325
 
316
326
  if server_url is not None:
317
327
  base_url = server_url
328
+ else:
329
+ base_url = self._get_url(base_url, url_variables)
318
330
 
319
331
  request = models.ChatCompletionRequest(
320
332
  model=model,
@@ -338,6 +350,7 @@ class Chat(BaseSDK):
338
350
  prediction=utils.get_pydantic_model(
339
351
  prediction, Optional[models.Prediction]
340
352
  ),
353
+ parallel_tool_calls=parallel_tool_calls,
341
354
  safe_prompt=safe_prompt,
342
355
  )
343
356
 
@@ -370,6 +383,7 @@ class Chat(BaseSDK):
370
383
 
371
384
  http_res = await self.do_request_async(
372
385
  hook_ctx=HookContext(
386
+ base_url=base_url or "",
373
387
  operation_id="chat_completion_v1_chat_completions_post",
374
388
  oauth2_scopes=[],
375
389
  security_source=get_security_from_env(
@@ -381,12 +395,14 @@ class Chat(BaseSDK):
381
395
  retry_config=retry_config,
382
396
  )
383
397
 
384
- data: Any = None
398
+ response_data: Any = None
385
399
  if utils.match_response(http_res, "200", "application/json"):
386
400
  return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
387
401
  if utils.match_response(http_res, "422", "application/json"):
388
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
389
- raise models.HTTPValidationError(data=data)
402
+ response_data = utils.unmarshal_json(
403
+ http_res.text, models.HTTPValidationErrorData
404
+ )
405
+ raise models.HTTPValidationError(data=response_data)
390
406
  if utils.match_response(http_res, "4XX", "*"):
391
407
  http_res_text = await utils.stream_to_text_async(http_res)
392
408
  raise models.SDKError(
@@ -444,6 +460,7 @@ class Chat(BaseSDK):
444
460
  prediction: Optional[
445
461
  Union[models.Prediction, models.PredictionTypedDict]
446
462
  ] = None,
463
+ parallel_tool_calls: Optional[bool] = None,
447
464
  safe_prompt: Optional[bool] = None,
448
465
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
449
466
  server_url: Optional[str] = None,
@@ -469,6 +486,7 @@ class Chat(BaseSDK):
469
486
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
470
487
  :param n: Number of completions to return for each request, input tokens are only billed once.
471
488
  :param prediction:
489
+ :param parallel_tool_calls:
472
490
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
473
491
  :param retries: Override the default retry configuration for this method
474
492
  :param server_url: Override the default server URL for this method
@@ -482,6 +500,8 @@ class Chat(BaseSDK):
482
500
 
483
501
  if server_url is not None:
484
502
  base_url = server_url
503
+ else:
504
+ base_url = self._get_url(base_url, url_variables)
485
505
 
486
506
  request = models.ChatCompletionStreamRequest(
487
507
  model=model,
@@ -507,6 +527,7 @@ class Chat(BaseSDK):
507
527
  prediction=utils.get_pydantic_model(
508
528
  prediction, Optional[models.Prediction]
509
529
  ),
530
+ parallel_tool_calls=parallel_tool_calls,
510
531
  safe_prompt=safe_prompt,
511
532
  )
512
533
 
@@ -539,6 +560,7 @@ class Chat(BaseSDK):
539
560
 
540
561
  http_res = self.do_request(
541
562
  hook_ctx=HookContext(
563
+ base_url=base_url or "",
542
564
  operation_id="stream_chat",
543
565
  oauth2_scopes=[],
544
566
  security_source=get_security_from_env(
@@ -551,7 +573,7 @@ class Chat(BaseSDK):
551
573
  retry_config=retry_config,
552
574
  )
553
575
 
554
- data: Any = None
576
+ response_data: Any = None
555
577
  if utils.match_response(http_res, "200", "text/event-stream"):
556
578
  return eventstreaming.EventStream(
557
579
  http_res,
@@ -560,8 +582,10 @@ class Chat(BaseSDK):
560
582
  )
561
583
  if utils.match_response(http_res, "422", "application/json"):
562
584
  http_res_text = utils.stream_to_text(http_res)
563
- data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
564
- raise models.HTTPValidationError(data=data)
585
+ response_data = utils.unmarshal_json(
586
+ http_res_text, models.HTTPValidationErrorData
587
+ )
588
+ raise models.HTTPValidationError(data=response_data)
565
589
  if utils.match_response(http_res, "4XX", "*"):
566
590
  http_res_text = utils.stream_to_text(http_res)
567
591
  raise models.SDKError(
@@ -619,6 +643,7 @@ class Chat(BaseSDK):
619
643
  prediction: Optional[
620
644
  Union[models.Prediction, models.PredictionTypedDict]
621
645
  ] = None,
646
+ parallel_tool_calls: Optional[bool] = None,
622
647
  safe_prompt: Optional[bool] = None,
623
648
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
624
649
  server_url: Optional[str] = None,
@@ -644,6 +669,7 @@ class Chat(BaseSDK):
644
669
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
645
670
  :param n: Number of completions to return for each request, input tokens are only billed once.
646
671
  :param prediction:
672
+ :param parallel_tool_calls:
647
673
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
648
674
  :param retries: Override the default retry configuration for this method
649
675
  :param server_url: Override the default server URL for this method
@@ -657,6 +683,8 @@ class Chat(BaseSDK):
657
683
 
658
684
  if server_url is not None:
659
685
  base_url = server_url
686
+ else:
687
+ base_url = self._get_url(base_url, url_variables)
660
688
 
661
689
  request = models.ChatCompletionStreamRequest(
662
690
  model=model,
@@ -682,6 +710,7 @@ class Chat(BaseSDK):
682
710
  prediction=utils.get_pydantic_model(
683
711
  prediction, Optional[models.Prediction]
684
712
  ),
713
+ parallel_tool_calls=parallel_tool_calls,
685
714
  safe_prompt=safe_prompt,
686
715
  )
687
716
 
@@ -714,6 +743,7 @@ class Chat(BaseSDK):
714
743
 
715
744
  http_res = await self.do_request_async(
716
745
  hook_ctx=HookContext(
746
+ base_url=base_url or "",
717
747
  operation_id="stream_chat",
718
748
  oauth2_scopes=[],
719
749
  security_source=get_security_from_env(
@@ -726,7 +756,7 @@ class Chat(BaseSDK):
726
756
  retry_config=retry_config,
727
757
  )
728
758
 
729
- data: Any = None
759
+ response_data: Any = None
730
760
  if utils.match_response(http_res, "200", "text/event-stream"):
731
761
  return eventstreaming.EventStreamAsync(
732
762
  http_res,
@@ -735,8 +765,10 @@ class Chat(BaseSDK):
735
765
  )
736
766
  if utils.match_response(http_res, "422", "application/json"):
737
767
  http_res_text = await utils.stream_to_text_async(http_res)
738
- data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
739
- raise models.HTTPValidationError(data=data)
768
+ response_data = utils.unmarshal_json(
769
+ http_res_text, models.HTTPValidationErrorData
770
+ )
771
+ raise models.HTTPValidationError(data=response_data)
740
772
  if utils.match_response(http_res, "4XX", "*"):
741
773
  http_res_text = await utils.stream_to_text_async(http_res)
742
774
  raise models.SDKError(