mistralai 0.4.2__py3-none-any.whl → 1.0.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 (246) hide show
  1. mistralai/__init__.py +5 -0
  2. mistralai/_hooks/__init__.py +5 -0
  3. mistralai/_hooks/custom_user_agent.py +16 -0
  4. mistralai/_hooks/deprecation_warning.py +26 -0
  5. mistralai/_hooks/registration.py +17 -0
  6. mistralai/_hooks/sdkhooks.py +57 -0
  7. mistralai/_hooks/types.py +76 -0
  8. mistralai/agents.py +434 -0
  9. mistralai/async_client.py +5 -413
  10. mistralai/basesdk.py +253 -0
  11. mistralai/chat.py +470 -0
  12. mistralai/client.py +5 -414
  13. mistralai/embeddings.py +182 -0
  14. mistralai/files.py +600 -84
  15. mistralai/fim.py +438 -0
  16. mistralai/fine_tuning.py +16 -0
  17. mistralai/httpclient.py +78 -0
  18. mistralai/jobs.py +822 -150
  19. mistralai/models/__init__.py +82 -0
  20. mistralai/models/agentscompletionrequest.py +96 -0
  21. mistralai/models/agentscompletionstreamrequest.py +92 -0
  22. mistralai/models/archiveftmodelout.py +19 -0
  23. mistralai/models/assistantmessage.py +53 -0
  24. mistralai/models/chatcompletionchoice.py +22 -0
  25. mistralai/models/chatcompletionrequest.py +109 -0
  26. mistralai/models/chatcompletionresponse.py +27 -0
  27. mistralai/models/chatcompletionstreamrequest.py +107 -0
  28. mistralai/models/checkpointout.py +25 -0
  29. mistralai/models/completionchunk.py +27 -0
  30. mistralai/models/completionevent.py +15 -0
  31. mistralai/models/completionresponsestreamchoice.py +48 -0
  32. mistralai/models/contentchunk.py +17 -0
  33. mistralai/models/delete_model_v1_models_model_id_deleteop.py +18 -0
  34. mistralai/models/deletefileout.py +24 -0
  35. mistralai/models/deletemodelout.py +25 -0
  36. mistralai/models/deltamessage.py +47 -0
  37. mistralai/models/detailedjobout.py +91 -0
  38. mistralai/models/embeddingrequest.py +61 -0
  39. mistralai/models/embeddingresponse.py +24 -0
  40. mistralai/models/embeddingresponsedata.py +19 -0
  41. mistralai/models/eventout.py +50 -0
  42. mistralai/models/files_api_routes_delete_fileop.py +16 -0
  43. mistralai/models/files_api_routes_retrieve_fileop.py +16 -0
  44. mistralai/models/files_api_routes_upload_fileop.py +51 -0
  45. mistralai/models/fileschema.py +71 -0
  46. mistralai/models/fimcompletionrequest.py +94 -0
  47. mistralai/models/fimcompletionresponse.py +27 -0
  48. mistralai/models/fimcompletionstreamrequest.py +92 -0
  49. mistralai/models/finetuneablemodel.py +8 -0
  50. mistralai/models/ftmodelcapabilitiesout.py +21 -0
  51. mistralai/models/ftmodelout.py +65 -0
  52. mistralai/models/function.py +19 -0
  53. mistralai/models/functioncall.py +22 -0
  54. mistralai/models/githubrepositoryin.py +52 -0
  55. mistralai/models/githubrepositoryout.py +52 -0
  56. mistralai/models/httpvalidationerror.py +23 -0
  57. mistralai/models/jobin.py +73 -0
  58. mistralai/models/jobmetadataout.py +54 -0
  59. mistralai/models/jobout.py +107 -0
  60. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +18 -0
  61. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +18 -0
  62. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +15 -0
  63. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +18 -0
  64. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +81 -0
  65. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +16 -0
  66. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +18 -0
  67. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +21 -0
  68. mistralai/models/jobsout.py +20 -0
  69. mistralai/models/legacyjobmetadataout.py +80 -0
  70. mistralai/models/listfilesout.py +17 -0
  71. mistralai/models/metricout.py +50 -0
  72. mistralai/models/modelcapabilities.py +21 -0
  73. mistralai/models/modelcard.py +66 -0
  74. mistralai/models/modellist.py +18 -0
  75. mistralai/models/responseformat.py +18 -0
  76. mistralai/models/retrieve_model_v1_models_model_id_getop.py +18 -0
  77. mistralai/models/retrievefileout.py +71 -0
  78. mistralai/models/sampletype.py +7 -0
  79. mistralai/models/sdkerror.py +22 -0
  80. mistralai/models/security.py +16 -0
  81. mistralai/models/source.py +7 -0
  82. mistralai/models/systemmessage.py +26 -0
  83. mistralai/models/textchunk.py +17 -0
  84. mistralai/models/tool.py +18 -0
  85. mistralai/models/toolcall.py +20 -0
  86. mistralai/models/toolmessage.py +50 -0
  87. mistralai/models/trainingfile.py +17 -0
  88. mistralai/models/trainingparameters.py +48 -0
  89. mistralai/models/trainingparametersin.py +56 -0
  90. mistralai/models/unarchiveftmodelout.py +19 -0
  91. mistralai/models/updateftmodelin.py +44 -0
  92. mistralai/models/uploadfileout.py +71 -0
  93. mistralai/models/usageinfo.py +18 -0
  94. mistralai/models/usermessage.py +26 -0
  95. mistralai/models/validationerror.py +24 -0
  96. mistralai/models/wandbintegration.py +56 -0
  97. mistralai/models/wandbintegrationout.py +52 -0
  98. mistralai/models_.py +928 -0
  99. mistralai/py.typed +1 -0
  100. mistralai/sdk.py +119 -0
  101. mistralai/sdkconfiguration.py +54 -0
  102. mistralai/types/__init__.py +21 -0
  103. mistralai/types/basemodel.py +39 -0
  104. mistralai/utils/__init__.py +86 -0
  105. mistralai/utils/annotations.py +19 -0
  106. mistralai/utils/enums.py +34 -0
  107. mistralai/utils/eventstreaming.py +178 -0
  108. mistralai/utils/forms.py +207 -0
  109. mistralai/utils/headers.py +136 -0
  110. mistralai/utils/logger.py +16 -0
  111. mistralai/utils/metadata.py +118 -0
  112. mistralai/utils/queryparams.py +203 -0
  113. mistralai/utils/requestbodies.py +66 -0
  114. mistralai/utils/retries.py +216 -0
  115. mistralai/utils/security.py +185 -0
  116. mistralai/utils/serializers.py +181 -0
  117. mistralai/utils/url.py +150 -0
  118. mistralai/utils/values.py +128 -0
  119. {mistralai-0.4.2.dist-info → mistralai-1.0.0.dist-info}/LICENSE +1 -1
  120. mistralai-1.0.0.dist-info/METADATA +695 -0
  121. mistralai-1.0.0.dist-info/RECORD +235 -0
  122. mistralai_azure/__init__.py +5 -0
  123. mistralai_azure/_hooks/__init__.py +5 -0
  124. mistralai_azure/_hooks/custom_user_agent.py +16 -0
  125. mistralai_azure/_hooks/registration.py +15 -0
  126. mistralai_azure/_hooks/sdkhooks.py +57 -0
  127. mistralai_azure/_hooks/types.py +76 -0
  128. mistralai_azure/basesdk.py +253 -0
  129. mistralai_azure/chat.py +470 -0
  130. mistralai_azure/httpclient.py +78 -0
  131. mistralai_azure/models/__init__.py +28 -0
  132. mistralai_azure/models/assistantmessage.py +53 -0
  133. mistralai_azure/models/chatcompletionchoice.py +22 -0
  134. mistralai_azure/models/chatcompletionrequest.py +109 -0
  135. mistralai_azure/models/chatcompletionresponse.py +27 -0
  136. mistralai_azure/models/chatcompletionstreamrequest.py +107 -0
  137. mistralai_azure/models/completionchunk.py +27 -0
  138. mistralai_azure/models/completionevent.py +15 -0
  139. mistralai_azure/models/completionresponsestreamchoice.py +48 -0
  140. mistralai_azure/models/contentchunk.py +17 -0
  141. mistralai_azure/models/deltamessage.py +47 -0
  142. mistralai_azure/models/function.py +19 -0
  143. mistralai_azure/models/functioncall.py +22 -0
  144. mistralai_azure/models/httpvalidationerror.py +23 -0
  145. mistralai_azure/models/responseformat.py +18 -0
  146. mistralai_azure/models/sdkerror.py +22 -0
  147. mistralai_azure/models/security.py +16 -0
  148. mistralai_azure/models/systemmessage.py +26 -0
  149. mistralai_azure/models/textchunk.py +17 -0
  150. mistralai_azure/models/tool.py +18 -0
  151. mistralai_azure/models/toolcall.py +20 -0
  152. mistralai_azure/models/toolmessage.py +50 -0
  153. mistralai_azure/models/usageinfo.py +18 -0
  154. mistralai_azure/models/usermessage.py +26 -0
  155. mistralai_azure/models/validationerror.py +24 -0
  156. mistralai_azure/py.typed +1 -0
  157. mistralai_azure/sdk.py +107 -0
  158. mistralai_azure/sdkconfiguration.py +54 -0
  159. mistralai_azure/types/__init__.py +21 -0
  160. mistralai_azure/types/basemodel.py +39 -0
  161. mistralai_azure/utils/__init__.py +84 -0
  162. mistralai_azure/utils/annotations.py +19 -0
  163. mistralai_azure/utils/enums.py +34 -0
  164. mistralai_azure/utils/eventstreaming.py +178 -0
  165. mistralai_azure/utils/forms.py +207 -0
  166. mistralai_azure/utils/headers.py +136 -0
  167. mistralai_azure/utils/logger.py +16 -0
  168. mistralai_azure/utils/metadata.py +118 -0
  169. mistralai_azure/utils/queryparams.py +203 -0
  170. mistralai_azure/utils/requestbodies.py +66 -0
  171. mistralai_azure/utils/retries.py +216 -0
  172. mistralai_azure/utils/security.py +168 -0
  173. mistralai_azure/utils/serializers.py +181 -0
  174. mistralai_azure/utils/url.py +150 -0
  175. mistralai_azure/utils/values.py +128 -0
  176. mistralai_gcp/__init__.py +5 -0
  177. mistralai_gcp/_hooks/__init__.py +5 -0
  178. mistralai_gcp/_hooks/custom_user_agent.py +16 -0
  179. mistralai_gcp/_hooks/registration.py +15 -0
  180. mistralai_gcp/_hooks/sdkhooks.py +57 -0
  181. mistralai_gcp/_hooks/types.py +76 -0
  182. mistralai_gcp/basesdk.py +253 -0
  183. mistralai_gcp/chat.py +458 -0
  184. mistralai_gcp/fim.py +438 -0
  185. mistralai_gcp/httpclient.py +78 -0
  186. mistralai_gcp/models/__init__.py +31 -0
  187. mistralai_gcp/models/assistantmessage.py +53 -0
  188. mistralai_gcp/models/chatcompletionchoice.py +22 -0
  189. mistralai_gcp/models/chatcompletionrequest.py +105 -0
  190. mistralai_gcp/models/chatcompletionresponse.py +27 -0
  191. mistralai_gcp/models/chatcompletionstreamrequest.py +103 -0
  192. mistralai_gcp/models/completionchunk.py +27 -0
  193. mistralai_gcp/models/completionevent.py +15 -0
  194. mistralai_gcp/models/completionresponsestreamchoice.py +48 -0
  195. mistralai_gcp/models/contentchunk.py +17 -0
  196. mistralai_gcp/models/deltamessage.py +47 -0
  197. mistralai_gcp/models/fimcompletionrequest.py +94 -0
  198. mistralai_gcp/models/fimcompletionresponse.py +27 -0
  199. mistralai_gcp/models/fimcompletionstreamrequest.py +92 -0
  200. mistralai_gcp/models/function.py +19 -0
  201. mistralai_gcp/models/functioncall.py +22 -0
  202. mistralai_gcp/models/httpvalidationerror.py +23 -0
  203. mistralai_gcp/models/responseformat.py +18 -0
  204. mistralai_gcp/models/sdkerror.py +22 -0
  205. mistralai_gcp/models/security.py +16 -0
  206. mistralai_gcp/models/systemmessage.py +26 -0
  207. mistralai_gcp/models/textchunk.py +17 -0
  208. mistralai_gcp/models/tool.py +18 -0
  209. mistralai_gcp/models/toolcall.py +20 -0
  210. mistralai_gcp/models/toolmessage.py +50 -0
  211. mistralai_gcp/models/usageinfo.py +18 -0
  212. mistralai_gcp/models/usermessage.py +26 -0
  213. mistralai_gcp/models/validationerror.py +24 -0
  214. mistralai_gcp/py.typed +1 -0
  215. mistralai_gcp/sdk.py +174 -0
  216. mistralai_gcp/sdkconfiguration.py +54 -0
  217. mistralai_gcp/types/__init__.py +21 -0
  218. mistralai_gcp/types/basemodel.py +39 -0
  219. mistralai_gcp/utils/__init__.py +84 -0
  220. mistralai_gcp/utils/annotations.py +19 -0
  221. mistralai_gcp/utils/enums.py +34 -0
  222. mistralai_gcp/utils/eventstreaming.py +178 -0
  223. mistralai_gcp/utils/forms.py +207 -0
  224. mistralai_gcp/utils/headers.py +136 -0
  225. mistralai_gcp/utils/logger.py +16 -0
  226. mistralai_gcp/utils/metadata.py +118 -0
  227. mistralai_gcp/utils/queryparams.py +203 -0
  228. mistralai_gcp/utils/requestbodies.py +66 -0
  229. mistralai_gcp/utils/retries.py +216 -0
  230. mistralai_gcp/utils/security.py +168 -0
  231. mistralai_gcp/utils/serializers.py +181 -0
  232. mistralai_gcp/utils/url.py +150 -0
  233. mistralai_gcp/utils/values.py +128 -0
  234. py.typed +1 -0
  235. mistralai/client_base.py +0 -211
  236. mistralai/constants.py +0 -5
  237. mistralai/exceptions.py +0 -54
  238. mistralai/models/chat_completion.py +0 -93
  239. mistralai/models/common.py +0 -9
  240. mistralai/models/embeddings.py +0 -19
  241. mistralai/models/files.py +0 -23
  242. mistralai/models/jobs.py +0 -100
  243. mistralai/models/models.py +0 -39
  244. mistralai-0.4.2.dist-info/METADATA +0 -82
  245. mistralai-0.4.2.dist-info/RECORD +0 -20
  246. {mistralai-0.4.2.dist-info → mistralai-1.0.0.dist-info}/WHEEL +0 -0
mistralai_gcp/fim.py ADDED
@@ -0,0 +1,438 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from mistralai_gcp import models, utils
5
+ from mistralai_gcp._hooks import HookContext
6
+ from mistralai_gcp.types import Nullable, OptionalNullable, UNSET
7
+ from mistralai_gcp.utils import eventstreaming
8
+ from typing import Any, AsyncGenerator, Generator, Optional, Union
9
+
10
+ class Fim(BaseSDK):
11
+ r"""Fill-in-the-middle API."""
12
+
13
+
14
+ def stream(
15
+ self, *,
16
+ model: Nullable[str],
17
+ prompt: str,
18
+ temperature: Optional[float] = 0.7,
19
+ top_p: Optional[float] = 1,
20
+ max_tokens: OptionalNullable[int] = UNSET,
21
+ min_tokens: OptionalNullable[int] = UNSET,
22
+ stream: Optional[bool] = True,
23
+ stop: Optional[Union[models.FIMCompletionStreamRequestStop, models.FIMCompletionStreamRequestStopTypedDict]] = None,
24
+ random_seed: OptionalNullable[int] = UNSET,
25
+ suffix: OptionalNullable[str] = UNSET,
26
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
27
+ server_url: Optional[str] = None,
28
+ timeout_ms: Optional[int] = None,
29
+ ) -> Optional[Generator[models.CompletionEvent, None, None]]:
30
+ r"""Stream fim completion
31
+
32
+ Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
33
+
34
+ :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
35
+ :param prompt: The text/code to complete.
36
+ :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
37
+ :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
+ :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
+ :param min_tokens: The minimum number of tokens to generate in the completion.
40
+ :param stream:
41
+ :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
42
+ :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
43
+ :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`.
44
+ :param retries: Override the default retry configuration for this method
45
+ :param server_url: Override the default server URL for this method
46
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
47
+ """
48
+ base_url = None
49
+ url_variables = None
50
+ if timeout_ms is None:
51
+ timeout_ms = self.sdk_configuration.timeout_ms
52
+
53
+ if server_url is not None:
54
+ base_url = server_url
55
+
56
+ request = models.FIMCompletionStreamRequest(
57
+ model=model,
58
+ temperature=temperature,
59
+ top_p=top_p,
60
+ max_tokens=max_tokens,
61
+ min_tokens=min_tokens,
62
+ stream=stream,
63
+ stop=stop,
64
+ random_seed=random_seed,
65
+ prompt=prompt,
66
+ suffix=suffix,
67
+ )
68
+
69
+ req = self.build_request(
70
+ method="POST",
71
+ path="/streamRawPredict#fim",
72
+ base_url=base_url,
73
+ url_variables=url_variables,
74
+ request=request,
75
+ request_body_required=True,
76
+ request_has_path_params=False,
77
+ request_has_query_params=True,
78
+ user_agent_header="user-agent",
79
+ accept_header_value="text/event-stream",
80
+ security=self.sdk_configuration.security,
81
+ get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.FIMCompletionStreamRequest),
82
+ timeout_ms=timeout_ms,
83
+ )
84
+
85
+ if retries == UNSET:
86
+ if self.sdk_configuration.retry_config is not UNSET:
87
+ retries = self.sdk_configuration.retry_config
88
+
89
+ retry_config = None
90
+ if isinstance(retries, utils.RetryConfig):
91
+ retry_config = (retries, [
92
+ "429",
93
+ "500",
94
+ "502",
95
+ "503",
96
+ "504"
97
+ ])
98
+
99
+ http_res = self.do_request(
100
+ hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=self.sdk_configuration.security),
101
+ request=req,
102
+ error_status_codes=["422","4XX","5XX"],
103
+ stream=True,
104
+ retry_config=retry_config
105
+ )
106
+
107
+ data: Any = None
108
+ if utils.match_response(http_res, "200", "text/event-stream"):
109
+ return eventstreaming.stream_events(http_res, lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), sentinel="[DONE]")
110
+ if utils.match_response(http_res, "422", "application/json"):
111
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
112
+ raise models.HTTPValidationError(data=data)
113
+ if utils.match_response(http_res, ["4XX","5XX"], "*"):
114
+ raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
115
+
116
+ content_type = http_res.headers.get("Content-Type")
117
+ raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
118
+
119
+
120
+
121
+ async def stream_async(
122
+ self, *,
123
+ model: Nullable[str],
124
+ prompt: str,
125
+ temperature: Optional[float] = 0.7,
126
+ top_p: Optional[float] = 1,
127
+ max_tokens: OptionalNullable[int] = UNSET,
128
+ min_tokens: OptionalNullable[int] = UNSET,
129
+ stream: Optional[bool] = True,
130
+ stop: Optional[Union[models.FIMCompletionStreamRequestStop, models.FIMCompletionStreamRequestStopTypedDict]] = None,
131
+ random_seed: OptionalNullable[int] = UNSET,
132
+ suffix: OptionalNullable[str] = UNSET,
133
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
134
+ server_url: Optional[str] = None,
135
+ timeout_ms: Optional[int] = None,
136
+ ) -> Optional[AsyncGenerator[models.CompletionEvent, None]]:
137
+ r"""Stream fim completion
138
+
139
+ Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
140
+
141
+ :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
142
+ :param prompt: The text/code to complete.
143
+ :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
144
+ :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
+ :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
+ :param min_tokens: The minimum number of tokens to generate in the completion.
147
+ :param stream:
148
+ :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
149
+ :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
150
+ :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`.
151
+ :param retries: Override the default retry configuration for this method
152
+ :param server_url: Override the default server URL for this method
153
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
154
+ """
155
+ base_url = None
156
+ url_variables = None
157
+ if timeout_ms is None:
158
+ timeout_ms = self.sdk_configuration.timeout_ms
159
+
160
+ if server_url is not None:
161
+ base_url = server_url
162
+
163
+ request = models.FIMCompletionStreamRequest(
164
+ model=model,
165
+ temperature=temperature,
166
+ top_p=top_p,
167
+ max_tokens=max_tokens,
168
+ min_tokens=min_tokens,
169
+ stream=stream,
170
+ stop=stop,
171
+ random_seed=random_seed,
172
+ prompt=prompt,
173
+ suffix=suffix,
174
+ )
175
+
176
+ req = self.build_request(
177
+ method="POST",
178
+ path="/streamRawPredict#fim",
179
+ base_url=base_url,
180
+ url_variables=url_variables,
181
+ request=request,
182
+ request_body_required=True,
183
+ request_has_path_params=False,
184
+ request_has_query_params=True,
185
+ user_agent_header="user-agent",
186
+ accept_header_value="text/event-stream",
187
+ security=self.sdk_configuration.security,
188
+ get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.FIMCompletionStreamRequest),
189
+ timeout_ms=timeout_ms,
190
+ )
191
+
192
+ if retries == UNSET:
193
+ if self.sdk_configuration.retry_config is not UNSET:
194
+ retries = self.sdk_configuration.retry_config
195
+
196
+ retry_config = None
197
+ if isinstance(retries, utils.RetryConfig):
198
+ retry_config = (retries, [
199
+ "429",
200
+ "500",
201
+ "502",
202
+ "503",
203
+ "504"
204
+ ])
205
+
206
+ http_res = await self.do_request_async(
207
+ hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=self.sdk_configuration.security),
208
+ request=req,
209
+ error_status_codes=["422","4XX","5XX"],
210
+ stream=True,
211
+ retry_config=retry_config
212
+ )
213
+
214
+ data: Any = None
215
+ if utils.match_response(http_res, "200", "text/event-stream"):
216
+ return eventstreaming.stream_events_async(http_res, lambda raw: utils.unmarshal_json(raw, models.CompletionEvent), sentinel="[DONE]")
217
+ if utils.match_response(http_res, "422", "application/json"):
218
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
219
+ raise models.HTTPValidationError(data=data)
220
+ if utils.match_response(http_res, ["4XX","5XX"], "*"):
221
+ raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
222
+
223
+ content_type = http_res.headers.get("Content-Type")
224
+ raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
225
+
226
+
227
+
228
+ def complete(
229
+ self, *,
230
+ model: Nullable[str],
231
+ prompt: str,
232
+ temperature: Optional[float] = 0.7,
233
+ top_p: Optional[float] = 1,
234
+ max_tokens: OptionalNullable[int] = UNSET,
235
+ min_tokens: OptionalNullable[int] = UNSET,
236
+ stream: Optional[bool] = False,
237
+ stop: Optional[Union[models.FIMCompletionRequestStop, models.FIMCompletionRequestStopTypedDict]] = None,
238
+ random_seed: OptionalNullable[int] = UNSET,
239
+ suffix: OptionalNullable[str] = UNSET,
240
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
241
+ server_url: Optional[str] = None,
242
+ timeout_ms: Optional[int] = None,
243
+ ) -> Optional[models.FIMCompletionResponse]:
244
+ r"""Fim Completion
245
+
246
+ FIM completion.
247
+
248
+ :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
249
+ :param prompt: The text/code to complete.
250
+ :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
251
+ :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.
252
+ :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.
253
+ :param min_tokens: The minimum number of tokens to generate in the completion.
254
+ :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.
255
+ :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
256
+ :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
257
+ :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`.
258
+ :param retries: Override the default retry configuration for this method
259
+ :param server_url: Override the default server URL for this method
260
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
261
+ """
262
+ base_url = None
263
+ url_variables = None
264
+ if timeout_ms is None:
265
+ timeout_ms = self.sdk_configuration.timeout_ms
266
+
267
+ if server_url is not None:
268
+ base_url = server_url
269
+
270
+ request = models.FIMCompletionRequest(
271
+ model=model,
272
+ temperature=temperature,
273
+ top_p=top_p,
274
+ max_tokens=max_tokens,
275
+ min_tokens=min_tokens,
276
+ stream=stream,
277
+ stop=stop,
278
+ random_seed=random_seed,
279
+ prompt=prompt,
280
+ suffix=suffix,
281
+ )
282
+
283
+ req = self.build_request(
284
+ method="POST",
285
+ path="/rawPredict#fim",
286
+ base_url=base_url,
287
+ url_variables=url_variables,
288
+ request=request,
289
+ request_body_required=True,
290
+ request_has_path_params=False,
291
+ request_has_query_params=True,
292
+ user_agent_header="user-agent",
293
+ accept_header_value="application/json",
294
+ security=self.sdk_configuration.security,
295
+ get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.FIMCompletionRequest),
296
+ timeout_ms=timeout_ms,
297
+ )
298
+
299
+ if retries == UNSET:
300
+ if self.sdk_configuration.retry_config is not UNSET:
301
+ retries = self.sdk_configuration.retry_config
302
+
303
+ retry_config = None
304
+ if isinstance(retries, utils.RetryConfig):
305
+ retry_config = (retries, [
306
+ "429",
307
+ "500",
308
+ "502",
309
+ "503",
310
+ "504"
311
+ ])
312
+
313
+ http_res = self.do_request(
314
+ hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
315
+ request=req,
316
+ error_status_codes=["422","4XX","5XX"],
317
+ retry_config=retry_config
318
+ )
319
+
320
+ data: Any = None
321
+ if utils.match_response(http_res, "200", "application/json"):
322
+ return utils.unmarshal_json(http_res.text, Optional[models.FIMCompletionResponse])
323
+ if utils.match_response(http_res, "422", "application/json"):
324
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
325
+ raise models.HTTPValidationError(data=data)
326
+ if utils.match_response(http_res, ["4XX","5XX"], "*"):
327
+ raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
328
+
329
+ content_type = http_res.headers.get("Content-Type")
330
+ raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
331
+
332
+
333
+
334
+ async def complete_async(
335
+ self, *,
336
+ model: Nullable[str],
337
+ prompt: str,
338
+ temperature: Optional[float] = 0.7,
339
+ top_p: Optional[float] = 1,
340
+ max_tokens: OptionalNullable[int] = UNSET,
341
+ min_tokens: OptionalNullable[int] = UNSET,
342
+ stream: Optional[bool] = False,
343
+ stop: Optional[Union[models.FIMCompletionRequestStop, models.FIMCompletionRequestStopTypedDict]] = None,
344
+ random_seed: OptionalNullable[int] = UNSET,
345
+ suffix: OptionalNullable[str] = UNSET,
346
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
347
+ server_url: Optional[str] = None,
348
+ timeout_ms: Optional[int] = None,
349
+ ) -> Optional[models.FIMCompletionResponse]:
350
+ r"""Fim Completion
351
+
352
+ FIM completion.
353
+
354
+ :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
355
+ :param prompt: The text/code to complete.
356
+ :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
357
+ :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.
358
+ :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.
359
+ :param min_tokens: The minimum number of tokens to generate in the completion.
360
+ :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.
361
+ :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
362
+ :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
363
+ :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`.
364
+ :param retries: Override the default retry configuration for this method
365
+ :param server_url: Override the default server URL for this method
366
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
367
+ """
368
+ base_url = None
369
+ url_variables = None
370
+ if timeout_ms is None:
371
+ timeout_ms = self.sdk_configuration.timeout_ms
372
+
373
+ if server_url is not None:
374
+ base_url = server_url
375
+
376
+ request = models.FIMCompletionRequest(
377
+ model=model,
378
+ temperature=temperature,
379
+ top_p=top_p,
380
+ max_tokens=max_tokens,
381
+ min_tokens=min_tokens,
382
+ stream=stream,
383
+ stop=stop,
384
+ random_seed=random_seed,
385
+ prompt=prompt,
386
+ suffix=suffix,
387
+ )
388
+
389
+ req = self.build_request(
390
+ method="POST",
391
+ path="/rawPredict#fim",
392
+ base_url=base_url,
393
+ url_variables=url_variables,
394
+ request=request,
395
+ request_body_required=True,
396
+ request_has_path_params=False,
397
+ request_has_query_params=True,
398
+ user_agent_header="user-agent",
399
+ accept_header_value="application/json",
400
+ security=self.sdk_configuration.security,
401
+ get_serialized_body=lambda: utils.serialize_request_body(request, False, False, "json", models.FIMCompletionRequest),
402
+ timeout_ms=timeout_ms,
403
+ )
404
+
405
+ if retries == UNSET:
406
+ if self.sdk_configuration.retry_config is not UNSET:
407
+ retries = self.sdk_configuration.retry_config
408
+
409
+ retry_config = None
410
+ if isinstance(retries, utils.RetryConfig):
411
+ retry_config = (retries, [
412
+ "429",
413
+ "500",
414
+ "502",
415
+ "503",
416
+ "504"
417
+ ])
418
+
419
+ http_res = await self.do_request_async(
420
+ hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
421
+ request=req,
422
+ error_status_codes=["422","4XX","5XX"],
423
+ retry_config=retry_config
424
+ )
425
+
426
+ data: Any = None
427
+ if utils.match_response(http_res, "200", "application/json"):
428
+ return utils.unmarshal_json(http_res.text, Optional[models.FIMCompletionResponse])
429
+ if utils.match_response(http_res, "422", "application/json"):
430
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
431
+ raise models.HTTPValidationError(data=data)
432
+ if utils.match_response(http_res, ["4XX","5XX"], "*"):
433
+ raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
434
+
435
+ content_type = http_res.headers.get("Content-Type")
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)
437
+
438
+
@@ -0,0 +1,78 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ # pyright: reportReturnType = false
4
+ from typing_extensions import Protocol, runtime_checkable
5
+ import httpx
6
+ from typing import Any, Optional, Union
7
+
8
+
9
+ @runtime_checkable
10
+ class HttpClient(Protocol):
11
+ def send(
12
+ self,
13
+ request: httpx.Request,
14
+ *,
15
+ stream: bool = False,
16
+ auth: Union[
17
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
18
+ ] = httpx.USE_CLIENT_DEFAULT,
19
+ follow_redirects: Union[
20
+ bool, httpx._client.UseClientDefault
21
+ ] = httpx.USE_CLIENT_DEFAULT,
22
+ ) -> httpx.Response:
23
+ pass
24
+
25
+ def build_request(
26
+ self,
27
+ method: str,
28
+ url: httpx._types.URLTypes,
29
+ *,
30
+ content: Optional[httpx._types.RequestContent] = None,
31
+ data: Optional[httpx._types.RequestData] = None,
32
+ files: Optional[httpx._types.RequestFiles] = None,
33
+ json: Optional[Any] = None,
34
+ params: Optional[httpx._types.QueryParamTypes] = None,
35
+ headers: Optional[httpx._types.HeaderTypes] = None,
36
+ cookies: Optional[httpx._types.CookieTypes] = None,
37
+ timeout: Union[
38
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
39
+ ] = httpx.USE_CLIENT_DEFAULT,
40
+ extensions: Optional[httpx._types.RequestExtensions] = None,
41
+ ) -> httpx.Request:
42
+ pass
43
+
44
+
45
+ @runtime_checkable
46
+ class AsyncHttpClient(Protocol):
47
+ async def send(
48
+ self,
49
+ request: httpx.Request,
50
+ *,
51
+ stream: bool = False,
52
+ auth: Union[
53
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
54
+ ] = httpx.USE_CLIENT_DEFAULT,
55
+ follow_redirects: Union[
56
+ bool, httpx._client.UseClientDefault
57
+ ] = httpx.USE_CLIENT_DEFAULT,
58
+ ) -> httpx.Response:
59
+ pass
60
+
61
+ def build_request(
62
+ self,
63
+ method: str,
64
+ url: httpx._types.URLTypes,
65
+ *,
66
+ content: Optional[httpx._types.RequestContent] = None,
67
+ data: Optional[httpx._types.RequestData] = None,
68
+ files: Optional[httpx._types.RequestFiles] = None,
69
+ json: Optional[Any] = None,
70
+ params: Optional[httpx._types.QueryParamTypes] = None,
71
+ headers: Optional[httpx._types.HeaderTypes] = None,
72
+ cookies: Optional[httpx._types.CookieTypes] = None,
73
+ timeout: Union[
74
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
75
+ ] = httpx.USE_CLIENT_DEFAULT,
76
+ extensions: Optional[httpx._types.RequestExtensions] = None,
77
+ ) -> httpx.Request:
78
+ pass
@@ -0,0 +1,31 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .assistantmessage import AssistantMessage, AssistantMessageRole, AssistantMessageTypedDict
4
+ from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceFinishReason, ChatCompletionChoiceTypedDict
5
+ from .chatcompletionrequest import ChatCompletionRequest, ChatCompletionRequestMessages, ChatCompletionRequestMessagesTypedDict, ChatCompletionRequestStop, ChatCompletionRequestStopTypedDict, ChatCompletionRequestToolChoice, ChatCompletionRequestTypedDict
6
+ from .chatcompletionresponse import ChatCompletionResponse, ChatCompletionResponseTypedDict
7
+ from .chatcompletionstreamrequest import ChatCompletionStreamRequest, ChatCompletionStreamRequestTypedDict, Messages, MessagesTypedDict, Stop, StopTypedDict, ToolChoice
8
+ from .completionchunk import CompletionChunk, CompletionChunkTypedDict
9
+ from .completionevent import CompletionEvent, CompletionEventTypedDict
10
+ from .completionresponsestreamchoice import CompletionResponseStreamChoice, CompletionResponseStreamChoiceTypedDict, FinishReason
11
+ from .contentchunk import ContentChunk, ContentChunkTypedDict
12
+ from .deltamessage import DeltaMessage, DeltaMessageTypedDict
13
+ from .fimcompletionrequest import FIMCompletionRequest, FIMCompletionRequestStop, FIMCompletionRequestStopTypedDict, FIMCompletionRequestTypedDict
14
+ from .fimcompletionresponse import FIMCompletionResponse, FIMCompletionResponseTypedDict
15
+ from .fimcompletionstreamrequest import FIMCompletionStreamRequest, FIMCompletionStreamRequestStop, FIMCompletionStreamRequestStopTypedDict, FIMCompletionStreamRequestTypedDict
16
+ from .function import Function, FunctionTypedDict
17
+ from .functioncall import Arguments, ArgumentsTypedDict, FunctionCall, FunctionCallTypedDict
18
+ from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
19
+ from .responseformat import ResponseFormat, ResponseFormatTypedDict, ResponseFormats
20
+ from .sdkerror import SDKError
21
+ from .security import Security, SecurityTypedDict
22
+ from .systemmessage import Content, ContentTypedDict, Role, SystemMessage, SystemMessageTypedDict
23
+ from .textchunk import TextChunk, TextChunkTypedDict
24
+ from .tool import Tool, ToolTypedDict
25
+ from .toolcall import ToolCall, ToolCallTypedDict
26
+ from .toolmessage import ToolMessage, ToolMessageRole, ToolMessageTypedDict
27
+ from .usageinfo import UsageInfo, UsageInfoTypedDict
28
+ from .usermessage import UserMessage, UserMessageContent, UserMessageContentTypedDict, UserMessageRole, UserMessageTypedDict
29
+ from .validationerror import Loc, LocTypedDict, ValidationError, ValidationErrorTypedDict
30
+
31
+ __all__ = ["Arguments", "ArgumentsTypedDict", "AssistantMessage", "AssistantMessageRole", "AssistantMessageTypedDict", "ChatCompletionChoice", "ChatCompletionChoiceFinishReason", "ChatCompletionChoiceTypedDict", "ChatCompletionRequest", "ChatCompletionRequestMessages", "ChatCompletionRequestMessagesTypedDict", "ChatCompletionRequestStop", "ChatCompletionRequestStopTypedDict", "ChatCompletionRequestToolChoice", "ChatCompletionRequestTypedDict", "ChatCompletionResponse", "ChatCompletionResponseTypedDict", "ChatCompletionStreamRequest", "ChatCompletionStreamRequestTypedDict", "CompletionChunk", "CompletionChunkTypedDict", "CompletionEvent", "CompletionEventTypedDict", "CompletionResponseStreamChoice", "CompletionResponseStreamChoiceTypedDict", "Content", "ContentChunk", "ContentChunkTypedDict", "ContentTypedDict", "DeltaMessage", "DeltaMessageTypedDict", "FIMCompletionRequest", "FIMCompletionRequestStop", "FIMCompletionRequestStopTypedDict", "FIMCompletionRequestTypedDict", "FIMCompletionResponse", "FIMCompletionResponseTypedDict", "FIMCompletionStreamRequest", "FIMCompletionStreamRequestStop", "FIMCompletionStreamRequestStopTypedDict", "FIMCompletionStreamRequestTypedDict", "FinishReason", "Function", "FunctionCall", "FunctionCallTypedDict", "FunctionTypedDict", "HTTPValidationError", "HTTPValidationErrorData", "Loc", "LocTypedDict", "Messages", "MessagesTypedDict", "ResponseFormat", "ResponseFormatTypedDict", "ResponseFormats", "Role", "SDKError", "Security", "SecurityTypedDict", "Stop", "StopTypedDict", "SystemMessage", "SystemMessageTypedDict", "TextChunk", "TextChunkTypedDict", "Tool", "ToolCall", "ToolCallTypedDict", "ToolChoice", "ToolMessage", "ToolMessageRole", "ToolMessageTypedDict", "ToolTypedDict", "UsageInfo", "UsageInfoTypedDict", "UserMessage", "UserMessageContent", "UserMessageContentTypedDict", "UserMessageRole", "UserMessageTypedDict", "ValidationError", "ValidationErrorTypedDict"]
@@ -0,0 +1,53 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .toolcall import ToolCall, ToolCallTypedDict
5
+ from mistralai_gcp.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
+ from pydantic import model_serializer
7
+ from typing import List, Literal, Optional, TypedDict
8
+ from typing_extensions import NotRequired
9
+
10
+
11
+ AssistantMessageRole = Literal["assistant"]
12
+
13
+ class AssistantMessageTypedDict(TypedDict):
14
+ content: NotRequired[Nullable[str]]
15
+ tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
16
+ prefix: NotRequired[bool]
17
+ r"""Set this to `true` when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message."""
18
+ role: NotRequired[AssistantMessageRole]
19
+
20
+
21
+ class AssistantMessage(BaseModel):
22
+ content: OptionalNullable[str] = UNSET
23
+ tool_calls: OptionalNullable[List[ToolCall]] = UNSET
24
+ prefix: Optional[bool] = False
25
+ r"""Set this to `true` when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message."""
26
+ role: Optional[AssistantMessageRole] = "assistant"
27
+
28
+ @model_serializer(mode="wrap")
29
+ def serialize_model(self, handler):
30
+ optional_fields = ["content", "tool_calls", "prefix", "role"]
31
+ nullable_fields = ["content", "tool_calls"]
32
+ null_default_fields = []
33
+
34
+ serialized = handler(self)
35
+
36
+ m = {}
37
+
38
+ for n, f in self.model_fields.items():
39
+ k = f.alias or n
40
+ val = serialized.get(k)
41
+
42
+ optional_nullable = k in optional_fields and k in nullable_fields
43
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
44
+
45
+ if val is not None and val != UNSET_SENTINEL:
46
+ m[k] = val
47
+ elif val != UNSET_SENTINEL and (
48
+ not k in optional_fields or (optional_nullable and is_set)
49
+ ):
50
+ m[k] = val
51
+
52
+ return m
53
+
@@ -0,0 +1,22 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
5
+ from mistralai_gcp.types import BaseModel
6
+ from typing import Literal, Optional, TypedDict
7
+ from typing_extensions import NotRequired
8
+
9
+
10
+ ChatCompletionChoiceFinishReason = Literal["stop", "length", "model_length", "error", "tool_calls"]
11
+
12
+ class ChatCompletionChoiceTypedDict(TypedDict):
13
+ index: int
14
+ finish_reason: ChatCompletionChoiceFinishReason
15
+ message: NotRequired[AssistantMessageTypedDict]
16
+
17
+
18
+ class ChatCompletionChoice(BaseModel):
19
+ index: int
20
+ finish_reason: ChatCompletionChoiceFinishReason
21
+ message: Optional[AssistantMessage] = None
22
+