mistralai 1.0.3__py3-none-any.whl → 1.2.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 (230) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_hooks/sdkhooks.py +23 -4
  3. mistralai/_hooks/types.py +27 -9
  4. mistralai/_version.py +12 -0
  5. mistralai/agents.py +334 -164
  6. mistralai/basesdk.py +90 -5
  7. mistralai/batch.py +17 -0
  8. mistralai/chat.py +316 -166
  9. mistralai/classifiers.py +396 -0
  10. mistralai/embeddings.py +79 -55
  11. mistralai/files.py +487 -194
  12. mistralai/fim.py +206 -132
  13. mistralai/fine_tuning.py +3 -2
  14. mistralai/jobs.py +392 -263
  15. mistralai/mistral_jobs.py +733 -0
  16. mistralai/models/__init__.py +593 -50
  17. mistralai/models/agentscompletionrequest.py +70 -17
  18. mistralai/models/agentscompletionstreamrequest.py +72 -17
  19. mistralai/models/apiendpoint.py +9 -0
  20. mistralai/models/archiveftmodelout.py +15 -5
  21. mistralai/models/assistantmessage.py +22 -10
  22. mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
  23. mistralai/models/batcherror.py +17 -0
  24. mistralai/models/batchjobin.py +58 -0
  25. mistralai/models/batchjobout.py +117 -0
  26. mistralai/models/batchjobsout.py +30 -0
  27. mistralai/models/batchjobstatus.py +15 -0
  28. mistralai/models/chatclassificationrequest.py +104 -0
  29. mistralai/models/chatcompletionchoice.py +13 -6
  30. mistralai/models/chatcompletionrequest.py +86 -21
  31. mistralai/models/chatcompletionresponse.py +8 -4
  32. mistralai/models/chatcompletionstreamrequest.py +88 -21
  33. mistralai/models/checkpointout.py +4 -3
  34. mistralai/models/classificationobject.py +21 -0
  35. mistralai/models/classificationrequest.py +59 -0
  36. mistralai/models/classificationresponse.py +21 -0
  37. mistralai/models/completionchunk.py +12 -5
  38. mistralai/models/completionevent.py +2 -3
  39. mistralai/models/completionresponsestreamchoice.py +22 -8
  40. mistralai/models/contentchunk.py +13 -10
  41. mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
  42. mistralai/models/deletefileout.py +4 -3
  43. mistralai/models/deletemodelout.py +5 -4
  44. mistralai/models/deltamessage.py +23 -11
  45. mistralai/models/detailedjobout.py +70 -12
  46. mistralai/models/embeddingrequest.py +14 -9
  47. mistralai/models/embeddingresponse.py +7 -3
  48. mistralai/models/embeddingresponsedata.py +5 -4
  49. mistralai/models/eventout.py +11 -6
  50. mistralai/models/filepurpose.py +8 -0
  51. mistralai/models/files_api_routes_delete_fileop.py +5 -5
  52. mistralai/models/files_api_routes_download_fileop.py +16 -0
  53. mistralai/models/files_api_routes_list_filesop.py +96 -0
  54. mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
  55. mistralai/models/files_api_routes_upload_fileop.py +33 -14
  56. mistralai/models/fileschema.py +22 -15
  57. mistralai/models/fimcompletionrequest.py +44 -16
  58. mistralai/models/fimcompletionresponse.py +8 -4
  59. mistralai/models/fimcompletionstreamrequest.py +44 -16
  60. mistralai/models/finetuneablemodel.py +7 -1
  61. mistralai/models/ftmodelcapabilitiesout.py +6 -4
  62. mistralai/models/ftmodelcard.py +121 -0
  63. mistralai/models/ftmodelout.py +39 -9
  64. mistralai/models/function.py +5 -4
  65. mistralai/models/functioncall.py +4 -3
  66. mistralai/models/functionname.py +17 -0
  67. mistralai/models/githubrepositoryin.py +24 -7
  68. mistralai/models/githubrepositoryout.py +24 -7
  69. mistralai/models/httpvalidationerror.py +1 -3
  70. mistralai/models/imageurl.py +47 -0
  71. mistralai/models/imageurlchunk.py +38 -0
  72. mistralai/models/jobin.py +24 -7
  73. mistralai/models/jobmetadataout.py +32 -8
  74. mistralai/models/jobout.py +65 -12
  75. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  76. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  77. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  78. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
  79. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
  80. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
  81. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
  82. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
  83. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
  84. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
  85. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
  86. mistralai/models/jobsout.py +13 -5
  87. mistralai/models/legacyjobmetadataout.py +55 -9
  88. mistralai/models/listfilesout.py +7 -3
  89. mistralai/models/metricout.py +12 -8
  90. mistralai/models/modelcapabilities.py +9 -4
  91. mistralai/models/modellist.py +21 -7
  92. mistralai/models/responseformat.py +7 -8
  93. mistralai/models/responseformats.py +8 -0
  94. mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
  95. mistralai/models/retrievefileout.py +25 -15
  96. mistralai/models/sampletype.py +6 -2
  97. mistralai/models/security.py +14 -5
  98. mistralai/models/source.py +3 -2
  99. mistralai/models/systemmessage.py +10 -9
  100. mistralai/models/textchunk.py +14 -5
  101. mistralai/models/tool.py +10 -9
  102. mistralai/models/toolcall.py +10 -8
  103. mistralai/models/toolchoice.py +29 -0
  104. mistralai/models/toolchoiceenum.py +7 -0
  105. mistralai/models/toolmessage.py +13 -6
  106. mistralai/models/tooltypes.py +8 -0
  107. mistralai/models/trainingfile.py +4 -4
  108. mistralai/models/trainingparameters.py +34 -8
  109. mistralai/models/trainingparametersin.py +36 -10
  110. mistralai/models/unarchiveftmodelout.py +15 -5
  111. mistralai/models/updateftmodelin.py +9 -6
  112. mistralai/models/uploadfileout.py +22 -15
  113. mistralai/models/usageinfo.py +4 -3
  114. mistralai/models/usermessage.py +42 -10
  115. mistralai/models/validationerror.py +5 -3
  116. mistralai/models/wandbintegration.py +23 -7
  117. mistralai/models/wandbintegrationout.py +23 -8
  118. mistralai/models_.py +416 -294
  119. mistralai/sdk.py +31 -19
  120. mistralai/sdkconfiguration.py +9 -11
  121. mistralai/utils/__init__.py +14 -1
  122. mistralai/utils/annotations.py +13 -2
  123. mistralai/utils/logger.py +4 -1
  124. mistralai/utils/retries.py +2 -1
  125. mistralai/utils/security.py +13 -6
  126. mistralai/utils/serializers.py +25 -0
  127. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
  128. mistralai-1.2.0.dist-info/RECORD +276 -0
  129. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
  130. mistralai_azure/__init__.py +4 -0
  131. mistralai_azure/_hooks/sdkhooks.py +23 -4
  132. mistralai_azure/_hooks/types.py +27 -9
  133. mistralai_azure/_version.py +12 -0
  134. mistralai_azure/basesdk.py +91 -6
  135. mistralai_azure/chat.py +308 -166
  136. mistralai_azure/models/__init__.py +164 -16
  137. mistralai_azure/models/assistantmessage.py +29 -11
  138. mistralai_azure/models/chatcompletionchoice.py +15 -6
  139. mistralai_azure/models/chatcompletionrequest.py +94 -22
  140. mistralai_azure/models/chatcompletionresponse.py +8 -4
  141. mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
  142. mistralai_azure/models/completionchunk.py +12 -5
  143. mistralai_azure/models/completionevent.py +2 -3
  144. mistralai_azure/models/completionresponsestreamchoice.py +19 -8
  145. mistralai_azure/models/contentchunk.py +4 -11
  146. mistralai_azure/models/deltamessage.py +30 -12
  147. mistralai_azure/models/function.py +5 -4
  148. mistralai_azure/models/functioncall.py +4 -3
  149. mistralai_azure/models/functionname.py +17 -0
  150. mistralai_azure/models/httpvalidationerror.py +1 -3
  151. mistralai_azure/models/responseformat.py +7 -8
  152. mistralai_azure/models/responseformats.py +8 -0
  153. mistralai_azure/models/security.py +13 -5
  154. mistralai_azure/models/systemmessage.py +10 -9
  155. mistralai_azure/models/textchunk.py +14 -5
  156. mistralai_azure/models/tool.py +10 -9
  157. mistralai_azure/models/toolcall.py +10 -8
  158. mistralai_azure/models/toolchoice.py +29 -0
  159. mistralai_azure/models/toolchoiceenum.py +7 -0
  160. mistralai_azure/models/toolmessage.py +20 -7
  161. mistralai_azure/models/tooltypes.py +8 -0
  162. mistralai_azure/models/usageinfo.py +4 -3
  163. mistralai_azure/models/usermessage.py +42 -10
  164. mistralai_azure/models/validationerror.py +5 -3
  165. mistralai_azure/sdkconfiguration.py +9 -11
  166. mistralai_azure/utils/__init__.py +16 -3
  167. mistralai_azure/utils/annotations.py +13 -2
  168. mistralai_azure/utils/forms.py +10 -9
  169. mistralai_azure/utils/headers.py +8 -8
  170. mistralai_azure/utils/logger.py +6 -0
  171. mistralai_azure/utils/queryparams.py +16 -14
  172. mistralai_azure/utils/retries.py +2 -1
  173. mistralai_azure/utils/security.py +12 -6
  174. mistralai_azure/utils/serializers.py +42 -8
  175. mistralai_azure/utils/url.py +13 -8
  176. mistralai_azure/utils/values.py +6 -0
  177. mistralai_gcp/__init__.py +4 -0
  178. mistralai_gcp/_hooks/sdkhooks.py +23 -4
  179. mistralai_gcp/_hooks/types.py +27 -9
  180. mistralai_gcp/_version.py +12 -0
  181. mistralai_gcp/basesdk.py +91 -6
  182. mistralai_gcp/chat.py +308 -166
  183. mistralai_gcp/fim.py +198 -132
  184. mistralai_gcp/models/__init__.py +186 -18
  185. mistralai_gcp/models/assistantmessage.py +29 -11
  186. mistralai_gcp/models/chatcompletionchoice.py +15 -6
  187. mistralai_gcp/models/chatcompletionrequest.py +91 -22
  188. mistralai_gcp/models/chatcompletionresponse.py +8 -4
  189. mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
  190. mistralai_gcp/models/completionchunk.py +12 -5
  191. mistralai_gcp/models/completionevent.py +2 -3
  192. mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
  193. mistralai_gcp/models/contentchunk.py +4 -11
  194. mistralai_gcp/models/deltamessage.py +30 -12
  195. mistralai_gcp/models/fimcompletionrequest.py +51 -17
  196. mistralai_gcp/models/fimcompletionresponse.py +8 -4
  197. mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
  198. mistralai_gcp/models/function.py +5 -4
  199. mistralai_gcp/models/functioncall.py +4 -3
  200. mistralai_gcp/models/functionname.py +17 -0
  201. mistralai_gcp/models/httpvalidationerror.py +1 -3
  202. mistralai_gcp/models/responseformat.py +7 -8
  203. mistralai_gcp/models/responseformats.py +8 -0
  204. mistralai_gcp/models/security.py +13 -5
  205. mistralai_gcp/models/systemmessage.py +10 -9
  206. mistralai_gcp/models/textchunk.py +14 -5
  207. mistralai_gcp/models/tool.py +10 -9
  208. mistralai_gcp/models/toolcall.py +10 -8
  209. mistralai_gcp/models/toolchoice.py +29 -0
  210. mistralai_gcp/models/toolchoiceenum.py +7 -0
  211. mistralai_gcp/models/toolmessage.py +20 -7
  212. mistralai_gcp/models/tooltypes.py +8 -0
  213. mistralai_gcp/models/usageinfo.py +4 -3
  214. mistralai_gcp/models/usermessage.py +42 -10
  215. mistralai_gcp/models/validationerror.py +5 -3
  216. mistralai_gcp/sdk.py +6 -7
  217. mistralai_gcp/sdkconfiguration.py +9 -11
  218. mistralai_gcp/utils/__init__.py +16 -3
  219. mistralai_gcp/utils/annotations.py +13 -2
  220. mistralai_gcp/utils/forms.py +10 -9
  221. mistralai_gcp/utils/headers.py +8 -8
  222. mistralai_gcp/utils/logger.py +6 -0
  223. mistralai_gcp/utils/queryparams.py +16 -14
  224. mistralai_gcp/utils/retries.py +2 -1
  225. mistralai_gcp/utils/security.py +12 -6
  226. mistralai_gcp/utils/serializers.py +42 -8
  227. mistralai_gcp/utils/url.py +13 -8
  228. mistralai_gcp/utils/values.py +6 -0
  229. mistralai-1.0.3.dist-info/RECORD +0 -236
  230. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
mistralai/agents.py CHANGED
@@ -7,22 +7,42 @@ from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
8
  from typing import Any, AsyncGenerator, Generator, List, Optional, Union
9
9
 
10
+
10
11
  class Agents(BaseSDK):
11
12
  r"""Agents API."""
12
-
13
-
13
+
14
14
  def complete(
15
- self, *,
16
- messages: Union[List[models.AgentsCompletionRequestMessages], List[models.AgentsCompletionRequestMessagesTypedDict]],
15
+ self,
16
+ *,
17
+ messages: Union[
18
+ List[models.AgentsCompletionRequestMessages],
19
+ List[models.AgentsCompletionRequestMessagesTypedDict],
20
+ ],
17
21
  agent_id: str,
18
22
  max_tokens: OptionalNullable[int] = UNSET,
19
- min_tokens: OptionalNullable[int] = UNSET,
20
23
  stream: Optional[bool] = False,
21
- stop: Optional[Union[models.AgentsCompletionRequestStop, models.AgentsCompletionRequestStopTypedDict]] = None,
24
+ stop: Optional[
25
+ Union[
26
+ models.AgentsCompletionRequestStop,
27
+ models.AgentsCompletionRequestStopTypedDict,
28
+ ]
29
+ ] = None,
22
30
  random_seed: OptionalNullable[int] = UNSET,
23
- response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
24
- tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
25
- tool_choice: Optional[models.AgentsCompletionRequestToolChoice] = "auto",
31
+ response_format: Optional[
32
+ Union[models.ResponseFormat, models.ResponseFormatTypedDict]
33
+ ] = None,
34
+ tools: OptionalNullable[
35
+ Union[List[models.Tool], List[models.ToolTypedDict]]
36
+ ] = UNSET,
37
+ tool_choice: Optional[
38
+ Union[
39
+ models.AgentsCompletionRequestToolChoice,
40
+ models.AgentsCompletionRequestToolChoiceTypedDict,
41
+ ]
42
+ ] = None,
43
+ presence_penalty: Optional[float] = 0,
44
+ frequency_penalty: Optional[float] = 0,
45
+ n: OptionalNullable[int] = UNSET,
26
46
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
27
47
  server_url: Optional[str] = None,
28
48
  timeout_ms: Optional[int] = None,
@@ -32,13 +52,15 @@ class Agents(BaseSDK):
32
52
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
33
53
  :param agent_id: The ID of the agent to use for this completion.
34
54
  :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
35
- :param min_tokens: The minimum number of tokens to generate in the completion.
36
55
  :param stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-side 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.
37
56
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
38
57
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
39
- :param response_format:
40
- :param tools:
41
- :param tool_choice:
58
+ :param response_format:
59
+ :param tools:
60
+ :param tool_choice:
61
+ :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
62
+ :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.
63
+ :param n: Number of completions to return for each request, input tokens are only billed once.
42
64
  :param retries: Override the default retry configuration for this method
43
65
  :param server_url: Override the default server URL for this method
44
66
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -47,23 +69,31 @@ class Agents(BaseSDK):
47
69
  url_variables = None
48
70
  if timeout_ms is None:
49
71
  timeout_ms = self.sdk_configuration.timeout_ms
50
-
72
+
51
73
  if server_url is not None:
52
74
  base_url = server_url
53
-
75
+
54
76
  request = models.AgentsCompletionRequest(
55
77
  max_tokens=max_tokens,
56
- min_tokens=min_tokens,
57
78
  stream=stream,
58
79
  stop=stop,
59
80
  random_seed=random_seed,
60
- messages=utils.get_pydantic_model(messages, List[models.AgentsCompletionRequestMessages]),
61
- response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
81
+ messages=utils.get_pydantic_model(
82
+ messages, List[models.AgentsCompletionRequestMessages]
83
+ ),
84
+ response_format=utils.get_pydantic_model(
85
+ response_format, Optional[models.ResponseFormat]
86
+ ),
62
87
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
63
- tool_choice=tool_choice,
88
+ tool_choice=utils.get_pydantic_model(
89
+ tool_choice, Optional[models.AgentsCompletionRequestToolChoice]
90
+ ),
91
+ presence_penalty=presence_penalty,
92
+ frequency_penalty=frequency_penalty,
93
+ n=n,
64
94
  agent_id=agent_id,
65
95
  )
66
-
96
+
67
97
  req = self.build_request(
68
98
  method="POST",
69
99
  path="/v1/agents/completions",
@@ -76,57 +106,88 @@ class Agents(BaseSDK):
76
106
  user_agent_header="user-agent",
77
107
  accept_header_value="application/json",
78
108
  security=self.sdk_configuration.security,
79
- get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.AgentsCompletionRequest),
109
+ get_serialized_body=lambda: utils.serialize_request_body(
110
+ request, False, False, "json", models.AgentsCompletionRequest
111
+ ),
80
112
  timeout_ms=timeout_ms,
81
113
  )
82
-
114
+
83
115
  if retries == UNSET:
84
116
  if self.sdk_configuration.retry_config is not UNSET:
85
117
  retries = self.sdk_configuration.retry_config
86
118
 
87
119
  retry_config = None
88
120
  if isinstance(retries, utils.RetryConfig):
89
- retry_config = (retries, [
90
- "429",
91
- "500",
92
- "502",
93
- "503",
94
- "504"
95
- ])
96
-
121
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
122
+
97
123
  http_res = self.do_request(
98
- hook_ctx=HookContext(operation_id="agents_completion_v1_agents_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
124
+ hook_ctx=HookContext(
125
+ operation_id="agents_completion_v1_agents_completions_post",
126
+ oauth2_scopes=[],
127
+ security_source=get_security_from_env(
128
+ self.sdk_configuration.security, models.Security
129
+ ),
130
+ ),
99
131
  request=req,
100
- error_status_codes=["422","4XX","5XX"],
101
- retry_config=retry_config
132
+ error_status_codes=["422", "4XX", "5XX"],
133
+ retry_config=retry_config,
102
134
  )
103
-
135
+
104
136
  data: Any = None
105
137
  if utils.match_response(http_res, "200", "application/json"):
106
- return utils.unmarshal_json(http_res.text, Optional[models.ChatCompletionResponse])
138
+ return utils.unmarshal_json(
139
+ http_res.text, Optional[models.ChatCompletionResponse]
140
+ )
107
141
  if utils.match_response(http_res, "422", "application/json"):
108
142
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
109
143
  raise models.HTTPValidationError(data=data)
110
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
111
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
112
-
144
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
145
+ http_res_text = utils.stream_to_text(http_res)
146
+ raise models.SDKError(
147
+ "API error occurred", http_res.status_code, http_res_text, http_res
148
+ )
149
+
113
150
  content_type = http_res.headers.get("Content-Type")
114
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
151
+ http_res_text = utils.stream_to_text(http_res)
152
+ raise models.SDKError(
153
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
154
+ http_res.status_code,
155
+ http_res_text,
156
+ http_res,
157
+ )
115
158
 
116
-
117
-
118
159
  async def complete_async(
119
- self, *,
120
- messages: Union[List[models.AgentsCompletionRequestMessages], List[models.AgentsCompletionRequestMessagesTypedDict]],
160
+ self,
161
+ *,
162
+ messages: Union[
163
+ List[models.AgentsCompletionRequestMessages],
164
+ List[models.AgentsCompletionRequestMessagesTypedDict],
165
+ ],
121
166
  agent_id: str,
122
167
  max_tokens: OptionalNullable[int] = UNSET,
123
- min_tokens: OptionalNullable[int] = UNSET,
124
168
  stream: Optional[bool] = False,
125
- stop: Optional[Union[models.AgentsCompletionRequestStop, models.AgentsCompletionRequestStopTypedDict]] = None,
169
+ stop: Optional[
170
+ Union[
171
+ models.AgentsCompletionRequestStop,
172
+ models.AgentsCompletionRequestStopTypedDict,
173
+ ]
174
+ ] = None,
126
175
  random_seed: OptionalNullable[int] = UNSET,
127
- response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
128
- tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
129
- tool_choice: Optional[models.AgentsCompletionRequestToolChoice] = "auto",
176
+ response_format: Optional[
177
+ Union[models.ResponseFormat, models.ResponseFormatTypedDict]
178
+ ] = None,
179
+ tools: OptionalNullable[
180
+ Union[List[models.Tool], List[models.ToolTypedDict]]
181
+ ] = UNSET,
182
+ tool_choice: Optional[
183
+ Union[
184
+ models.AgentsCompletionRequestToolChoice,
185
+ models.AgentsCompletionRequestToolChoiceTypedDict,
186
+ ]
187
+ ] = None,
188
+ presence_penalty: Optional[float] = 0,
189
+ frequency_penalty: Optional[float] = 0,
190
+ n: OptionalNullable[int] = UNSET,
130
191
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
131
192
  server_url: Optional[str] = None,
132
193
  timeout_ms: Optional[int] = None,
@@ -136,13 +197,15 @@ class Agents(BaseSDK):
136
197
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
137
198
  :param agent_id: The ID of the agent to use for this completion.
138
199
  :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
139
- :param min_tokens: The minimum number of tokens to generate in the completion.
140
200
  :param stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-side 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.
141
201
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
142
202
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
143
- :param response_format:
144
- :param tools:
145
- :param tool_choice:
203
+ :param response_format:
204
+ :param tools:
205
+ :param tool_choice:
206
+ :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
207
+ :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.
208
+ :param n: Number of completions to return for each request, input tokens are only billed once.
146
209
  :param retries: Override the default retry configuration for this method
147
210
  :param server_url: Override the default server URL for this method
148
211
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -151,24 +214,32 @@ class Agents(BaseSDK):
151
214
  url_variables = None
152
215
  if timeout_ms is None:
153
216
  timeout_ms = self.sdk_configuration.timeout_ms
154
-
217
+
155
218
  if server_url is not None:
156
219
  base_url = server_url
157
-
220
+
158
221
  request = models.AgentsCompletionRequest(
159
222
  max_tokens=max_tokens,
160
- min_tokens=min_tokens,
161
223
  stream=stream,
162
224
  stop=stop,
163
225
  random_seed=random_seed,
164
- messages=utils.get_pydantic_model(messages, List[models.AgentsCompletionRequestMessages]),
165
- response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
226
+ messages=utils.get_pydantic_model(
227
+ messages, List[models.AgentsCompletionRequestMessages]
228
+ ),
229
+ response_format=utils.get_pydantic_model(
230
+ response_format, Optional[models.ResponseFormat]
231
+ ),
166
232
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
167
- tool_choice=tool_choice,
233
+ tool_choice=utils.get_pydantic_model(
234
+ tool_choice, Optional[models.AgentsCompletionRequestToolChoice]
235
+ ),
236
+ presence_penalty=presence_penalty,
237
+ frequency_penalty=frequency_penalty,
238
+ n=n,
168
239
  agent_id=agent_id,
169
240
  )
170
-
171
- req = self.build_request(
241
+
242
+ req = self.build_request_async(
172
243
  method="POST",
173
244
  path="/v1/agents/completions",
174
245
  base_url=base_url,
@@ -180,57 +251,88 @@ class Agents(BaseSDK):
180
251
  user_agent_header="user-agent",
181
252
  accept_header_value="application/json",
182
253
  security=self.sdk_configuration.security,
183
- get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.AgentsCompletionRequest),
254
+ get_serialized_body=lambda: utils.serialize_request_body(
255
+ request, False, False, "json", models.AgentsCompletionRequest
256
+ ),
184
257
  timeout_ms=timeout_ms,
185
258
  )
186
-
259
+
187
260
  if retries == UNSET:
188
261
  if self.sdk_configuration.retry_config is not UNSET:
189
262
  retries = self.sdk_configuration.retry_config
190
263
 
191
264
  retry_config = None
192
265
  if isinstance(retries, utils.RetryConfig):
193
- retry_config = (retries, [
194
- "429",
195
- "500",
196
- "502",
197
- "503",
198
- "504"
199
- ])
200
-
266
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
267
+
201
268
  http_res = await self.do_request_async(
202
- hook_ctx=HookContext(operation_id="agents_completion_v1_agents_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
269
+ hook_ctx=HookContext(
270
+ operation_id="agents_completion_v1_agents_completions_post",
271
+ oauth2_scopes=[],
272
+ security_source=get_security_from_env(
273
+ self.sdk_configuration.security, models.Security
274
+ ),
275
+ ),
203
276
  request=req,
204
- error_status_codes=["422","4XX","5XX"],
205
- retry_config=retry_config
277
+ error_status_codes=["422", "4XX", "5XX"],
278
+ retry_config=retry_config,
206
279
  )
207
-
280
+
208
281
  data: Any = None
209
282
  if utils.match_response(http_res, "200", "application/json"):
210
- return utils.unmarshal_json(http_res.text, Optional[models.ChatCompletionResponse])
283
+ return utils.unmarshal_json(
284
+ http_res.text, Optional[models.ChatCompletionResponse]
285
+ )
211
286
  if utils.match_response(http_res, "422", "application/json"):
212
287
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
213
288
  raise models.HTTPValidationError(data=data)
214
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
215
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
216
-
289
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
290
+ http_res_text = await utils.stream_to_text_async(http_res)
291
+ raise models.SDKError(
292
+ "API error occurred", http_res.status_code, http_res_text, http_res
293
+ )
294
+
217
295
  content_type = http_res.headers.get("Content-Type")
218
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
296
+ http_res_text = await utils.stream_to_text_async(http_res)
297
+ raise models.SDKError(
298
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
299
+ http_res.status_code,
300
+ http_res_text,
301
+ http_res,
302
+ )
219
303
 
220
-
221
-
222
304
  def stream(
223
- self, *,
224
- messages: Union[List[models.AgentsCompletionStreamRequestMessages], List[models.AgentsCompletionStreamRequestMessagesTypedDict]],
305
+ self,
306
+ *,
307
+ messages: Union[
308
+ List[models.AgentsCompletionStreamRequestMessages],
309
+ List[models.AgentsCompletionStreamRequestMessagesTypedDict],
310
+ ],
225
311
  agent_id: str,
226
312
  max_tokens: OptionalNullable[int] = UNSET,
227
- min_tokens: OptionalNullable[int] = UNSET,
228
313
  stream: Optional[bool] = True,
229
- stop: Optional[Union[models.AgentsCompletionStreamRequestStop, models.AgentsCompletionStreamRequestStopTypedDict]] = None,
314
+ stop: Optional[
315
+ Union[
316
+ models.AgentsCompletionStreamRequestStop,
317
+ models.AgentsCompletionStreamRequestStopTypedDict,
318
+ ]
319
+ ] = None,
230
320
  random_seed: OptionalNullable[int] = UNSET,
231
- response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
232
- tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
233
- tool_choice: Optional[models.AgentsCompletionStreamRequestToolChoice] = "auto",
321
+ response_format: Optional[
322
+ Union[models.ResponseFormat, models.ResponseFormatTypedDict]
323
+ ] = None,
324
+ tools: OptionalNullable[
325
+ Union[List[models.Tool], List[models.ToolTypedDict]]
326
+ ] = UNSET,
327
+ tool_choice: Optional[
328
+ Union[
329
+ models.AgentsCompletionStreamRequestToolChoice,
330
+ models.AgentsCompletionStreamRequestToolChoiceTypedDict,
331
+ ]
332
+ ] = None,
333
+ presence_penalty: Optional[float] = 0,
334
+ frequency_penalty: Optional[float] = 0,
335
+ n: OptionalNullable[int] = UNSET,
234
336
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
235
337
  server_url: Optional[str] = None,
236
338
  timeout_ms: Optional[int] = None,
@@ -242,13 +344,15 @@ class Agents(BaseSDK):
242
344
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
243
345
  :param agent_id: The ID of the agent to use for this completion.
244
346
  :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
245
- :param min_tokens: The minimum number of tokens to generate in the completion.
246
- :param stream:
347
+ :param stream:
247
348
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
248
349
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
249
- :param response_format:
250
- :param tools:
251
- :param tool_choice:
350
+ :param response_format:
351
+ :param tools:
352
+ :param tool_choice:
353
+ :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
354
+ :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.
355
+ :param n: Number of completions to return for each request, input tokens are only billed once.
252
356
  :param retries: Override the default retry configuration for this method
253
357
  :param server_url: Override the default server URL for this method
254
358
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -257,23 +361,31 @@ class Agents(BaseSDK):
257
361
  url_variables = None
258
362
  if timeout_ms is None:
259
363
  timeout_ms = self.sdk_configuration.timeout_ms
260
-
364
+
261
365
  if server_url is not None:
262
366
  base_url = server_url
263
-
367
+
264
368
  request = models.AgentsCompletionStreamRequest(
265
369
  max_tokens=max_tokens,
266
- min_tokens=min_tokens,
267
370
  stream=stream,
268
371
  stop=stop,
269
372
  random_seed=random_seed,
270
- messages=utils.get_pydantic_model(messages, List[models.AgentsCompletionStreamRequestMessages]),
271
- response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
373
+ messages=utils.get_pydantic_model(
374
+ messages, List[models.AgentsCompletionStreamRequestMessages]
375
+ ),
376
+ response_format=utils.get_pydantic_model(
377
+ response_format, Optional[models.ResponseFormat]
378
+ ),
272
379
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
273
- tool_choice=tool_choice,
380
+ tool_choice=utils.get_pydantic_model(
381
+ tool_choice, Optional[models.AgentsCompletionStreamRequestToolChoice]
382
+ ),
383
+ presence_penalty=presence_penalty,
384
+ frequency_penalty=frequency_penalty,
385
+ n=n,
274
386
  agent_id=agent_id,
275
387
  )
276
-
388
+
277
389
  req = self.build_request(
278
390
  method="POST",
279
391
  path="/v1/agents/completions#stream",
@@ -286,58 +398,92 @@ class Agents(BaseSDK):
286
398
  user_agent_header="user-agent",
287
399
  accept_header_value="text/event-stream",
288
400
  security=self.sdk_configuration.security,
289
- get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.AgentsCompletionStreamRequest),
401
+ get_serialized_body=lambda: utils.serialize_request_body(
402
+ request, False, False, "json", models.AgentsCompletionStreamRequest
403
+ ),
290
404
  timeout_ms=timeout_ms,
291
405
  )
292
-
406
+
293
407
  if retries == UNSET:
294
408
  if self.sdk_configuration.retry_config is not UNSET:
295
409
  retries = self.sdk_configuration.retry_config
296
410
 
297
411
  retry_config = None
298
412
  if isinstance(retries, utils.RetryConfig):
299
- retry_config = (retries, [
300
- "429",
301
- "500",
302
- "502",
303
- "503",
304
- "504"
305
- ])
306
-
413
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
414
+
307
415
  http_res = self.do_request(
308
- hook_ctx=HookContext(operation_id="stream_agents", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
416
+ hook_ctx=HookContext(
417
+ operation_id="stream_agents",
418
+ oauth2_scopes=[],
419
+ security_source=get_security_from_env(
420
+ self.sdk_configuration.security, models.Security
421
+ ),
422
+ ),
309
423
  request=req,
310
- error_status_codes=["422","4XX","5XX"],
424
+ error_status_codes=["422", "4XX", "5XX"],
311
425
  stream=True,
312
- retry_config=retry_config
426
+ retry_config=retry_config,
313
427
  )
314
-
428
+
315
429
  data: Any = None
316
430
  if utils.match_response(http_res, "200", "text/event-stream"):
317
- return eventstreaming.stream_events(http_res, lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), sentinel="[DONE]")
431
+ return eventstreaming.stream_events(
432
+ http_res,
433
+ lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
434
+ sentinel="[DONE]",
435
+ )
318
436
  if utils.match_response(http_res, "422", "application/json"):
319
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
437
+ http_res_text = utils.stream_to_text(http_res)
438
+ data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
320
439
  raise models.HTTPValidationError(data=data)
321
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
322
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
323
-
440
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
441
+ http_res_text = utils.stream_to_text(http_res)
442
+ raise models.SDKError(
443
+ "API error occurred", http_res.status_code, http_res_text, http_res
444
+ )
445
+
324
446
  content_type = http_res.headers.get("Content-Type")
325
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
447
+ http_res_text = utils.stream_to_text(http_res)
448
+ raise models.SDKError(
449
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
450
+ http_res.status_code,
451
+ http_res_text,
452
+ http_res,
453
+ )
326
454
 
327
-
328
-
329
455
  async def stream_async(
330
- self, *,
331
- messages: Union[List[models.AgentsCompletionStreamRequestMessages], List[models.AgentsCompletionStreamRequestMessagesTypedDict]],
456
+ self,
457
+ *,
458
+ messages: Union[
459
+ List[models.AgentsCompletionStreamRequestMessages],
460
+ List[models.AgentsCompletionStreamRequestMessagesTypedDict],
461
+ ],
332
462
  agent_id: str,
333
463
  max_tokens: OptionalNullable[int] = UNSET,
334
- min_tokens: OptionalNullable[int] = UNSET,
335
464
  stream: Optional[bool] = True,
336
- stop: Optional[Union[models.AgentsCompletionStreamRequestStop, models.AgentsCompletionStreamRequestStopTypedDict]] = None,
465
+ stop: Optional[
466
+ Union[
467
+ models.AgentsCompletionStreamRequestStop,
468
+ models.AgentsCompletionStreamRequestStopTypedDict,
469
+ ]
470
+ ] = None,
337
471
  random_seed: OptionalNullable[int] = UNSET,
338
- response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
339
- tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
340
- tool_choice: Optional[models.AgentsCompletionStreamRequestToolChoice] = "auto",
472
+ response_format: Optional[
473
+ Union[models.ResponseFormat, models.ResponseFormatTypedDict]
474
+ ] = None,
475
+ tools: OptionalNullable[
476
+ Union[List[models.Tool], List[models.ToolTypedDict]]
477
+ ] = UNSET,
478
+ tool_choice: Optional[
479
+ Union[
480
+ models.AgentsCompletionStreamRequestToolChoice,
481
+ models.AgentsCompletionStreamRequestToolChoiceTypedDict,
482
+ ]
483
+ ] = None,
484
+ presence_penalty: Optional[float] = 0,
485
+ frequency_penalty: Optional[float] = 0,
486
+ n: OptionalNullable[int] = UNSET,
341
487
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
342
488
  server_url: Optional[str] = None,
343
489
  timeout_ms: Optional[int] = None,
@@ -349,13 +495,15 @@ class Agents(BaseSDK):
349
495
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
350
496
  :param agent_id: The ID of the agent to use for this completion.
351
497
  :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
352
- :param min_tokens: The minimum number of tokens to generate in the completion.
353
- :param stream:
498
+ :param stream:
354
499
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
355
500
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
356
- :param response_format:
357
- :param tools:
358
- :param tool_choice:
501
+ :param response_format:
502
+ :param tools:
503
+ :param tool_choice:
504
+ :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
505
+ :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.
506
+ :param n: Number of completions to return for each request, input tokens are only billed once.
359
507
  :param retries: Override the default retry configuration for this method
360
508
  :param server_url: Override the default server URL for this method
361
509
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -364,24 +512,32 @@ class Agents(BaseSDK):
364
512
  url_variables = None
365
513
  if timeout_ms is None:
366
514
  timeout_ms = self.sdk_configuration.timeout_ms
367
-
515
+
368
516
  if server_url is not None:
369
517
  base_url = server_url
370
-
518
+
371
519
  request = models.AgentsCompletionStreamRequest(
372
520
  max_tokens=max_tokens,
373
- min_tokens=min_tokens,
374
521
  stream=stream,
375
522
  stop=stop,
376
523
  random_seed=random_seed,
377
- messages=utils.get_pydantic_model(messages, List[models.AgentsCompletionStreamRequestMessages]),
378
- response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
524
+ messages=utils.get_pydantic_model(
525
+ messages, List[models.AgentsCompletionStreamRequestMessages]
526
+ ),
527
+ response_format=utils.get_pydantic_model(
528
+ response_format, Optional[models.ResponseFormat]
529
+ ),
379
530
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
380
- tool_choice=tool_choice,
531
+ tool_choice=utils.get_pydantic_model(
532
+ tool_choice, Optional[models.AgentsCompletionStreamRequestToolChoice]
533
+ ),
534
+ presence_penalty=presence_penalty,
535
+ frequency_penalty=frequency_penalty,
536
+ n=n,
381
537
  agent_id=agent_id,
382
538
  )
383
-
384
- req = self.build_request(
539
+
540
+ req = self.build_request_async(
385
541
  method="POST",
386
542
  path="/v1/agents/completions#stream",
387
543
  base_url=base_url,
@@ -393,42 +549,56 @@ class Agents(BaseSDK):
393
549
  user_agent_header="user-agent",
394
550
  accept_header_value="text/event-stream",
395
551
  security=self.sdk_configuration.security,
396
- get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.AgentsCompletionStreamRequest),
552
+ get_serialized_body=lambda: utils.serialize_request_body(
553
+ request, False, False, "json", models.AgentsCompletionStreamRequest
554
+ ),
397
555
  timeout_ms=timeout_ms,
398
556
  )
399
-
557
+
400
558
  if retries == UNSET:
401
559
  if self.sdk_configuration.retry_config is not UNSET:
402
560
  retries = self.sdk_configuration.retry_config
403
561
 
404
562
  retry_config = None
405
563
  if isinstance(retries, utils.RetryConfig):
406
- retry_config = (retries, [
407
- "429",
408
- "500",
409
- "502",
410
- "503",
411
- "504"
412
- ])
413
-
564
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
565
+
414
566
  http_res = await self.do_request_async(
415
- hook_ctx=HookContext(operation_id="stream_agents", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
567
+ hook_ctx=HookContext(
568
+ operation_id="stream_agents",
569
+ oauth2_scopes=[],
570
+ security_source=get_security_from_env(
571
+ self.sdk_configuration.security, models.Security
572
+ ),
573
+ ),
416
574
  request=req,
417
- error_status_codes=["422","4XX","5XX"],
575
+ error_status_codes=["422", "4XX", "5XX"],
418
576
  stream=True,
419
- retry_config=retry_config
577
+ retry_config=retry_config,
420
578
  )
421
-
579
+
422
580
  data: Any = None
423
581
  if utils.match_response(http_res, "200", "text/event-stream"):
424
- return eventstreaming.stream_events_async(http_res, lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), sentinel="[DONE]")
582
+ return eventstreaming.stream_events_async(
583
+ http_res,
584
+ lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
585
+ sentinel="[DONE]",
586
+ )
425
587
  if utils.match_response(http_res, "422", "application/json"):
426
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
588
+ http_res_text = await utils.stream_to_text_async(http_res)
589
+ data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
427
590
  raise models.HTTPValidationError(data=data)
428
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
429
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
430
-
431
- content_type = http_res.headers.get("Content-Type")
432
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
591
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
592
+ http_res_text = await utils.stream_to_text_async(http_res)
593
+ raise models.SDKError(
594
+ "API error occurred", http_res.status_code, http_res_text, http_res
595
+ )
433
596
 
434
-
597
+ content_type = http_res.headers.get("Content-Type")
598
+ http_res_text = await utils.stream_to_text_async(http_res)
599
+ raise models.SDKError(
600
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
601
+ http_res.status_code,
602
+ http_res_text,
603
+ http_res,
604
+ )