mistralai 1.0.2__py3-none-any.whl → 1.1.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.
- mistralai/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/agents.py +286 -150
- mistralai/basesdk.py +90 -5
- mistralai/chat.py +260 -144
- mistralai/embeddings.py +73 -53
- mistralai/files.py +252 -192
- mistralai/fim.py +174 -110
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +372 -263
- mistralai/models/__init__.py +499 -46
- mistralai/models/agentscompletionrequest.py +47 -11
- mistralai/models/agentscompletionstreamrequest.py +49 -11
- mistralai/models/archiveftmodelout.py +6 -2
- mistralai/models/assistantmessage.py +11 -4
- mistralai/models/{modelcard.py → basemodelcard.py} +37 -14
- mistralai/models/chatcompletionchoice.py +4 -2
- mistralai/models/chatcompletionrequest.py +57 -11
- mistralai/models/chatcompletionresponse.py +6 -2
- mistralai/models/chatcompletionstreamrequest.py +59 -11
- mistralai/models/checkpointout.py +3 -2
- mistralai/models/completionchunk.py +10 -3
- mistralai/models/completionevent.py +1 -2
- mistralai/models/completionresponsestreamchoice.py +13 -5
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +4 -3
- mistralai/models/deletefileout.py +3 -2
- mistralai/models/deletemodelout.py +3 -2
- mistralai/models/deltamessage.py +9 -4
- mistralai/models/detailedjobout.py +59 -7
- mistralai/models/embeddingrequest.py +9 -4
- mistralai/models/embeddingresponse.py +5 -2
- mistralai/models/embeddingresponsedata.py +3 -2
- mistralai/models/eventout.py +9 -4
- mistralai/models/files_api_routes_delete_fileop.py +4 -3
- mistralai/models/files_api_routes_retrieve_fileop.py +4 -3
- mistralai/models/files_api_routes_upload_fileop.py +27 -8
- mistralai/models/fileschema.py +26 -5
- mistralai/models/fimcompletionrequest.py +26 -5
- mistralai/models/fimcompletionresponse.py +6 -2
- mistralai/models/fimcompletionstreamrequest.py +26 -5
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +4 -2
- mistralai/models/ftmodelcard.py +103 -0
- mistralai/models/ftmodelout.py +32 -6
- mistralai/models/function.py +3 -2
- mistralai/models/functioncall.py +2 -2
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +15 -4
- mistralai/models/githubrepositoryout.py +15 -4
- mistralai/models/httpvalidationerror.py +2 -2
- mistralai/models/imageurl.py +48 -0
- mistralai/models/imageurlchunk.py +32 -0
- mistralai/models/jobin.py +22 -5
- mistralai/models/jobmetadataout.py +31 -6
- mistralai/models/jobout.py +55 -7
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +83 -16
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +9 -4
- mistralai/models/jobsout.py +6 -2
- mistralai/models/legacyjobmetadataout.py +45 -6
- mistralai/models/listfilesout.py +2 -2
- mistralai/models/metricout.py +11 -6
- mistralai/models/modelcapabilities.py +7 -2
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +6 -7
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +24 -5
- mistralai/models/retrievefileout.py +26 -5
- mistralai/models/security.py +12 -3
- mistralai/models/systemmessage.py +6 -5
- mistralai/models/textchunk.py +9 -4
- mistralai/models/tool.py +9 -8
- mistralai/models/toolcall.py +9 -7
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +11 -4
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +2 -2
- mistralai/models/trainingparameters.py +27 -6
- mistralai/models/trainingparametersin.py +29 -8
- mistralai/models/unarchiveftmodelout.py +6 -2
- mistralai/models/updateftmodelin.py +8 -4
- mistralai/models/uploadfileout.py +26 -5
- mistralai/models/usageinfo.py +3 -2
- mistralai/models/usermessage.py +6 -5
- mistralai/models/validationerror.py +3 -2
- mistralai/models/wandbintegration.py +14 -4
- mistralai/models/wandbintegrationout.py +13 -4
- mistralai/models_.py +392 -294
- mistralai/sdk.py +24 -19
- mistralai/sdkconfiguration.py +6 -8
- mistralai/utils/__init__.py +6 -1
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/METADATA +103 -74
- mistralai-1.1.0.dist-info/RECORD +254 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +252 -144
- mistralai_azure/models/__init__.py +157 -15
- mistralai_azure/models/assistantmessage.py +18 -5
- mistralai_azure/models/chatcompletionchoice.py +7 -3
- mistralai_azure/models/chatcompletionrequest.py +65 -12
- mistralai_azure/models/chatcompletionresponse.py +6 -2
- mistralai_azure/models/chatcompletionstreamrequest.py +67 -12
- mistralai_azure/models/completionchunk.py +10 -3
- mistralai_azure/models/completionevent.py +1 -2
- mistralai_azure/models/completionresponsestreamchoice.py +10 -4
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +16 -5
- mistralai_azure/models/function.py +3 -2
- mistralai_azure/models/functioncall.py +2 -2
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +2 -2
- mistralai_azure/models/responseformat.py +6 -7
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +12 -3
- mistralai_azure/models/systemmessage.py +6 -5
- mistralai_azure/models/textchunk.py +9 -4
- mistralai_azure/models/tool.py +9 -8
- mistralai_azure/models/toolcall.py +9 -7
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +18 -5
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +3 -2
- mistralai_azure/models/usermessage.py +6 -5
- mistralai_azure/models/validationerror.py +3 -2
- mistralai_azure/sdkconfiguration.py +6 -8
- mistralai_azure/utils/__init__.py +8 -3
- mistralai_azure/utils/forms.py +10 -9
- mistralai_azure/utils/headers.py +8 -8
- mistralai_azure/utils/logger.py +6 -0
- mistralai_azure/utils/queryparams.py +16 -14
- mistralai_azure/utils/retries.py +2 -1
- mistralai_azure/utils/security.py +12 -6
- mistralai_azure/utils/serializers.py +17 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +252 -144
- mistralai_gcp/fim.py +166 -110
- mistralai_gcp/models/__init__.py +179 -17
- mistralai_gcp/models/assistantmessage.py +18 -5
- mistralai_gcp/models/chatcompletionchoice.py +7 -3
- mistralai_gcp/models/chatcompletionrequest.py +62 -12
- mistralai_gcp/models/chatcompletionresponse.py +6 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +64 -12
- mistralai_gcp/models/completionchunk.py +10 -3
- mistralai_gcp/models/completionevent.py +1 -2
- mistralai_gcp/models/completionresponsestreamchoice.py +10 -4
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +16 -5
- mistralai_gcp/models/fimcompletionrequest.py +33 -6
- mistralai_gcp/models/fimcompletionresponse.py +6 -2
- mistralai_gcp/models/fimcompletionstreamrequest.py +33 -6
- mistralai_gcp/models/function.py +3 -2
- mistralai_gcp/models/functioncall.py +2 -2
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +2 -2
- mistralai_gcp/models/responseformat.py +6 -7
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +12 -3
- mistralai_gcp/models/systemmessage.py +6 -5
- mistralai_gcp/models/textchunk.py +9 -4
- mistralai_gcp/models/tool.py +9 -8
- mistralai_gcp/models/toolcall.py +9 -7
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +18 -5
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +3 -2
- mistralai_gcp/models/usermessage.py +6 -5
- mistralai_gcp/models/validationerror.py +3 -2
- mistralai_gcp/sdk.py +14 -10
- mistralai_gcp/sdkconfiguration.py +6 -8
- mistralai_gcp/utils/__init__.py +8 -3
- mistralai_gcp/utils/forms.py +10 -9
- mistralai_gcp/utils/headers.py +8 -8
- mistralai_gcp/utils/logger.py +6 -0
- mistralai_gcp/utils/queryparams.py +16 -14
- mistralai_gcp/utils/retries.py +2 -1
- mistralai_gcp/utils/security.py +12 -6
- mistralai_gcp/utils/serializers.py +17 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.2.dist-info/RECORD +0 -236
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/LICENSE +0 -0
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/WHEEL +0 -0
mistralai_gcp/fim.py
CHANGED
|
@@ -7,12 +7,13 @@ from mistralai_gcp.types import Nullable, OptionalNullable, UNSET
|
|
|
7
7
|
from mistralai_gcp.utils import eventstreaming
|
|
8
8
|
from typing import Any, AsyncGenerator, Generator, Optional, Union
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
class Fim(BaseSDK):
|
|
11
12
|
r"""Fill-in-the-middle API."""
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def stream(
|
|
15
|
-
self,
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
16
17
|
model: Nullable[str],
|
|
17
18
|
prompt: str,
|
|
18
19
|
temperature: Optional[float] = 0.7,
|
|
@@ -20,7 +21,12 @@ class Fim(BaseSDK):
|
|
|
20
21
|
max_tokens: OptionalNullable[int] = UNSET,
|
|
21
22
|
min_tokens: OptionalNullable[int] = UNSET,
|
|
22
23
|
stream: Optional[bool] = True,
|
|
23
|
-
stop: Optional[
|
|
24
|
+
stop: Optional[
|
|
25
|
+
Union[
|
|
26
|
+
models.FIMCompletionStreamRequestStop,
|
|
27
|
+
models.FIMCompletionStreamRequestStopTypedDict,
|
|
28
|
+
]
|
|
29
|
+
] = None,
|
|
24
30
|
random_seed: OptionalNullable[int] = UNSET,
|
|
25
31
|
suffix: OptionalNullable[str] = UNSET,
|
|
26
32
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
@@ -37,7 +43,7 @@ class Fim(BaseSDK):
|
|
|
37
43
|
:param top_p: Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
|
|
38
44
|
: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.
|
|
39
45
|
:param min_tokens: The minimum number of tokens to generate in the completion.
|
|
40
|
-
:param stream:
|
|
46
|
+
:param stream:
|
|
41
47
|
:param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
|
|
42
48
|
:param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
43
49
|
:param suffix: Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`.
|
|
@@ -49,10 +55,10 @@ class Fim(BaseSDK):
|
|
|
49
55
|
url_variables = None
|
|
50
56
|
if timeout_ms is None:
|
|
51
57
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
52
|
-
|
|
58
|
+
|
|
53
59
|
if server_url is not None:
|
|
54
60
|
base_url = server_url
|
|
55
|
-
|
|
61
|
+
|
|
56
62
|
request = models.FIMCompletionStreamRequest(
|
|
57
63
|
model=model,
|
|
58
64
|
temperature=temperature,
|
|
@@ -65,7 +71,7 @@ class Fim(BaseSDK):
|
|
|
65
71
|
prompt=prompt,
|
|
66
72
|
suffix=suffix,
|
|
67
73
|
)
|
|
68
|
-
|
|
74
|
+
|
|
69
75
|
req = self.build_request(
|
|
70
76
|
method="POST",
|
|
71
77
|
path="/streamRawPredict#fim",
|
|
@@ -78,48 +84,58 @@ class Fim(BaseSDK):
|
|
|
78
84
|
user_agent_header="user-agent",
|
|
79
85
|
accept_header_value="text/event-stream",
|
|
80
86
|
security=self.sdk_configuration.security,
|
|
81
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
87
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
88
|
+
request, False, False, "json", models.FIMCompletionStreamRequest
|
|
89
|
+
),
|
|
82
90
|
timeout_ms=timeout_ms,
|
|
83
91
|
)
|
|
84
|
-
|
|
92
|
+
|
|
85
93
|
if retries == UNSET:
|
|
86
94
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
87
95
|
retries = self.sdk_configuration.retry_config
|
|
88
96
|
|
|
89
97
|
retry_config = None
|
|
90
98
|
if isinstance(retries, utils.RetryConfig):
|
|
91
|
-
retry_config = (retries, [
|
|
92
|
-
|
|
93
|
-
"500",
|
|
94
|
-
"502",
|
|
95
|
-
"503",
|
|
96
|
-
"504"
|
|
97
|
-
])
|
|
98
|
-
|
|
99
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
100
|
+
|
|
99
101
|
http_res = self.do_request(
|
|
100
|
-
hook_ctx=HookContext(
|
|
102
|
+
hook_ctx=HookContext(
|
|
103
|
+
operation_id="stream_fim",
|
|
104
|
+
oauth2_scopes=[],
|
|
105
|
+
security_source=self.sdk_configuration.security,
|
|
106
|
+
),
|
|
101
107
|
request=req,
|
|
102
|
-
error_status_codes=["422","4XX","5XX"],
|
|
108
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
103
109
|
stream=True,
|
|
104
|
-
retry_config=retry_config
|
|
110
|
+
retry_config=retry_config,
|
|
105
111
|
)
|
|
106
|
-
|
|
112
|
+
|
|
107
113
|
data: Any = None
|
|
108
114
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
109
|
-
return eventstreaming.stream_events(
|
|
115
|
+
return eventstreaming.stream_events(
|
|
116
|
+
http_res,
|
|
117
|
+
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
|
|
118
|
+
sentinel="[DONE]",
|
|
119
|
+
)
|
|
110
120
|
if utils.match_response(http_res, "422", "application/json"):
|
|
111
121
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
112
122
|
raise models.HTTPValidationError(data=data)
|
|
113
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
114
|
-
raise models.SDKError(
|
|
115
|
-
|
|
123
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
124
|
+
raise models.SDKError(
|
|
125
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
126
|
+
)
|
|
127
|
+
|
|
116
128
|
content_type = http_res.headers.get("Content-Type")
|
|
117
|
-
raise models.SDKError(
|
|
129
|
+
raise models.SDKError(
|
|
130
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
131
|
+
http_res.status_code,
|
|
132
|
+
http_res.text,
|
|
133
|
+
http_res,
|
|
134
|
+
)
|
|
118
135
|
|
|
119
|
-
|
|
120
|
-
|
|
121
136
|
async def stream_async(
|
|
122
|
-
self,
|
|
137
|
+
self,
|
|
138
|
+
*,
|
|
123
139
|
model: Nullable[str],
|
|
124
140
|
prompt: str,
|
|
125
141
|
temperature: Optional[float] = 0.7,
|
|
@@ -127,7 +143,12 @@ class Fim(BaseSDK):
|
|
|
127
143
|
max_tokens: OptionalNullable[int] = UNSET,
|
|
128
144
|
min_tokens: OptionalNullable[int] = UNSET,
|
|
129
145
|
stream: Optional[bool] = True,
|
|
130
|
-
stop: Optional[
|
|
146
|
+
stop: Optional[
|
|
147
|
+
Union[
|
|
148
|
+
models.FIMCompletionStreamRequestStop,
|
|
149
|
+
models.FIMCompletionStreamRequestStopTypedDict,
|
|
150
|
+
]
|
|
151
|
+
] = None,
|
|
131
152
|
random_seed: OptionalNullable[int] = UNSET,
|
|
132
153
|
suffix: OptionalNullable[str] = UNSET,
|
|
133
154
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
@@ -144,7 +165,7 @@ class Fim(BaseSDK):
|
|
|
144
165
|
:param top_p: Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
|
|
145
166
|
: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.
|
|
146
167
|
:param min_tokens: The minimum number of tokens to generate in the completion.
|
|
147
|
-
:param stream:
|
|
168
|
+
:param stream:
|
|
148
169
|
:param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
|
|
149
170
|
:param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
|
|
150
171
|
:param suffix: Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`.
|
|
@@ -156,10 +177,10 @@ class Fim(BaseSDK):
|
|
|
156
177
|
url_variables = None
|
|
157
178
|
if timeout_ms is None:
|
|
158
179
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
159
|
-
|
|
180
|
+
|
|
160
181
|
if server_url is not None:
|
|
161
182
|
base_url = server_url
|
|
162
|
-
|
|
183
|
+
|
|
163
184
|
request = models.FIMCompletionStreamRequest(
|
|
164
185
|
model=model,
|
|
165
186
|
temperature=temperature,
|
|
@@ -172,8 +193,8 @@ class Fim(BaseSDK):
|
|
|
172
193
|
prompt=prompt,
|
|
173
194
|
suffix=suffix,
|
|
174
195
|
)
|
|
175
|
-
|
|
176
|
-
req = self.
|
|
196
|
+
|
|
197
|
+
req = self.build_request_async(
|
|
177
198
|
method="POST",
|
|
178
199
|
path="/streamRawPredict#fim",
|
|
179
200
|
base_url=base_url,
|
|
@@ -185,48 +206,58 @@ class Fim(BaseSDK):
|
|
|
185
206
|
user_agent_header="user-agent",
|
|
186
207
|
accept_header_value="text/event-stream",
|
|
187
208
|
security=self.sdk_configuration.security,
|
|
188
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
209
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
210
|
+
request, False, False, "json", models.FIMCompletionStreamRequest
|
|
211
|
+
),
|
|
189
212
|
timeout_ms=timeout_ms,
|
|
190
213
|
)
|
|
191
|
-
|
|
214
|
+
|
|
192
215
|
if retries == UNSET:
|
|
193
216
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
194
217
|
retries = self.sdk_configuration.retry_config
|
|
195
218
|
|
|
196
219
|
retry_config = None
|
|
197
220
|
if isinstance(retries, utils.RetryConfig):
|
|
198
|
-
retry_config = (retries, [
|
|
199
|
-
|
|
200
|
-
"500",
|
|
201
|
-
"502",
|
|
202
|
-
"503",
|
|
203
|
-
"504"
|
|
204
|
-
])
|
|
205
|
-
|
|
221
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
222
|
+
|
|
206
223
|
http_res = await self.do_request_async(
|
|
207
|
-
hook_ctx=HookContext(
|
|
224
|
+
hook_ctx=HookContext(
|
|
225
|
+
operation_id="stream_fim",
|
|
226
|
+
oauth2_scopes=[],
|
|
227
|
+
security_source=self.sdk_configuration.security,
|
|
228
|
+
),
|
|
208
229
|
request=req,
|
|
209
|
-
error_status_codes=["422","4XX","5XX"],
|
|
230
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
210
231
|
stream=True,
|
|
211
|
-
retry_config=retry_config
|
|
232
|
+
retry_config=retry_config,
|
|
212
233
|
)
|
|
213
|
-
|
|
234
|
+
|
|
214
235
|
data: Any = None
|
|
215
236
|
if utils.match_response(http_res, "200", "text/event-stream"):
|
|
216
|
-
return eventstreaming.stream_events_async(
|
|
237
|
+
return eventstreaming.stream_events_async(
|
|
238
|
+
http_res,
|
|
239
|
+
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
|
|
240
|
+
sentinel="[DONE]",
|
|
241
|
+
)
|
|
217
242
|
if utils.match_response(http_res, "422", "application/json"):
|
|
218
243
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
219
244
|
raise models.HTTPValidationError(data=data)
|
|
220
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
221
|
-
raise models.SDKError(
|
|
222
|
-
|
|
245
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
246
|
+
raise models.SDKError(
|
|
247
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
248
|
+
)
|
|
249
|
+
|
|
223
250
|
content_type = http_res.headers.get("Content-Type")
|
|
224
|
-
raise models.SDKError(
|
|
251
|
+
raise models.SDKError(
|
|
252
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
253
|
+
http_res.status_code,
|
|
254
|
+
http_res.text,
|
|
255
|
+
http_res,
|
|
256
|
+
)
|
|
225
257
|
|
|
226
|
-
|
|
227
|
-
|
|
228
258
|
def complete(
|
|
229
|
-
self,
|
|
259
|
+
self,
|
|
260
|
+
*,
|
|
230
261
|
model: Nullable[str],
|
|
231
262
|
prompt: str,
|
|
232
263
|
temperature: Optional[float] = 0.7,
|
|
@@ -234,7 +265,12 @@ class Fim(BaseSDK):
|
|
|
234
265
|
max_tokens: OptionalNullable[int] = UNSET,
|
|
235
266
|
min_tokens: OptionalNullable[int] = UNSET,
|
|
236
267
|
stream: Optional[bool] = False,
|
|
237
|
-
stop: Optional[
|
|
268
|
+
stop: Optional[
|
|
269
|
+
Union[
|
|
270
|
+
models.FIMCompletionRequestStop,
|
|
271
|
+
models.FIMCompletionRequestStopTypedDict,
|
|
272
|
+
]
|
|
273
|
+
] = None,
|
|
238
274
|
random_seed: OptionalNullable[int] = UNSET,
|
|
239
275
|
suffix: OptionalNullable[str] = UNSET,
|
|
240
276
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
@@ -263,10 +299,10 @@ class Fim(BaseSDK):
|
|
|
263
299
|
url_variables = None
|
|
264
300
|
if timeout_ms is None:
|
|
265
301
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
266
|
-
|
|
302
|
+
|
|
267
303
|
if server_url is not None:
|
|
268
304
|
base_url = server_url
|
|
269
|
-
|
|
305
|
+
|
|
270
306
|
request = models.FIMCompletionRequest(
|
|
271
307
|
model=model,
|
|
272
308
|
temperature=temperature,
|
|
@@ -279,7 +315,7 @@ class Fim(BaseSDK):
|
|
|
279
315
|
prompt=prompt,
|
|
280
316
|
suffix=suffix,
|
|
281
317
|
)
|
|
282
|
-
|
|
318
|
+
|
|
283
319
|
req = self.build_request(
|
|
284
320
|
method="POST",
|
|
285
321
|
path="/rawPredict#fim",
|
|
@@ -292,47 +328,55 @@ class Fim(BaseSDK):
|
|
|
292
328
|
user_agent_header="user-agent",
|
|
293
329
|
accept_header_value="application/json",
|
|
294
330
|
security=self.sdk_configuration.security,
|
|
295
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
331
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
332
|
+
request, False, False, "json", models.FIMCompletionRequest
|
|
333
|
+
),
|
|
296
334
|
timeout_ms=timeout_ms,
|
|
297
335
|
)
|
|
298
|
-
|
|
336
|
+
|
|
299
337
|
if retries == UNSET:
|
|
300
338
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
301
339
|
retries = self.sdk_configuration.retry_config
|
|
302
340
|
|
|
303
341
|
retry_config = None
|
|
304
342
|
if isinstance(retries, utils.RetryConfig):
|
|
305
|
-
retry_config = (retries, [
|
|
306
|
-
|
|
307
|
-
"500",
|
|
308
|
-
"502",
|
|
309
|
-
"503",
|
|
310
|
-
"504"
|
|
311
|
-
])
|
|
312
|
-
|
|
343
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
344
|
+
|
|
313
345
|
http_res = self.do_request(
|
|
314
|
-
hook_ctx=HookContext(
|
|
346
|
+
hook_ctx=HookContext(
|
|
347
|
+
operation_id="fim_completion_v1_fim_completions_post",
|
|
348
|
+
oauth2_scopes=[],
|
|
349
|
+
security_source=self.sdk_configuration.security,
|
|
350
|
+
),
|
|
315
351
|
request=req,
|
|
316
|
-
error_status_codes=["422","4XX","5XX"],
|
|
317
|
-
retry_config=retry_config
|
|
352
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
353
|
+
retry_config=retry_config,
|
|
318
354
|
)
|
|
319
|
-
|
|
355
|
+
|
|
320
356
|
data: Any = None
|
|
321
357
|
if utils.match_response(http_res, "200", "application/json"):
|
|
322
|
-
return utils.unmarshal_json(
|
|
358
|
+
return utils.unmarshal_json(
|
|
359
|
+
http_res.text, Optional[models.FIMCompletionResponse]
|
|
360
|
+
)
|
|
323
361
|
if utils.match_response(http_res, "422", "application/json"):
|
|
324
362
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
325
363
|
raise models.HTTPValidationError(data=data)
|
|
326
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
327
|
-
raise models.SDKError(
|
|
328
|
-
|
|
364
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
365
|
+
raise models.SDKError(
|
|
366
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
367
|
+
)
|
|
368
|
+
|
|
329
369
|
content_type = http_res.headers.get("Content-Type")
|
|
330
|
-
raise models.SDKError(
|
|
370
|
+
raise models.SDKError(
|
|
371
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
372
|
+
http_res.status_code,
|
|
373
|
+
http_res.text,
|
|
374
|
+
http_res,
|
|
375
|
+
)
|
|
331
376
|
|
|
332
|
-
|
|
333
|
-
|
|
334
377
|
async def complete_async(
|
|
335
|
-
self,
|
|
378
|
+
self,
|
|
379
|
+
*,
|
|
336
380
|
model: Nullable[str],
|
|
337
381
|
prompt: str,
|
|
338
382
|
temperature: Optional[float] = 0.7,
|
|
@@ -340,7 +384,12 @@ class Fim(BaseSDK):
|
|
|
340
384
|
max_tokens: OptionalNullable[int] = UNSET,
|
|
341
385
|
min_tokens: OptionalNullable[int] = UNSET,
|
|
342
386
|
stream: Optional[bool] = False,
|
|
343
|
-
stop: Optional[
|
|
387
|
+
stop: Optional[
|
|
388
|
+
Union[
|
|
389
|
+
models.FIMCompletionRequestStop,
|
|
390
|
+
models.FIMCompletionRequestStopTypedDict,
|
|
391
|
+
]
|
|
392
|
+
] = None,
|
|
344
393
|
random_seed: OptionalNullable[int] = UNSET,
|
|
345
394
|
suffix: OptionalNullable[str] = UNSET,
|
|
346
395
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
@@ -369,10 +418,10 @@ class Fim(BaseSDK):
|
|
|
369
418
|
url_variables = None
|
|
370
419
|
if timeout_ms is None:
|
|
371
420
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
372
|
-
|
|
421
|
+
|
|
373
422
|
if server_url is not None:
|
|
374
423
|
base_url = server_url
|
|
375
|
-
|
|
424
|
+
|
|
376
425
|
request = models.FIMCompletionRequest(
|
|
377
426
|
model=model,
|
|
378
427
|
temperature=temperature,
|
|
@@ -385,8 +434,8 @@ class Fim(BaseSDK):
|
|
|
385
434
|
prompt=prompt,
|
|
386
435
|
suffix=suffix,
|
|
387
436
|
)
|
|
388
|
-
|
|
389
|
-
req = self.
|
|
437
|
+
|
|
438
|
+
req = self.build_request_async(
|
|
390
439
|
method="POST",
|
|
391
440
|
path="/rawPredict#fim",
|
|
392
441
|
base_url=base_url,
|
|
@@ -398,41 +447,48 @@ class Fim(BaseSDK):
|
|
|
398
447
|
user_agent_header="user-agent",
|
|
399
448
|
accept_header_value="application/json",
|
|
400
449
|
security=self.sdk_configuration.security,
|
|
401
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
450
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
451
|
+
request, False, False, "json", models.FIMCompletionRequest
|
|
452
|
+
),
|
|
402
453
|
timeout_ms=timeout_ms,
|
|
403
454
|
)
|
|
404
|
-
|
|
455
|
+
|
|
405
456
|
if retries == UNSET:
|
|
406
457
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
407
458
|
retries = self.sdk_configuration.retry_config
|
|
408
459
|
|
|
409
460
|
retry_config = None
|
|
410
461
|
if isinstance(retries, utils.RetryConfig):
|
|
411
|
-
retry_config = (retries, [
|
|
412
|
-
|
|
413
|
-
"500",
|
|
414
|
-
"502",
|
|
415
|
-
"503",
|
|
416
|
-
"504"
|
|
417
|
-
])
|
|
418
|
-
|
|
462
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
463
|
+
|
|
419
464
|
http_res = await self.do_request_async(
|
|
420
|
-
hook_ctx=HookContext(
|
|
465
|
+
hook_ctx=HookContext(
|
|
466
|
+
operation_id="fim_completion_v1_fim_completions_post",
|
|
467
|
+
oauth2_scopes=[],
|
|
468
|
+
security_source=self.sdk_configuration.security,
|
|
469
|
+
),
|
|
421
470
|
request=req,
|
|
422
|
-
error_status_codes=["422","4XX","5XX"],
|
|
423
|
-
retry_config=retry_config
|
|
471
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
472
|
+
retry_config=retry_config,
|
|
424
473
|
)
|
|
425
|
-
|
|
474
|
+
|
|
426
475
|
data: Any = None
|
|
427
476
|
if utils.match_response(http_res, "200", "application/json"):
|
|
428
|
-
return utils.unmarshal_json(
|
|
477
|
+
return utils.unmarshal_json(
|
|
478
|
+
http_res.text, Optional[models.FIMCompletionResponse]
|
|
479
|
+
)
|
|
429
480
|
if utils.match_response(http_res, "422", "application/json"):
|
|
430
481
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
431
482
|
raise models.HTTPValidationError(data=data)
|
|
432
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
433
|
-
raise models.SDKError(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
483
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
484
|
+
raise models.SDKError(
|
|
485
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
486
|
+
)
|
|
437
487
|
|
|
438
|
-
|
|
488
|
+
content_type = http_res.headers.get("Content-Type")
|
|
489
|
+
raise models.SDKError(
|
|
490
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
491
|
+
http_res.status_code,
|
|
492
|
+
http_res.text,
|
|
493
|
+
http_res,
|
|
494
|
+
)
|