diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index ff3c434..d435584 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,20 +1,20 @@ lockVersion: 2.0.0 id: 81b65c50-f2e3-40a3-bd65-346524007b3d management: - docChecksum: a7c4268dd1228c969aecfd7cfdb6ca3c + docChecksum: c19f5a86b8045af32a46604ee5478061 docVersion: 0.0.2 - speakeasyVersion: 1.357.4 - generationVersion: 2.390.6 - releaseVersion: 1.0.2 - configChecksum: 6c6983431817f47e5b2f8404eb1ab0dd + speakeasyVersion: 1.372.0 + generationVersion: 2.399.0 + releaseVersion: 1.1.2 + configChecksum: 73da950b6151099c2d5a87da13ba3360 repoURL: https://github.com/mistralai/client-ts.git installationURL: https://github.com/mistralai/client-ts published: true features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.6 - core: 3.12.3 + constsAndDefaults: 0.1.8 + core: 3.13.2 defaultEnabledRetries: 0.1.0 devContainers: 2.90.0 envVarSecurityUsage: 0.1.1 @@ -25,13 +25,14 @@ features: globalServerURLs: 2.82.4 nameOverrides: 2.81.2 nullables: 0.1.0 + openEnums: 0.1.1 responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 serverEvents: 0.1.4 serverEventsSentinels: 0.1.0 serverIDs: 2.81.2 - unions: 2.85.6 + unions: 2.85.7 generatedFiles: - src/funcs/modelsList.ts - src/funcs/modelsRetrieve.ts @@ -66,6 +67,7 @@ generatedFiles: - src/sdk/sdk.ts - .eslintrc.cjs - .npmignore + - FUNCTIONS.md - RUNTIMES.md - jsr.json - package.json @@ -79,6 +81,7 @@ generatedFiles: - src/lib/event-streams.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts - src/lib/matchers.ts - src/lib/primitives.ts - src/lib/retries.ts @@ -91,6 +94,7 @@ generatedFiles: - src/models/errors/sdkerror.ts - src/models/errors/sdkvalidationerror.ts - src/types/blobs.ts + - src/types/constdatetime.ts - src/types/enums.ts - src/types/fp.ts - src/types/index.ts @@ -219,6 +223,7 @@ generatedFiles: - docs/models/components/chatcompletionchoice.md - docs/models/components/assistantmessagerole.md - docs/models/components/assistantmessage.md + - docs/models/components/tooltypes.md - docs/models/components/toolcall.md - docs/models/components/arguments.md - docs/models/components/functioncall.md @@ -227,6 +232,7 @@ generatedFiles: - docs/models/components/messages.md - docs/models/components/toolchoice.md - docs/models/components/chatcompletionrequest.md + - docs/models/components/tooltooltypes.md - docs/models/components/tool.md - docs/models/components/functiont.md - docs/models/components/responseformats.md @@ -260,6 +266,8 @@ generatedFiles: - docs/models/components/agentscompletionrequesttoolchoice.md - docs/models/components/agentscompletionrequest.md - docs/models/components/agentscompletionstreamrequeststop.md + - docs/models/components/agentscompletionstreamrequestmessages.md + - docs/models/components/agentscompletionstreamrequesttoolchoice.md - docs/models/components/agentscompletionstreamrequest.md - docs/models/components/embeddingresponse.md - docs/models/components/embeddingresponsedata.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 1f7bb6e..4de31ce 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -15,7 +15,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 1.0.2 + version: 1.1.2 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 172fd4c..64aa6bd 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,15 +1,42 @@ -speakeasyVersion: 1.357.4 -sources: {} +speakeasyVersion: 1.372.0 +sources: + mistral-azure-source: + sourceNamespace: mistral-openapi-azure + sourceRevisionDigest: sha256:bc53dba5935490a409045de3c39ccf9e90243a289656dd538a542990aa376cca + sourceBlobDigest: sha256:4173c3be19775dd2bdd4ce28bb9ae6655650df75f2b689a44c3362d418d69d49 + tags: + - latest + mistral-google-cloud-source: + sourceNamespace: mistral-openapi-google-cloud + sourceRevisionDigest: sha256:ab52d75474e071db240ed9a5367dc6374867b5c9306d478dcfdf8f7b7d08607f + sourceBlobDigest: sha256:d5f9c665861d7fedd5093567d13e1f7f6a12b82137fbbecda4708007b15030ba + tags: + - latest + mistral-openapi: + sourceNamespace: mistral-openapi + sourceRevisionDigest: sha256:e4d5f5fe40e7f1141006ba40c1d85b743ce5dc2407635ca2e776ba0dfb00a398 + sourceBlobDigest: sha256:56f1bbe3a050c9505e003bb9790e443084922bff74b072805757076cdb8a136e + tags: + - latest targets: mistralai-azure-sdk: source: mistral-azure-source + sourceNamespace: mistral-openapi-azure + sourceRevisionDigest: sha256:bc53dba5935490a409045de3c39ccf9e90243a289656dd538a542990aa376cca + sourceBlobDigest: sha256:4173c3be19775dd2bdd4ce28bb9ae6655650df75f2b689a44c3362d418d69d49 outLocation: ./packages/mistralai-azure mistralai-gcp-sdk: source: mistral-google-cloud-source + sourceNamespace: mistral-openapi-google-cloud + sourceRevisionDigest: sha256:ab52d75474e071db240ed9a5367dc6374867b5c9306d478dcfdf8f7b7d08607f + sourceBlobDigest: sha256:d5f9c665861d7fedd5093567d13e1f7f6a12b82137fbbecda4708007b15030ba outLocation: ./packages/mistralai-gcp mistralai-sdk: source: mistral-openapi - outLocation: /github/workspace/repo + sourceNamespace: mistral-openapi + sourceRevisionDigest: sha256:e4d5f5fe40e7f1141006ba40c1d85b743ce5dc2407635ca2e776ba0dfb00a398 + sourceBlobDigest: sha256:56f1bbe3a050c9505e003bb9790e443084922bff74b072805757076cdb8a136e + outLocation: /Users/gaspard/public-mistral/client-ts workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/FUNCTIONS.md b/FUNCTIONS.md new file mode 100644 index 0000000..d6e4b11 --- /dev/null +++ b/FUNCTIONS.md @@ -0,0 +1,107 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { filesUpload } from "@mistralai/mistralai/funcs/filesUpload.js"; +import { SDKValidationError } from "@mistralai/mistralai/models/errors/sdkvalidationerror.js"; +import { openAsBlob } from "node:fs"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await filesUpload(mistral, { + file: await openAsBlob("./sample-file"), + }); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/README.md b/README.md index f7b86e0..9a2a29f 100644 --- a/README.md +++ b/README.md @@ -532,6 +532,63 @@ We also provide provider specific SDK for: - [GCP](packages/mistralai-gcp/README.md) - [Azure](packages/mistralai-azure/README.md) + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [agentsComplete](docs/sdks/agents/README.md#complete) +- [agentsStream](docs/sdks/agents/README.md#stream) +- [chatComplete](docs/sdks/chat/README.md#complete) +- [chatStream](docs/sdks/chat/README.md#stream) +- [embeddingsCreate](docs/sdks/embeddings/README.md#create) +- [filesDelete](docs/sdks/files/README.md#delete) +- [filesList](docs/sdks/files/README.md#list) +- [filesRetrieve](docs/sdks/files/README.md#retrieve) +- [filesUpload](docs/sdks/files/README.md#upload) +- [fimComplete](docs/sdks/fim/README.md#complete) +- [fimStream](docs/sdks/fim/README.md#stream) +- [fineTuningJobsCancel](docs/sdks/jobs/README.md#cancel) +- [fineTuningJobsCreate](docs/sdks/jobs/README.md#create) +- [fineTuningJobsGet](docs/sdks/jobs/README.md#get) +- [fineTuningJobsList](docs/sdks/jobs/README.md#list) +- [fineTuningJobsStart](docs/sdks/jobs/README.md#start) +- [modelsArchive](docs/sdks/models/README.md#archive) +- [modelsDelete](docs/sdks/models/README.md#delete) +- [modelsList](docs/sdks/models/README.md#list) +- [modelsRetrieve](docs/sdks/models/README.md#retrieve) +- [modelsUnarchive](docs/sdks/models/README.md#unarchive) +- [modelsUpdate](docs/sdks/models/README.md#update) + + +
+ + + +## Debugging + +To log HTTP requests and responses, you can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { Mistral } from "@mistralai/mistralai"; + +const sdk = new Mistral({ debugLogger: console }); +``` + + # Development diff --git a/docs/models/components/agentscompletionrequest.md b/docs/models/components/agentscompletionrequest.md index ee48faa..f5d9ad3 100644 --- a/docs/models/components/agentscompletionrequest.md +++ b/docs/models/components/agentscompletionrequest.md @@ -1,5 +1,20 @@ # AgentsCompletionRequest +## Example Usage + +```typescript +import { AgentsCompletionRequest } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionRequest = { + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + agentId: "", +}; +``` ## Fields @@ -10,7 +25,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | 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. | | | `stop` | *components.AgentsCompletionRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.AgentsCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.AgentsCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.AgentsCompletionRequestToolChoice](../../models/components/agentscompletionrequesttoolchoice.md) | :heavy_minus_sign: | N/A | | diff --git a/docs/models/components/agentscompletionrequestmessages.md b/docs/models/components/agentscompletionrequestmessages.md index f462d56..fd886f5 100644 --- a/docs/models/components/agentscompletionrequestmessages.md +++ b/docs/models/components/agentscompletionrequestmessages.md @@ -1,5 +1,14 @@ # AgentsCompletionRequestMessages +## Example Usage + +```typescript +import { AgentsCompletionRequestMessages } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionRequestMessages = { + content: "", +}; +``` ## Supported Types diff --git a/docs/models/components/agentscompletionrequeststop.md b/docs/models/components/agentscompletionrequeststop.md index 3bfe082..1197f6a 100644 --- a/docs/models/components/agentscompletionrequeststop.md +++ b/docs/models/components/agentscompletionrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { AgentsCompletionRequestStop } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionRequestStop = [""]; +``` ## Supported Types diff --git a/docs/models/components/agentscompletionrequesttoolchoice.md b/docs/models/components/agentscompletionrequesttoolchoice.md index 8739806..8ebff86 100644 --- a/docs/models/components/agentscompletionrequesttoolchoice.md +++ b/docs/models/components/agentscompletionrequesttoolchoice.md @@ -1,10 +1,15 @@ # AgentsCompletionRequestToolChoice +## Example Usage + +```typescript +import { AgentsCompletionRequestToolChoice } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionRequestToolChoice = "none"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/docs/models/components/agentscompletionstreamrequest.md b/docs/models/components/agentscompletionstreamrequest.md index 426c0cf..a54163f 100644 --- a/docs/models/components/agentscompletionstreamrequest.md +++ b/docs/models/components/agentscompletionstreamrequest.md @@ -1,17 +1,32 @@ # AgentsCompletionStreamRequest +## Example Usage + +```typescript +import { AgentsCompletionStreamRequest } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionStreamRequest = { + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + agentId: "", +}; +``` ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | *string* | :heavy_check_mark: | ID of the model to use. Only compatible for now with:
- `codestral-2405`
- `codestral-latest` | codestral-2405 | -| `temperature` | *number* | :heavy_minus_sign: | 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. | | -| `topP` | *number* | :heavy_minus_sign: | 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. | | -| `maxTokens` | *number* | :heavy_minus_sign: | 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. | | -| `minTokens` | *number* | :heavy_minus_sign: | The minimum number of tokens to generate in the completion. | | -| `stream` | *boolean* | :heavy_minus_sign: | N/A | | -| `stop` | *components.AgentsCompletionStreamRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | -| `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `prompt` | *string* | :heavy_check_mark: | The text/code to complete. | def | -| `suffix` | *string* | :heavy_minus_sign: | 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`. | return a+b | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `maxTokens` | *number* | :heavy_minus_sign: | 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. | | +| `minTokens` | *number* | :heavy_minus_sign: | The minimum number of tokens to generate in the completion. | | +| `stream` | *boolean* | :heavy_minus_sign: | N/A | | +| `stop` | *components.AgentsCompletionStreamRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | +| `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | +| `messages` | *components.AgentsCompletionStreamRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | +| `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | +| `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | +| `toolChoice` | [components.AgentsCompletionStreamRequestToolChoice](../../models/components/agentscompletionstreamrequesttoolchoice.md) | :heavy_minus_sign: | N/A | | +| `agentId` | *string* | :heavy_check_mark: | The ID of the agent to use for this completion. | | \ No newline at end of file diff --git a/docs/models/components/agentscompletionstreamrequestmessages.md b/docs/models/components/agentscompletionstreamrequestmessages.md new file mode 100644 index 0000000..f9fcf9c --- /dev/null +++ b/docs/models/components/agentscompletionstreamrequestmessages.md @@ -0,0 +1,32 @@ +# AgentsCompletionStreamRequestMessages + +## Example Usage + +```typescript +import { AgentsCompletionStreamRequestMessages } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionStreamRequestMessages = { + content: "", +}; +``` + +## Supported Types + +### `components.AssistantMessage` + +```typescript +const value: components.AssistantMessage = /* values here */ +``` + +### `components.ToolMessage` + +```typescript +const value: components.ToolMessage = /* values here */ +``` + +### `components.UserMessage` + +```typescript +const value: components.UserMessage = /* values here */ +``` + diff --git a/docs/models/components/agentscompletionstreamrequeststop.md b/docs/models/components/agentscompletionstreamrequeststop.md index 41ea8e7..72b7885 100644 --- a/docs/models/components/agentscompletionstreamrequeststop.md +++ b/docs/models/components/agentscompletionstreamrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { AgentsCompletionStreamRequestStop } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionStreamRequestStop = ""; +``` ## Supported Types diff --git a/docs/models/components/agentscompletionstreamrequesttoolchoice.md b/docs/models/components/agentscompletionstreamrequesttoolchoice.md new file mode 100644 index 0000000..134d1bc --- /dev/null +++ b/docs/models/components/agentscompletionstreamrequesttoolchoice.md @@ -0,0 +1,15 @@ +# AgentsCompletionStreamRequestToolChoice + +## Example Usage + +```typescript +import { AgentsCompletionStreamRequestToolChoice } from "@mistralai/mistralai/models/components"; + +let value: AgentsCompletionStreamRequestToolChoice = "none"; +``` + +## Values + +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/docs/models/components/archiveftmodelout.md b/docs/models/components/archiveftmodelout.md index fa3e6d9..1addbed 100644 --- a/docs/models/components/archiveftmodelout.md +++ b/docs/models/components/archiveftmodelout.md @@ -1,5 +1,14 @@ # ArchiveFTModelOut +## Example Usage + +```typescript +import { ArchiveFTModelOut } from "@mistralai/mistralai/models/components"; + +let value: ArchiveFTModelOut = { + id: "", +}; +``` ## Fields diff --git a/docs/models/components/arguments.md b/docs/models/components/arguments.md index aacbc0b..b4737fc 100644 --- a/docs/models/components/arguments.md +++ b/docs/models/components/arguments.md @@ -1,5 +1,12 @@ # Arguments +## Example Usage + +```typescript +import { Arguments } from "@mistralai/mistralai/models/components"; + +let value: Arguments = ""; +``` ## Supported Types diff --git a/docs/models/components/assistantmessage.md b/docs/models/components/assistantmessage.md index 37c243d..1fe1399 100644 --- a/docs/models/components/assistantmessage.md +++ b/docs/models/components/assistantmessage.md @@ -1,5 +1,12 @@ # AssistantMessage +## Example Usage + +```typescript +import { AssistantMessage } from "@mistralai/mistralai/models/components"; + +let value: AssistantMessage = {}; +``` ## Fields diff --git a/docs/models/components/assistantmessagerole.md b/docs/models/components/assistantmessagerole.md index 781c8a5..b7291f0 100644 --- a/docs/models/components/assistantmessagerole.md +++ b/docs/models/components/assistantmessagerole.md @@ -1,8 +1,15 @@ # AssistantMessageRole +## Example Usage + +```typescript +import { AssistantMessageRole } from "@mistralai/mistralai/models/components"; + +let value: AssistantMessageRole = "assistant"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Assistant` | assistant | \ No newline at end of file +```typescript +"assistant" +``` \ No newline at end of file diff --git a/docs/models/components/chatcompletionchoice.md b/docs/models/components/chatcompletionchoice.md index 57260b2..a7a6143 100644 --- a/docs/models/components/chatcompletionchoice.md +++ b/docs/models/components/chatcompletionchoice.md @@ -1,10 +1,21 @@ # ChatCompletionChoice +## Example Usage + +```typescript +import { ChatCompletionChoice } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionChoice = { + index: 0, + message: {}, + finishReason: "stop", +}; +``` ## Fields | Field | Type | Required | Description | Example | | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | `index` | *number* | :heavy_check_mark: | N/A | 0 | -| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_minus_sign: | N/A | | +| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_check_mark: | N/A | | | `finishReason` | [components.FinishReason](../../models/components/finishreason.md) | :heavy_check_mark: | N/A | stop | \ No newline at end of file diff --git a/docs/models/components/chatcompletionrequest.md b/docs/models/components/chatcompletionrequest.md index b9ec7a3..b250efc 100644 --- a/docs/models/components/chatcompletionrequest.md +++ b/docs/models/components/chatcompletionrequest.md @@ -1,11 +1,26 @@ # ChatCompletionRequest +## Example Usage + +```typescript +import { ChatCompletionRequest } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionRequest = { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields | Field | Type | Required | Description | Example | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | +| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | | `temperature` | *number* | :heavy_minus_sign: | 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. | | | `topP` | *number* | :heavy_minus_sign: | 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. | | | `maxTokens` | *number* | :heavy_minus_sign: | 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. | | @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | 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. | | | `stop` | *components.Stop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ToolChoice](../../models/components/toolchoice.md) | :heavy_minus_sign: | N/A | | diff --git a/docs/models/components/chatcompletionresponse.md b/docs/models/components/chatcompletionresponse.md index 9e595eb..6287b99 100644 --- a/docs/models/components/chatcompletionresponse.md +++ b/docs/models/components/chatcompletionresponse.md @@ -1,5 +1,29 @@ # ChatCompletionResponse +## Example Usage + +```typescript +import { ChatCompletionResponse } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "mistral-small-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + created: 1702256327, + choices: [ + { + index: 0, + message: {}, + finishReason: "stop", + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/chatcompletionstreamrequest.md b/docs/models/components/chatcompletionstreamrequest.md index 2018829..2322da3 100644 --- a/docs/models/components/chatcompletionstreamrequest.md +++ b/docs/models/components/chatcompletionstreamrequest.md @@ -1,11 +1,26 @@ # ChatCompletionStreamRequest +## Example Usage + +```typescript +import { ChatCompletionStreamRequest } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionStreamRequest = { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | +| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | | `temperature` | *number* | :heavy_minus_sign: | 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. | | | `topP` | *number* | :heavy_minus_sign: | 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. | | | `maxTokens` | *number* | :heavy_minus_sign: | 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. | | @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | N/A | | | `stop` | *components.ChatCompletionStreamRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.ChatCompletionStreamRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.ChatCompletionStreamRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ChatCompletionStreamRequestToolChoice](../../models/components/chatcompletionstreamrequesttoolchoice.md) | :heavy_minus_sign: | N/A | | diff --git a/docs/models/components/chatcompletionstreamrequestmessages.md b/docs/models/components/chatcompletionstreamrequestmessages.md index 0d87560..5b65fe4 100644 --- a/docs/models/components/chatcompletionstreamrequestmessages.md +++ b/docs/models/components/chatcompletionstreamrequestmessages.md @@ -1,5 +1,14 @@ # ChatCompletionStreamRequestMessages +## Example Usage + +```typescript +import { ChatCompletionStreamRequestMessages } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionStreamRequestMessages = { + content: "", +}; +``` ## Supported Types diff --git a/docs/models/components/chatcompletionstreamrequeststop.md b/docs/models/components/chatcompletionstreamrequeststop.md index ccc458d..2be68e8 100644 --- a/docs/models/components/chatcompletionstreamrequeststop.md +++ b/docs/models/components/chatcompletionstreamrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { ChatCompletionStreamRequestStop } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionStreamRequestStop = [""]; +``` ## Supported Types diff --git a/docs/models/components/chatcompletionstreamrequesttoolchoice.md b/docs/models/components/chatcompletionstreamrequesttoolchoice.md index 308c586..375d019 100644 --- a/docs/models/components/chatcompletionstreamrequesttoolchoice.md +++ b/docs/models/components/chatcompletionstreamrequesttoolchoice.md @@ -1,10 +1,15 @@ # ChatCompletionStreamRequestToolChoice +## Example Usage + +```typescript +import { ChatCompletionStreamRequestToolChoice } from "@mistralai/mistralai/models/components"; + +let value: ChatCompletionStreamRequestToolChoice = "any"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/docs/models/components/checkpointout.md b/docs/models/components/checkpointout.md index 3c58bf8..28c64a7 100644 --- a/docs/models/components/checkpointout.md +++ b/docs/models/components/checkpointout.md @@ -1,5 +1,16 @@ # CheckpointOut +## Example Usage + +```typescript +import { CheckpointOut } from "@mistralai/mistralai/models/components"; + +let value: CheckpointOut = { + metrics: {}, + stepNumber: 638921, + createdAt: 1716963433, +}; +``` ## Fields diff --git a/docs/models/components/completionchunk.md b/docs/models/components/completionchunk.md index 8a6f4e9..3e7c7aa 100644 --- a/docs/models/components/completionchunk.md +++ b/docs/models/components/completionchunk.md @@ -1,5 +1,27 @@ # CompletionChunk +## Example Usage + +```typescript +import { CompletionChunk } from "@mistralai/mistralai/models/components"; + +let value: CompletionChunk = { + id: "", + model: "Mercielago", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 249796, + delta: {}, + finishReason: "error", + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/completionevent.md b/docs/models/components/completionevent.md index 912c4c4..faf04b9 100644 --- a/docs/models/components/completionevent.md +++ b/docs/models/components/completionevent.md @@ -1,5 +1,29 @@ # CompletionEvent +## Example Usage + +```typescript +import { CompletionEvent } from "@mistralai/mistralai/models/components"; + +let value: CompletionEvent = { + data: { + id: "", + model: "LeBaron", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 396506, + delta: {}, + finishReason: "error", + }, + ], + }, +}; +``` ## Fields diff --git a/docs/models/components/completionresponsestreamchoice.md b/docs/models/components/completionresponsestreamchoice.md index bd78896..50fa6c6 100644 --- a/docs/models/components/completionresponsestreamchoice.md +++ b/docs/models/components/completionresponsestreamchoice.md @@ -1,5 +1,16 @@ # CompletionResponseStreamChoice +## Example Usage + +```typescript +import { CompletionResponseStreamChoice } from "@mistralai/mistralai/models/components"; + +let value: CompletionResponseStreamChoice = { + index: 881736, + delta: {}, + finishReason: "tool_calls", +}; +``` ## Fields diff --git a/docs/models/components/completionresponsestreamchoicefinishreason.md b/docs/models/components/completionresponsestreamchoicefinishreason.md index 98da6a9..8a803ab 100644 --- a/docs/models/components/completionresponsestreamchoicefinishreason.md +++ b/docs/models/components/completionresponsestreamchoicefinishreason.md @@ -1,11 +1,15 @@ # CompletionResponseStreamChoiceFinishReason +## Example Usage + +```typescript +import { CompletionResponseStreamChoiceFinishReason } from "@mistralai/mistralai/models/components"; + +let value: CompletionResponseStreamChoiceFinishReason = "length"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Stop` | stop | -| `Length` | length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/docs/models/components/content.md b/docs/models/components/content.md index 4b41002..9b6fbab 100644 --- a/docs/models/components/content.md +++ b/docs/models/components/content.md @@ -1,5 +1,12 @@ # Content +## Example Usage + +```typescript +import { Content } from "@mistralai/mistralai/models/components"; + +let value: Content = ""; +``` ## Supported Types diff --git a/docs/models/components/contentchunk.md b/docs/models/components/contentchunk.md index 83896db..731b67f 100644 --- a/docs/models/components/contentchunk.md +++ b/docs/models/components/contentchunk.md @@ -1,5 +1,14 @@ # ContentChunk +## Example Usage + +```typescript +import { ContentChunk } from "@mistralai/mistralai/models/components"; + +let value: ContentChunk = { + text: "", +}; +``` ## Fields diff --git a/docs/models/components/deletefileout.md b/docs/models/components/deletefileout.md index 6709c5c..c3e0b18 100644 --- a/docs/models/components/deletefileout.md +++ b/docs/models/components/deletefileout.md @@ -1,5 +1,16 @@ # DeleteFileOut +## Example Usage + +```typescript +import { DeleteFileOut } from "@mistralai/mistralai/models/components"; + +let value: DeleteFileOut = { + id: "497f6eca-6276-4993-bfeb-53cbbbba6f09", + object: "file", + deleted: false, +}; +``` ## Fields diff --git a/docs/models/components/deletemodelout.md b/docs/models/components/deletemodelout.md index 3fddee6..67a3098 100644 --- a/docs/models/components/deletemodelout.md +++ b/docs/models/components/deletemodelout.md @@ -1,5 +1,15 @@ # DeleteModelOut +## Example Usage + +```typescript +import { DeleteModelOut } from "@mistralai/mistralai/models/components"; + +let value: DeleteModelOut = { + id: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + deleted: true, +}; +``` ## Fields diff --git a/docs/models/components/deltamessage.md b/docs/models/components/deltamessage.md index 51c99bf..86ca339 100644 --- a/docs/models/components/deltamessage.md +++ b/docs/models/components/deltamessage.md @@ -1,5 +1,12 @@ # DeltaMessage +## Example Usage + +```typescript +import { DeltaMessage } from "@mistralai/mistralai/models/components"; + +let value: DeltaMessage = {}; +``` ## Fields diff --git a/docs/models/components/detailedjobout.md b/docs/models/components/detailedjobout.md index f931e5a..586a64e 100644 --- a/docs/models/components/detailedjobout.md +++ b/docs/models/components/detailedjobout.md @@ -1,5 +1,29 @@ # DetailedJobOut +## Example Usage + +```typescript +import { DetailedJobOut } from "@mistralai/mistralai/models/components"; + +let value: DetailedJobOut = { + id: "b0074f15-471b-45e6-a13b-99d488e1e91e", + autoStart: false, + hyperparameters: {}, + model: "mistral-small-latest", + status: "VALIDATED", + jobType: "", + createdAt: 9356, + modifiedAt: 667411, + trainingFiles: ["d2abd442-6980-42d5-82a9-4bb4f63c969e"], + checkpoints: [ + { + metrics: {}, + stepNumber: 572252, + createdAt: 1716963433, + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/detailedjoboutstatus.md b/docs/models/components/detailedjoboutstatus.md index fa884ee..17e6416 100644 --- a/docs/models/components/detailedjoboutstatus.md +++ b/docs/models/components/detailedjoboutstatus.md @@ -1,17 +1,15 @@ # DetailedJobOutStatus +## Example Usage + +```typescript +import { DetailedJobOutStatus } from "@mistralai/mistralai/models/components"; + +let value: DetailedJobOutStatus = "RUNNING"; +``` ## Values -| Name | Value | -| ----------------------- | ----------------------- | -| `Queued` | QUEUED | -| `Started` | STARTED | -| `Validating` | VALIDATING | -| `Validated` | VALIDATED | -| `Running` | RUNNING | -| `FailedValidation` | FAILED_VALIDATION | -| `Failed` | FAILED | -| `Success` | SUCCESS | -| `Cancelled` | CANCELLED | -| `CancellationRequested` | CANCELLATION_REQUESTED | \ No newline at end of file +```typescript +"QUEUED" | "STARTED" | "VALIDATING" | "VALIDATED" | "RUNNING" | "FAILED_VALIDATION" | "FAILED" | "SUCCESS" | "CANCELLED" | "CANCELLATION_REQUESTED" +``` \ No newline at end of file diff --git a/docs/models/components/embeddingrequest.md b/docs/models/components/embeddingrequest.md index 8e2e87c..851b890 100644 --- a/docs/models/components/embeddingrequest.md +++ b/docs/models/components/embeddingrequest.md @@ -1,5 +1,15 @@ # EmbeddingRequest +## Example Usage + +```typescript +import { EmbeddingRequest } from "@mistralai/mistralai/models/components"; + +let value: EmbeddingRequest = { + inputs: "", + model: "Focus", +}; +``` ## Fields diff --git a/docs/models/components/embeddingresponse.md b/docs/models/components/embeddingresponse.md index 08a3622..2dceb5d 100644 --- a/docs/models/components/embeddingresponse.md +++ b/docs/models/components/embeddingresponse.md @@ -1,5 +1,28 @@ # EmbeddingResponse +## Example Usage + +```typescript +import { EmbeddingResponse } from "@mistralai/mistralai/models/components"; + +let value: EmbeddingResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "mistral-small-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + data: [ + { + object: "embedding", + embedding: [0.1, 0.2, 0.3], + index: 0, + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/embeddingresponsedata.md b/docs/models/components/embeddingresponsedata.md index 8dcd036..3c356cb 100644 --- a/docs/models/components/embeddingresponsedata.md +++ b/docs/models/components/embeddingresponsedata.md @@ -1,5 +1,16 @@ # EmbeddingResponseData +## Example Usage + +```typescript +import { EmbeddingResponseData } from "@mistralai/mistralai/models/components"; + +let value: EmbeddingResponseData = { + object: "embedding", + embedding: [0.1, 0.2, 0.3], + index: 0, +}; +``` ## Fields diff --git a/docs/models/components/eventout.md b/docs/models/components/eventout.md index f012f65..4ed7e64 100644 --- a/docs/models/components/eventout.md +++ b/docs/models/components/eventout.md @@ -1,5 +1,15 @@ # EventOut +## Example Usage + +```typescript +import { EventOut } from "@mistralai/mistralai/models/components"; + +let value: EventOut = { + name: "", + createdAt: 223081, +}; +``` ## Fields diff --git a/docs/models/components/fileschema.md b/docs/models/components/fileschema.md index af0e709..49f8bb5 100644 --- a/docs/models/components/fileschema.md +++ b/docs/models/components/fileschema.md @@ -1,5 +1,20 @@ # FileSchema +## Example Usage + +```typescript +import { FileSchema } from "@mistralai/mistralai/models/components"; + +let value: FileSchema = { + id: "497f6eca-6276-4993-bfeb-53cbbbba6f09", + object: "file", + bytes: 13000, + createdAt: 1716963433, + filename: "files_upload.jsonl", + sampleType: "instruct", + source: "repository", +}; +``` ## Fields diff --git a/docs/models/components/fimcompletionrequest.md b/docs/models/components/fimcompletionrequest.md index b3ceb22..84bd6ad 100644 --- a/docs/models/components/fimcompletionrequest.md +++ b/docs/models/components/fimcompletionrequest.md @@ -1,5 +1,16 @@ # FIMCompletionRequest +## Example Usage + +```typescript +import { FIMCompletionRequest } from "@mistralai/mistralai/models/components"; + +let value: FIMCompletionRequest = { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", +}; +``` ## Fields diff --git a/docs/models/components/fimcompletionrequeststop.md b/docs/models/components/fimcompletionrequeststop.md index 03bd871..4084655 100644 --- a/docs/models/components/fimcompletionrequeststop.md +++ b/docs/models/components/fimcompletionrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { FIMCompletionRequestStop } from "@mistralai/mistralai/models/components"; + +let value: FIMCompletionRequestStop = [""]; +``` ## Supported Types diff --git a/docs/models/components/fimcompletionresponse.md b/docs/models/components/fimcompletionresponse.md index b3705f7..26466b5 100644 --- a/docs/models/components/fimcompletionresponse.md +++ b/docs/models/components/fimcompletionresponse.md @@ -1,5 +1,29 @@ # FIMCompletionResponse +## Example Usage + +```typescript +import { FIMCompletionResponse } from "@mistralai/mistralai/models/components"; + +let value: FIMCompletionResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "codestral-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + created: 1702256327, + choices: [ + { + index: 0, + message: {}, + finishReason: "stop", + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/fimcompletionstreamrequest.md b/docs/models/components/fimcompletionstreamrequest.md index 8f32a6e..7f1e212 100644 --- a/docs/models/components/fimcompletionstreamrequest.md +++ b/docs/models/components/fimcompletionstreamrequest.md @@ -1,5 +1,16 @@ # FIMCompletionStreamRequest +## Example Usage + +```typescript +import { FIMCompletionStreamRequest } from "@mistralai/mistralai/models/components"; + +let value: FIMCompletionStreamRequest = { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", +}; +``` ## Fields diff --git a/docs/models/components/fimcompletionstreamrequeststop.md b/docs/models/components/fimcompletionstreamrequeststop.md index 2ab10b5..ae0d5dd 100644 --- a/docs/models/components/fimcompletionstreamrequeststop.md +++ b/docs/models/components/fimcompletionstreamrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { FIMCompletionStreamRequestStop } from "@mistralai/mistralai/models/components"; + +let value: FIMCompletionStreamRequestStop = [""]; +``` ## Supported Types diff --git a/docs/models/components/finetuneablemodel.md b/docs/models/components/finetuneablemodel.md index a7721bb..5fd8fad 100644 --- a/docs/models/components/finetuneablemodel.md +++ b/docs/models/components/finetuneablemodel.md @@ -2,13 +2,16 @@ The name of the model to fine-tune. +## Example Usage + +```typescript +import { FineTuneableModel } from "@mistralai/mistralai/models/components"; + +let value: FineTuneableModel = "mistral-small-latest"; +``` ## Values -| Name | Value | -| -------------------- | -------------------- | -| `OpenMistral7b` | open-mistral-7b | -| `MistralSmallLatest` | mistral-small-latest | -| `CodestralLatest` | codestral-latest | -| `MistralLargeLatest` | mistral-large-latest | -| `OpenMistralNemo` | open-mistral-nemo | \ No newline at end of file +```typescript +"open-mistral-7b" | "mistral-small-latest" | "codestral-latest" | "mistral-large-latest" | "open-mistral-nemo" +``` \ No newline at end of file diff --git a/docs/models/components/finishreason.md b/docs/models/components/finishreason.md index f1096e4..ac7b175 100644 --- a/docs/models/components/finishreason.md +++ b/docs/models/components/finishreason.md @@ -1,12 +1,15 @@ # FinishReason +## Example Usage + +```typescript +import { FinishReason } from "@mistralai/mistralai/models/components"; + +let value: FinishReason = "stop"; +``` ## Values -| Name | Value | -| ------------- | ------------- | -| `Stop` | stop | -| `Length` | length | -| `ModelLength` | model_length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "model_length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/docs/models/components/ftmodelcapabilitiesout.md b/docs/models/components/ftmodelcapabilitiesout.md index e589132..249505e 100644 --- a/docs/models/components/ftmodelcapabilitiesout.md +++ b/docs/models/components/ftmodelcapabilitiesout.md @@ -1,5 +1,12 @@ # FTModelCapabilitiesOut +## Example Usage + +```typescript +import { FTModelCapabilitiesOut } from "@mistralai/mistralai/models/components"; + +let value: FTModelCapabilitiesOut = {}; +``` ## Fields diff --git a/docs/models/components/ftmodelout.md b/docs/models/components/ftmodelout.md index 48106a1..9df4a5f 100644 --- a/docs/models/components/ftmodelout.md +++ b/docs/models/components/ftmodelout.md @@ -1,5 +1,20 @@ # FTModelOut +## Example Usage + +```typescript +import { FTModelOut } from "@mistralai/mistralai/models/components"; + +let value: FTModelOut = { + id: "", + created: 602763, + ownedBy: "", + root: "", + archived: false, + capabilities: {}, + job: "d8d69a67-4e0f-4467-8c87-96ed151a05df", +}; +``` ## Fields diff --git a/docs/models/components/functioncall.md b/docs/models/components/functioncall.md index 75750f4..990f063 100644 --- a/docs/models/components/functioncall.md +++ b/docs/models/components/functioncall.md @@ -1,5 +1,15 @@ # FunctionCall +## Example Usage + +```typescript +import { FunctionCall } from "@mistralai/mistralai/models/components"; + +let value: FunctionCall = { + name: "", + arguments: "", +}; +``` ## Fields diff --git a/docs/models/components/functiont.md b/docs/models/components/functiont.md index ed230e5..361803f 100644 --- a/docs/models/components/functiont.md +++ b/docs/models/components/functiont.md @@ -1,5 +1,17 @@ # FunctionT +## Example Usage + +```typescript +import { FunctionT } from "@mistralai/mistralai/models/components"; + +let value: FunctionT = { + name: "", + parameters: { + key: "", + }, +}; +``` ## Fields diff --git a/docs/models/components/githubrepositoryin.md b/docs/models/components/githubrepositoryin.md index 5e2d4ad..1b9b8dc 100644 --- a/docs/models/components/githubrepositoryin.md +++ b/docs/models/components/githubrepositoryin.md @@ -1,5 +1,16 @@ # GithubRepositoryIn +## Example Usage + +```typescript +import { GithubRepositoryIn } from "@mistralai/mistralai/models/components"; + +let value: GithubRepositoryIn = { + name: "", + owner: "", + token: "", +}; +``` ## Fields diff --git a/docs/models/components/githubrepositoryout.md b/docs/models/components/githubrepositoryout.md index 5e32030..f1b78b9 100644 --- a/docs/models/components/githubrepositoryout.md +++ b/docs/models/components/githubrepositoryout.md @@ -1,5 +1,16 @@ # GithubRepositoryOut +## Example Usage + +```typescript +import { GithubRepositoryOut } from "@mistralai/mistralai/models/components"; + +let value: GithubRepositoryOut = { + name: "", + owner: "", + commitId: "", +}; +``` ## Fields diff --git a/docs/models/components/inputs.md b/docs/models/components/inputs.md index aa74758..5ac3d69 100644 --- a/docs/models/components/inputs.md +++ b/docs/models/components/inputs.md @@ -2,6 +2,13 @@ Text to embed. +## Example Usage + +```typescript +import { Inputs } from "@mistralai/mistralai/models/components"; + +let value: Inputs = [""]; +``` ## Supported Types diff --git a/docs/models/components/jobin.md b/docs/models/components/jobin.md index 602de66..5c7803b 100644 --- a/docs/models/components/jobin.md +++ b/docs/models/components/jobin.md @@ -1,5 +1,15 @@ # JobIn +## Example Usage + +```typescript +import { JobIn } from "@mistralai/mistralai/models/components"; + +let value: JobIn = { + model: "codestral-latest", + hyperparameters: {}, +}; +``` ## Fields diff --git a/docs/models/components/jobmetadataout.md b/docs/models/components/jobmetadataout.md index 7cc1c44..3222f53 100644 --- a/docs/models/components/jobmetadataout.md +++ b/docs/models/components/jobmetadataout.md @@ -1,5 +1,12 @@ # JobMetadataOut +## Example Usage + +```typescript +import { JobMetadataOut } from "@mistralai/mistralai/models/components"; + +let value: JobMetadataOut = {}; +``` ## Fields diff --git a/docs/models/components/jobout.md b/docs/models/components/jobout.md index df9694d..be42b57 100644 --- a/docs/models/components/jobout.md +++ b/docs/models/components/jobout.md @@ -1,5 +1,22 @@ # JobOut +## Example Usage + +```typescript +import { JobOut } from "@mistralai/mistralai/models/components"; + +let value: JobOut = { + id: "1ba928fc-8167-442c-b739-205929396fea", + autoStart: false, + hyperparameters: {}, + model: "codestral-latest", + status: "VALIDATED", + jobType: "", + createdAt: 613064, + modifiedAt: 437032, + trainingFiles: ["eb10faaa-2352-4c59-9590-7aff1a3a2fa9"], +}; +``` ## Fields diff --git a/docs/models/components/jobsout.md b/docs/models/components/jobsout.md index c69cb44..7ea67bd 100644 --- a/docs/models/components/jobsout.md +++ b/docs/models/components/jobsout.md @@ -1,5 +1,14 @@ # JobsOut +## Example Usage + +```typescript +import { JobsOut } from "@mistralai/mistralai/models/components"; + +let value: JobsOut = { + total: 780529, +}; +``` ## Fields diff --git a/docs/models/components/legacyjobmetadataout.md b/docs/models/components/legacyjobmetadataout.md index 7667b67..1a08864 100644 --- a/docs/models/components/legacyjobmetadataout.md +++ b/docs/models/components/legacyjobmetadataout.md @@ -1,5 +1,22 @@ # LegacyJobMetadataOut +## Example Usage + +```typescript +import { LegacyJobMetadataOut } from "@mistralai/mistralai/models/components"; + +let value: LegacyJobMetadataOut = { + expectedDurationSeconds: 220, + cost: 10, + costCurrency: "EUR", + trainTokensPerStep: 131072, + trainTokens: 1310720, + dataTokens: 305375, + details: "", + epochs: 4.2922, + trainingSteps: 10, +}; +``` ## Fields diff --git a/docs/models/components/listfilesout.md b/docs/models/components/listfilesout.md index 2a425c0..10370d8 100644 --- a/docs/models/components/listfilesout.md +++ b/docs/models/components/listfilesout.md @@ -1,5 +1,25 @@ # ListFilesOut +## Example Usage + +```typescript +import { ListFilesOut } from "@mistralai/mistralai/models/components"; + +let value: ListFilesOut = { + data: [ + { + id: "497f6eca-6276-4993-bfeb-53cbbbba6f09", + object: "file", + bytes: 13000, + createdAt: 1716963433, + filename: "files_upload.jsonl", + sampleType: "instruct", + source: "upload", + }, + ], + object: "", +}; +``` ## Fields diff --git a/docs/models/components/loc.md b/docs/models/components/loc.md index 1d789e1..d18f095 100644 --- a/docs/models/components/loc.md +++ b/docs/models/components/loc.md @@ -1,5 +1,12 @@ # Loc +## Example Usage + +```typescript +import { Loc } from "@mistralai/mistralai/models/components"; + +let value: Loc = 592845; +``` ## Supported Types diff --git a/docs/models/components/messages.md b/docs/models/components/messages.md index b2462b3..0a25c1a 100644 --- a/docs/models/components/messages.md +++ b/docs/models/components/messages.md @@ -1,5 +1,18 @@ # Messages +## Example Usage + +```typescript +import { Messages } from "@mistralai/mistralai/models/components"; + +let value: Messages = { + content: [ + { + text: "", + }, + ], +}; +``` ## Supported Types diff --git a/docs/models/components/metricout.md b/docs/models/components/metricout.md index e052182..243e6fc 100644 --- a/docs/models/components/metricout.md +++ b/docs/models/components/metricout.md @@ -2,6 +2,13 @@ Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase). +## Example Usage + +```typescript +import { MetricOut } from "@mistralai/mistralai/models/components"; + +let value: MetricOut = {}; +``` ## Fields diff --git a/docs/models/components/modelcapabilities.md b/docs/models/components/modelcapabilities.md index a43f893..80dc937 100644 --- a/docs/models/components/modelcapabilities.md +++ b/docs/models/components/modelcapabilities.md @@ -1,5 +1,12 @@ # ModelCapabilities +## Example Usage + +```typescript +import { ModelCapabilities } from "@mistralai/mistralai/models/components"; + +let value: ModelCapabilities = {}; +``` ## Fields diff --git a/docs/models/components/modelcard.md b/docs/models/components/modelcard.md index 08dd4ac..401e367 100644 --- a/docs/models/components/modelcard.md +++ b/docs/models/components/modelcard.md @@ -1,5 +1,15 @@ # ModelCard +## Example Usage + +```typescript +import { ModelCard } from "@mistralai/mistralai/models/components"; + +let value: ModelCard = { + id: "", + capabilities: {}, +}; +``` ## Fields diff --git a/docs/models/components/modellist.md b/docs/models/components/modellist.md index f0cb04f..aa188c7 100644 --- a/docs/models/components/modellist.md +++ b/docs/models/components/modellist.md @@ -1,5 +1,12 @@ # ModelList +## Example Usage + +```typescript +import { ModelList } from "@mistralai/mistralai/models/components"; + +let value: ModelList = {}; +``` ## Fields diff --git a/docs/models/components/responseformat.md b/docs/models/components/responseformat.md index f2d1257..1e5a44c 100644 --- a/docs/models/components/responseformat.md +++ b/docs/models/components/responseformat.md @@ -1,5 +1,12 @@ # ResponseFormat +## Example Usage + +```typescript +import { ResponseFormat } from "@mistralai/mistralai/models/components"; + +let value: ResponseFormat = {}; +``` ## Fields diff --git a/docs/models/components/responseformats.md b/docs/models/components/responseformats.md index d2429dc..c13e204 100644 --- a/docs/models/components/responseformats.md +++ b/docs/models/components/responseformats.md @@ -2,10 +2,16 @@ An object specifying the format that the model must output. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. +## Example Usage + +```typescript +import { ResponseFormats } from "@mistralai/mistralai/models/components"; + +let value: ResponseFormats = "json_object"; +``` ## Values -| Name | Value | -| ------------ | ------------ | -| `Text` | text | -| `JsonObject` | json_object | \ No newline at end of file +```typescript +"text" | "json_object" +``` \ No newline at end of file diff --git a/docs/models/components/retrievefileout.md b/docs/models/components/retrievefileout.md index 74334d7..8086d23 100644 --- a/docs/models/components/retrievefileout.md +++ b/docs/models/components/retrievefileout.md @@ -1,5 +1,20 @@ # RetrieveFileOut +## Example Usage + +```typescript +import { RetrieveFileOut } from "@mistralai/mistralai/models/components"; + +let value: RetrieveFileOut = { + id: "497f6eca-6276-4993-bfeb-53cbbbba6f09", + object: "file", + bytes: 13000, + createdAt: 1716963433, + filename: "files_upload.jsonl", + sampleType: "pretrain", + source: "repository", +}; +``` ## Fields diff --git a/docs/models/components/role.md b/docs/models/components/role.md index 38d07ee..4682b64 100644 --- a/docs/models/components/role.md +++ b/docs/models/components/role.md @@ -1,8 +1,15 @@ # Role +## Example Usage + +```typescript +import { Role } from "@mistralai/mistralai/models/components"; + +let value: Role = "system"; +``` ## Values -| Name | Value | -| -------- | -------- | -| `System` | system | \ No newline at end of file +```typescript +"system" +``` \ No newline at end of file diff --git a/docs/models/components/sampletype.md b/docs/models/components/sampletype.md index d4514bd..1ba5400 100644 --- a/docs/models/components/sampletype.md +++ b/docs/models/components/sampletype.md @@ -1,9 +1,15 @@ # SampleType +## Example Usage + +```typescript +import { SampleType } from "@mistralai/mistralai/models/components"; + +let value: SampleType = "instruct"; +``` ## Values -| Name | Value | -| ---------- | ---------- | -| `Pretrain` | pretrain | -| `Instruct` | instruct | \ No newline at end of file +```typescript +"pretrain" | "instruct" +``` \ No newline at end of file diff --git a/docs/models/components/security.md b/docs/models/components/security.md index 217b33b..19ed4e2 100644 --- a/docs/models/components/security.md +++ b/docs/models/components/security.md @@ -1,5 +1,12 @@ # Security +## Example Usage + +```typescript +import { Security } from "@mistralai/mistralai/models/components"; + +let value: Security = {}; +``` ## Fields diff --git a/docs/models/components/source.md b/docs/models/components/source.md index 11c0b03..ac1c0db 100644 --- a/docs/models/components/source.md +++ b/docs/models/components/source.md @@ -1,9 +1,15 @@ # Source +## Example Usage + +```typescript +import { Source } from "@mistralai/mistralai/models/components"; + +let value: Source = "repository"; +``` ## Values -| Name | Value | -| ------------ | ------------ | -| `Upload` | upload | -| `Repository` | repository | \ No newline at end of file +```typescript +"upload" | "repository" +``` \ No newline at end of file diff --git a/docs/models/components/status.md b/docs/models/components/status.md index 229c8da..d4aa1bb 100644 --- a/docs/models/components/status.md +++ b/docs/models/components/status.md @@ -2,18 +2,16 @@ The current status of the fine-tuning job. +## Example Usage + +```typescript +import { Status } from "@mistralai/mistralai/models/components"; + +let value: Status = "FAILED"; +``` ## Values -| Name | Value | -| ----------------------- | ----------------------- | -| `Queued` | QUEUED | -| `Started` | STARTED | -| `Validating` | VALIDATING | -| `Validated` | VALIDATED | -| `Running` | RUNNING | -| `FailedValidation` | FAILED_VALIDATION | -| `Failed` | FAILED | -| `Success` | SUCCESS | -| `Cancelled` | CANCELLED | -| `CancellationRequested` | CANCELLATION_REQUESTED | \ No newline at end of file +```typescript +"QUEUED" | "STARTED" | "VALIDATING" | "VALIDATED" | "RUNNING" | "FAILED_VALIDATION" | "FAILED" | "SUCCESS" | "CANCELLED" | "CANCELLATION_REQUESTED" +``` \ No newline at end of file diff --git a/docs/models/components/stop.md b/docs/models/components/stop.md index a25543c..72119d9 100644 --- a/docs/models/components/stop.md +++ b/docs/models/components/stop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { Stop } from "@mistralai/mistralai/models/components"; + +let value: Stop = ""; +``` ## Supported Types diff --git a/docs/models/components/systemmessage.md b/docs/models/components/systemmessage.md index 37ee0ae..beb7f5c 100644 --- a/docs/models/components/systemmessage.md +++ b/docs/models/components/systemmessage.md @@ -1,5 +1,14 @@ # SystemMessage +## Example Usage + +```typescript +import { SystemMessage } from "@mistralai/mistralai/models/components"; + +let value: SystemMessage = { + content: "", +}; +``` ## Fields diff --git a/docs/models/components/textchunk.md b/docs/models/components/textchunk.md index b9426f2..2b421ba 100644 --- a/docs/models/components/textchunk.md +++ b/docs/models/components/textchunk.md @@ -1,5 +1,14 @@ # TextChunk +## Example Usage + +```typescript +import { TextChunk } from "@mistralai/mistralai/models/components"; + +let value: TextChunk = { + text: "", +}; +``` ## Fields diff --git a/docs/models/components/tool.md b/docs/models/components/tool.md index 5fe4a6c..53b0576 100644 --- a/docs/models/components/tool.md +++ b/docs/models/components/tool.md @@ -1,9 +1,23 @@ # Tool +## Example Usage + +```typescript +import { Tool } from "@mistralai/mistralai/models/components"; + +let value: Tool = { + function: { + name: "", + parameters: { + key: "", + }, + }, +}; +``` ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `type` | *string* | :heavy_minus_sign: | N/A | -| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `type` | [components.ToolToolTypes](../../models/components/tooltooltypes.md) | :heavy_minus_sign: | N/A | +| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/components/toolcall.md b/docs/models/components/toolcall.md index 2145c1b..3a9a1b0 100644 --- a/docs/models/components/toolcall.md +++ b/docs/models/components/toolcall.md @@ -1,10 +1,22 @@ # ToolCall +## Example Usage + +```typescript +import { ToolCall } from "@mistralai/mistralai/models/components"; + +let value: ToolCall = { + function: { + name: "", + arguments: "", + }, +}; +``` ## Fields | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `id` | *string* | :heavy_minus_sign: | N/A | -| `type` | *string* | :heavy_minus_sign: | N/A | +| `type` | [components.ToolTypes](../../models/components/tooltypes.md) | :heavy_minus_sign: | N/A | | `function` | [components.FunctionCall](../../models/components/functioncall.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/components/toolchoice.md b/docs/models/components/toolchoice.md index 54bc57c..4a8e188 100644 --- a/docs/models/components/toolchoice.md +++ b/docs/models/components/toolchoice.md @@ -1,10 +1,15 @@ # ToolChoice +## Example Usage + +```typescript +import { ToolChoice } from "@mistralai/mistralai/models/components"; + +let value: ToolChoice = "any"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/docs/models/components/toolmessage.md b/docs/models/components/toolmessage.md index e8135ba..f250b4b 100644 --- a/docs/models/components/toolmessage.md +++ b/docs/models/components/toolmessage.md @@ -1,5 +1,14 @@ # ToolMessage +## Example Usage + +```typescript +import { ToolMessage } from "@mistralai/mistralai/models/components"; + +let value: ToolMessage = { + content: "", +}; +``` ## Fields diff --git a/docs/models/components/toolmessagerole.md b/docs/models/components/toolmessagerole.md index f4fd3c6..1d38904 100644 --- a/docs/models/components/toolmessagerole.md +++ b/docs/models/components/toolmessagerole.md @@ -1,8 +1,15 @@ # ToolMessageRole +## Example Usage + +```typescript +import { ToolMessageRole } from "@mistralai/mistralai/models/components"; + +let value: ToolMessageRole = "tool"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Tool` | tool | \ No newline at end of file +```typescript +"tool" +``` \ No newline at end of file diff --git a/docs/models/components/tooltooltypes.md b/docs/models/components/tooltooltypes.md new file mode 100644 index 0000000..8edb07e --- /dev/null +++ b/docs/models/components/tooltooltypes.md @@ -0,0 +1,17 @@ +# ToolToolTypes + +## Example Usage + +```typescript +import { ToolToolTypes } from "@mistralai/mistralai/models/components"; + +let value: ToolToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/components/tooltypes.md b/docs/models/components/tooltypes.md new file mode 100644 index 0000000..a452b16 --- /dev/null +++ b/docs/models/components/tooltypes.md @@ -0,0 +1,17 @@ +# ToolTypes + +## Example Usage + +```typescript +import { ToolTypes } from "@mistralai/mistralai/models/components"; + +let value: ToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/components/trainingfile.md b/docs/models/components/trainingfile.md index ee7c04b..9786e8e 100644 --- a/docs/models/components/trainingfile.md +++ b/docs/models/components/trainingfile.md @@ -1,5 +1,14 @@ # TrainingFile +## Example Usage + +```typescript +import { TrainingFile } from "@mistralai/mistralai/models/components"; + +let value: TrainingFile = { + fileId: "7739251a-a52c-43f5-ad01-9da1ffe78f09", +}; +``` ## Fields diff --git a/docs/models/components/trainingparameters.md b/docs/models/components/trainingparameters.md index 536d1ba..7c415e1 100644 --- a/docs/models/components/trainingparameters.md +++ b/docs/models/components/trainingparameters.md @@ -1,5 +1,12 @@ # TrainingParameters +## Example Usage + +```typescript +import { TrainingParameters } from "@mistralai/mistralai/models/components"; + +let value: TrainingParameters = {}; +``` ## Fields diff --git a/docs/models/components/trainingparametersin.md b/docs/models/components/trainingparametersin.md index 4c4dffc..46a3e59 100644 --- a/docs/models/components/trainingparametersin.md +++ b/docs/models/components/trainingparametersin.md @@ -2,6 +2,13 @@ The fine-tuning hyperparameter settings used in a fine-tune job. +## Example Usage + +```typescript +import { TrainingParametersIn } from "@mistralai/mistralai/models/components"; + +let value: TrainingParametersIn = {}; +``` ## Fields diff --git a/docs/models/components/unarchiveftmodelout.md b/docs/models/components/unarchiveftmodelout.md index 2880d55..c7c0bc3 100644 --- a/docs/models/components/unarchiveftmodelout.md +++ b/docs/models/components/unarchiveftmodelout.md @@ -1,5 +1,14 @@ # UnarchiveFTModelOut +## Example Usage + +```typescript +import { UnarchiveFTModelOut } from "@mistralai/mistralai/models/components"; + +let value: UnarchiveFTModelOut = { + id: "", +}; +``` ## Fields diff --git a/docs/models/components/updateftmodelin.md b/docs/models/components/updateftmodelin.md index fa96a6b..be18c6e 100644 --- a/docs/models/components/updateftmodelin.md +++ b/docs/models/components/updateftmodelin.md @@ -1,5 +1,12 @@ # UpdateFTModelIn +## Example Usage + +```typescript +import { UpdateFTModelIn } from "@mistralai/mistralai/models/components"; + +let value: UpdateFTModelIn = {}; +``` ## Fields diff --git a/docs/models/components/uploadfileout.md b/docs/models/components/uploadfileout.md index b6a7e4b..0879551 100644 --- a/docs/models/components/uploadfileout.md +++ b/docs/models/components/uploadfileout.md @@ -1,5 +1,20 @@ # UploadFileOut +## Example Usage + +```typescript +import { UploadFileOut } from "@mistralai/mistralai/models/components"; + +let value: UploadFileOut = { + id: "497f6eca-6276-4993-bfeb-53cbbbba6f09", + object: "file", + bytes: 13000, + createdAt: 1716963433, + filename: "files_upload.jsonl", + sampleType: "instruct", + source: "upload", +}; +``` ## Fields diff --git a/docs/models/components/usageinfo.md b/docs/models/components/usageinfo.md index b317b51..e8fa0f4 100644 --- a/docs/models/components/usageinfo.md +++ b/docs/models/components/usageinfo.md @@ -1,5 +1,16 @@ # UsageInfo +## Example Usage + +```typescript +import { UsageInfo } from "@mistralai/mistralai/models/components"; + +let value: UsageInfo = { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, +}; +``` ## Fields diff --git a/docs/models/components/usermessage.md b/docs/models/components/usermessage.md index 1e06816..6451d7e 100644 --- a/docs/models/components/usermessage.md +++ b/docs/models/components/usermessage.md @@ -1,5 +1,18 @@ # UserMessage +## Example Usage + +```typescript +import { UserMessage } from "@mistralai/mistralai/models/components"; + +let value: UserMessage = { + content: [ + { + text: "", + }, + ], +}; +``` ## Fields diff --git a/docs/models/components/usermessagecontent.md b/docs/models/components/usermessagecontent.md index 2d9bd3f..919d5ed 100644 --- a/docs/models/components/usermessagecontent.md +++ b/docs/models/components/usermessagecontent.md @@ -1,5 +1,16 @@ # UserMessageContent +## Example Usage + +```typescript +import { UserMessageContent } from "@mistralai/mistralai/models/components"; + +let value: UserMessageContent = [ + { + text: "", + }, +]; +``` ## Supported Types diff --git a/docs/models/components/usermessagerole.md b/docs/models/components/usermessagerole.md index 30a5286..df3b831 100644 --- a/docs/models/components/usermessagerole.md +++ b/docs/models/components/usermessagerole.md @@ -1,8 +1,15 @@ # UserMessageRole +## Example Usage + +```typescript +import { UserMessageRole } from "@mistralai/mistralai/models/components"; + +let value: UserMessageRole = "user"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `User` | user | \ No newline at end of file +```typescript +"user" +``` \ No newline at end of file diff --git a/docs/models/components/validationerror.md b/docs/models/components/validationerror.md index 865d485..1ef0a26 100644 --- a/docs/models/components/validationerror.md +++ b/docs/models/components/validationerror.md @@ -1,5 +1,16 @@ # ValidationError +## Example Usage + +```typescript +import { ValidationError } from "@mistralai/mistralai/models/components"; + +let value: ValidationError = { + loc: [844266], + msg: "", + type: "", +}; +``` ## Fields diff --git a/docs/models/components/wandbintegration.md b/docs/models/components/wandbintegration.md index b2cd762..b0b3084 100644 --- a/docs/models/components/wandbintegration.md +++ b/docs/models/components/wandbintegration.md @@ -1,5 +1,15 @@ # WandbIntegration +## Example Usage + +```typescript +import { WandbIntegration } from "@mistralai/mistralai/models/components"; + +let value: WandbIntegration = { + project: "", + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/components/wandbintegrationout.md b/docs/models/components/wandbintegrationout.md index b6a024d..a58d780 100644 --- a/docs/models/components/wandbintegrationout.md +++ b/docs/models/components/wandbintegrationout.md @@ -1,5 +1,14 @@ # WandbIntegrationOut +## Example Usage + +```typescript +import { WandbIntegrationOut } from "@mistralai/mistralai/models/components"; + +let value: WandbIntegrationOut = { + project: "", +}; +``` ## Fields diff --git a/docs/models/errors/httpvalidationerror.md b/docs/models/errors/httpvalidationerror.md index 50ca4db..2878a4f 100644 --- a/docs/models/errors/httpvalidationerror.md +++ b/docs/models/errors/httpvalidationerror.md @@ -2,6 +2,13 @@ Validation Error +## Example Usage + +```typescript +import { HTTPValidationError } from "@mistralai/mistralai/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/docs/models/operations/deletemodelv1modelsmodeliddeleterequest.md b/docs/models/operations/deletemodelv1modelsmodeliddeleterequest.md index c0242d8..bc190af 100644 --- a/docs/models/operations/deletemodelv1modelsmodeliddeleterequest.md +++ b/docs/models/operations/deletemodelv1modelsmodeliddeleterequest.md @@ -1,5 +1,14 @@ # DeleteModelV1ModelsModelIdDeleteRequest +## Example Usage + +```typescript +import { DeleteModelV1ModelsModelIdDeleteRequest } from "@mistralai/mistralai/models/operations"; + +let value: DeleteModelV1ModelsModelIdDeleteRequest = { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", +}; +``` ## Fields diff --git a/docs/models/operations/filesapiroutesdeletefilerequest.md b/docs/models/operations/filesapiroutesdeletefilerequest.md index b5b75fb..64a9291 100644 --- a/docs/models/operations/filesapiroutesdeletefilerequest.md +++ b/docs/models/operations/filesapiroutesdeletefilerequest.md @@ -1,5 +1,14 @@ # FilesApiRoutesDeleteFileRequest +## Example Usage + +```typescript +import { FilesApiRoutesDeleteFileRequest } from "@mistralai/mistralai/models/operations"; + +let value: FilesApiRoutesDeleteFileRequest = { + fileId: "", +}; +``` ## Fields diff --git a/docs/models/operations/filesapiroutesretrievefilerequest.md b/docs/models/operations/filesapiroutesretrievefilerequest.md index 772f224..003b2c9 100644 --- a/docs/models/operations/filesapiroutesretrievefilerequest.md +++ b/docs/models/operations/filesapiroutesretrievefilerequest.md @@ -1,5 +1,14 @@ # FilesApiRoutesRetrieveFileRequest +## Example Usage + +```typescript +import { FilesApiRoutesRetrieveFileRequest } from "@mistralai/mistralai/models/operations"; + +let value: FilesApiRoutesRetrieveFileRequest = { + fileId: "", +}; +``` ## Fields diff --git a/docs/models/operations/filesapiroutesuploadfilemultipartbodyparams.md b/docs/models/operations/filesapiroutesuploadfilemultipartbodyparams.md index fa84115..edf3901 100644 --- a/docs/models/operations/filesapiroutesuploadfilemultipartbodyparams.md +++ b/docs/models/operations/filesapiroutesuploadfilemultipartbodyparams.md @@ -1,5 +1,15 @@ # FilesApiRoutesUploadFileMultiPartBodyParams +## Example Usage + +```typescript +import { FilesApiRoutesUploadFileMultiPartBodyParams } from "@mistralai/mistralai/models/operations"; +import { openAsBlob } from "node:fs"; + +let value: FilesApiRoutesUploadFileMultiPartBodyParams = { + file: await openAsBlob("./sample-file"), +}; +``` ## Fields diff --git a/docs/models/operations/filet.md b/docs/models/operations/filet.md index 72990e9..a197aeb 100644 --- a/docs/models/operations/filet.md +++ b/docs/models/operations/filet.md @@ -1,5 +1,15 @@ # FileT +## Example Usage + +```typescript +import { FileT } from "@mistralai/mistralai/models/operations"; + +let value: FileT = { + fileName: "your_file_here", + content: new TextEncoder().encode("0xa6fe668dA9"), +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningarchivefinetunedmodelrequest.md b/docs/models/operations/jobsapiroutesfinetuningarchivefinetunedmodelrequest.md index d58af19..1a2d650 100644 --- a/docs/models/operations/jobsapiroutesfinetuningarchivefinetunedmodelrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuningarchivefinetunedmodelrequest.md @@ -1,5 +1,14 @@ # JobsApiRoutesFineTuningArchiveFineTunedModelRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningArchiveFineTunedModelRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningArchiveFineTunedModelRequest = { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningcancelfinetuningjobrequest.md b/docs/models/operations/jobsapiroutesfinetuningcancelfinetuningjobrequest.md index 308cc7b..0faf301 100644 --- a/docs/models/operations/jobsapiroutesfinetuningcancelfinetuningjobrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuningcancelfinetuningjobrequest.md @@ -1,5 +1,14 @@ # JobsApiRoutesFineTuningCancelFineTuningJobRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningCancelFineTuningJobRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningCancelFineTuningJobRequest = { + jobId: "909b3fe4-9a8d-49cb-b486-33323f9b77f3", +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningcreatefinetuningjobresponse.md b/docs/models/operations/jobsapiroutesfinetuningcreatefinetuningjobresponse.md index 9900da7..3bbb0ad 100644 --- a/docs/models/operations/jobsapiroutesfinetuningcreatefinetuningjobresponse.md +++ b/docs/models/operations/jobsapiroutesfinetuningcreatefinetuningjobresponse.md @@ -2,6 +2,23 @@ OK +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningCreateFineTuningJobResponse } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningCreateFineTuningJobResponse = { + id: "14195989-0afa-4563-a251-6fe4c8b711e5", + autoStart: false, + hyperparameters: {}, + model: "mistral-large-latest", + status: "RUNNING", + jobType: "", + createdAt: 998848, + modifiedAt: 841140, + trainingFiles: ["2ed02892-1cdd-4c69-a601-fb576b0d5f0d"], +}; +``` ## Supported Types diff --git a/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobrequest.md b/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobrequest.md index 004c149..1259bd6 100644 --- a/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobrequest.md @@ -1,5 +1,14 @@ # JobsApiRoutesFineTuningGetFineTuningJobRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningGetFineTuningJobRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningGetFineTuningJobRequest = { + jobId: "30c5fbb2-5870-4532-82c7-3d5fe9b90c28", +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobsrequest.md b/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobsrequest.md index 0baabc5..80c82fc 100644 --- a/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobsrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuninggetfinetuningjobsrequest.md @@ -1,5 +1,12 @@ # JobsApiRoutesFineTuningGetFineTuningJobsRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningGetFineTuningJobsRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningGetFineTuningJobsRequest = {}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningstartfinetuningjobrequest.md b/docs/models/operations/jobsapiroutesfinetuningstartfinetuningjobrequest.md index 9c3610b..f21e484 100644 --- a/docs/models/operations/jobsapiroutesfinetuningstartfinetuningjobrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuningstartfinetuningjobrequest.md @@ -1,5 +1,14 @@ # JobsApiRoutesFineTuningStartFineTuningJobRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningStartFineTuningJobRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningStartFineTuningJobRequest = { + jobId: "a4100674-ebf6-4928-8d1b-a77a89ebf737", +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningunarchivefinetunedmodelrequest.md b/docs/models/operations/jobsapiroutesfinetuningunarchivefinetunedmodelrequest.md index 7e79b3f..96c50bb 100644 --- a/docs/models/operations/jobsapiroutesfinetuningunarchivefinetunedmodelrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuningunarchivefinetunedmodelrequest.md @@ -1,5 +1,14 @@ # JobsApiRoutesFineTuningUnarchiveFineTunedModelRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningUnarchiveFineTunedModelRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningUnarchiveFineTunedModelRequest = { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", +}; +``` ## Fields diff --git a/docs/models/operations/jobsapiroutesfinetuningupdatefinetunedmodelrequest.md b/docs/models/operations/jobsapiroutesfinetuningupdatefinetunedmodelrequest.md index 03e9ba9..e36021e 100644 --- a/docs/models/operations/jobsapiroutesfinetuningupdatefinetunedmodelrequest.md +++ b/docs/models/operations/jobsapiroutesfinetuningupdatefinetunedmodelrequest.md @@ -1,5 +1,15 @@ # JobsApiRoutesFineTuningUpdateFineTunedModelRequest +## Example Usage + +```typescript +import { JobsApiRoutesFineTuningUpdateFineTunedModelRequest } from "@mistralai/mistralai/models/operations"; + +let value: JobsApiRoutesFineTuningUpdateFineTunedModelRequest = { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + updateFTModelIn: {}, +}; +``` ## Fields diff --git a/docs/models/operations/retrievemodelv1modelsmodelidgetrequest.md b/docs/models/operations/retrievemodelv1modelsmodelidgetrequest.md index 5b2f279..47afb4f 100644 --- a/docs/models/operations/retrievemodelv1modelsmodelidgetrequest.md +++ b/docs/models/operations/retrievemodelv1modelsmodelidgetrequest.md @@ -1,5 +1,14 @@ # RetrieveModelV1ModelsModelIdGetRequest +## Example Usage + +```typescript +import { RetrieveModelV1ModelsModelIdGetRequest } from "@mistralai/mistralai/models/operations"; + +let value: RetrieveModelV1ModelsModelIdGetRequest = { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", +}; +``` ## Fields diff --git a/docs/models/operations/status.md b/docs/models/operations/status.md index 7e24f2e..a431ee2 100644 --- a/docs/models/operations/status.md +++ b/docs/models/operations/status.md @@ -2,18 +2,16 @@ The current job state to filter on. When set, the other results are not displayed. +## Example Usage + +```typescript +import { Status } from "@mistralai/mistralai/models/operations"; + +let value: Status = "CANCELLED"; +``` ## Values -| Name | Value | -| ----------------------- | ----------------------- | -| `Queued` | QUEUED | -| `Started` | STARTED | -| `Validating` | VALIDATING | -| `Validated` | VALIDATED | -| `Running` | RUNNING | -| `FailedValidation` | FAILED_VALIDATION | -| `Failed` | FAILED | -| `Success` | SUCCESS | -| `Cancelled` | CANCELLED | -| `CancellationRequested` | CANCELLATION_REQUESTED | \ No newline at end of file +```typescript +"QUEUED" | "STARTED" | "VALIDATING" | "VALIDATED" | "RUNNING" | "FAILED_VALIDATION" | "FAILED" | "SUCCESS" | "CANCELLED" | "CANCELLATION_REQUESTED" +``` \ No newline at end of file diff --git a/docs/sdks/agents/README.md b/docs/sdks/agents/README.md index a8d0dab..5426c4c 100644 --- a/docs/sdks/agents/README.md +++ b/docs/sdks/agents/README.md @@ -41,6 +41,45 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { agentsComplete } from "@mistralai/mistralai/funcs/agentsComplete.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await agentsComplete(mistral, { + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + agentId: "", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -76,11 +115,55 @@ const mistral = new Mistral({ async function run() { const result = await mistral.agents.stream({ - model: "codestral-2405", - prompt: "def", - suffix: "return a+b", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + agentId: "", + }); + + for await (const event of result) { + // Handle the event + } +} + +run(); +``` + + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { agentsStream } from "@mistralai/mistralai/funcs/agentsStream.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await agentsStream(mistral, { + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + agentId: "", }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + for await (const event of result) { // Handle the event } diff --git a/docs/sdks/chat/README.md b/docs/sdks/chat/README.md index e0c408b..fa56aa0 100644 --- a/docs/sdks/chat/README.md +++ b/docs/sdks/chat/README.md @@ -41,6 +41,45 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { chatComplete } from "@mistralai/mistralai/funcs/chatComplete.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await chatComplete(mistral, { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -93,6 +132,46 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { chatStream } from "@mistralai/mistralai/funcs/chatStream.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await chatStream(mistral, { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + for await (const event of result) { + // Handle the event + } +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/docs/sdks/embeddings/README.md b/docs/sdks/embeddings/README.md index 4d41a25..f311604 100644 --- a/docs/sdks/embeddings/README.md +++ b/docs/sdks/embeddings/README.md @@ -35,6 +35,40 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { embeddingsCreate } from "@mistralai/mistralai/funcs/embeddingsCreate.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await embeddingsCreate(mistral, { + inputs: "", + model: "El Camino", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/docs/sdks/files/README.md b/docs/sdks/files/README.md index f743b49..9662cfc 100644 --- a/docs/sdks/files/README.md +++ b/docs/sdks/files/README.md @@ -42,6 +42,40 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { filesUpload } from "@mistralai/mistralai/funcs/filesUpload.js"; +import { openAsBlob } from "node:fs"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await filesUpload(mistral, { + file: await openAsBlob("./sample-file"), + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -84,6 +118,37 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { filesList } from "@mistralai/mistralai/funcs/filesList.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await filesList(mistral); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -127,6 +192,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { filesRetrieve } from "@mistralai/mistralai/funcs/filesRetrieve.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await filesRetrieve(mistral, { + fileId: "", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -171,6 +269,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { filesDelete } from "@mistralai/mistralai/funcs/filesDelete.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await filesDelete(mistral, { + fileId: "", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/docs/sdks/fim/README.md b/docs/sdks/fim/README.md index 83c9cc1..41d2b65 100644 --- a/docs/sdks/fim/README.md +++ b/docs/sdks/fim/README.md @@ -37,6 +37,41 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fimComplete } from "@mistralai/mistralai/funcs/fimComplete.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fimComplete(mistral, { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -85,6 +120,42 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fimStream } from "@mistralai/mistralai/funcs/fimStream.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fimStream(mistral, { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + for await (const event of result) { + // Handle the event + } +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/docs/sdks/jobs/README.md b/docs/sdks/jobs/README.md index baa341f..8fae358 100644 --- a/docs/sdks/jobs/README.md +++ b/docs/sdks/jobs/README.md @@ -32,6 +32,37 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fineTuningJobsList } from "@mistralai/mistralai/funcs/fineTuningJobsList.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fineTuningJobsList(mistral, {}); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -77,6 +108,40 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fineTuningJobsCreate } from "@mistralai/mistralai/funcs/fineTuningJobsCreate.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fineTuningJobsCreate(mistral, { + model: "mistral-large-latest", + hyperparameters: {}, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -121,6 +186,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fineTuningJobsGet } from "@mistralai/mistralai/funcs/fineTuningJobsGet.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fineTuningJobsGet(mistral, { + jobId: "ed5f0cf0-7c66-4222-8821-0d5a28144bbc", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -165,6 +263,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fineTuningJobsCancel } from "@mistralai/mistralai/funcs/fineTuningJobsCancel.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fineTuningJobsCancel(mistral, { + jobId: "dc5409f0-bbe9-449e-837e-33a2d6618375", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -209,6 +340,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { fineTuningJobsStart } from "@mistralai/mistralai/funcs/fineTuningJobsStart.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await fineTuningJobsStart(mistral, { + jobId: "b662786a-f8e8-4548-822c-b4a778d30ec3", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/docs/sdks/models/README.md b/docs/sdks/models/README.md index 990638d..6ddb547 100644 --- a/docs/sdks/models/README.md +++ b/docs/sdks/models/README.md @@ -37,6 +37,37 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsList } from "@mistralai/mistralai/funcs/modelsList.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsList(mistral); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -81,6 +112,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsRetrieve } from "@mistralai/mistralai/funcs/modelsRetrieve.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsRetrieve(mistral, { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -126,6 +190,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsDelete } from "@mistralai/mistralai/funcs/modelsDelete.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsDelete(mistral, { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -172,6 +269,40 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsUpdate } from "@mistralai/mistralai/funcs/modelsUpdate.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsUpdate(mistral, { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + updateFTModelIn: {}, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -216,6 +347,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsArchive } from "@mistralai/mistralai/funcs/modelsArchive.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsArchive(mistral, { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -260,6 +424,39 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { MistralCore } from "@mistralai/mistralai/core.js"; +import { modelsUnarchive } from "@mistralai/mistralai/funcs/modelsUnarchive.js"; + +// Use `MistralCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistral = new MistralCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await modelsUnarchive(mistral, { + modelId: "ft:open-mistral-7b:587a6b29:20240514:7e773925", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/examples/package-lock.json b/examples/package-lock.json index 067fb61..62ed46b 100644 --- a/examples/package-lock.json +++ b/examples/package-lock.json @@ -22,7 +22,7 @@ }, "..": { "name": "@mistralai/mistralai", - "version": "1.0.0-rc.8", + "version": "1.0.2", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", @@ -97,7 +97,7 @@ }, "../packages/mistralai-azure": { "name": "@mistralai/mistralai-azure", - "version": "1.0.0-rc.8", + "version": "1.0.2", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", @@ -113,7 +113,7 @@ }, "../packages/mistralai-gcp": { "name": "@mistralai/mistralai-gcp", - "version": "1.0.0-rc.8", + "version": "1.0.2", "dependencies": { "google-auth-library": "^9.11.0" }, diff --git a/examples/src/async_function_calling_streaming.ts b/examples/src/async_function_calling_streaming.ts new file mode 100644 index 0000000..f7f8db7 --- /dev/null +++ b/examples/src/async_function_calling_streaming.ts @@ -0,0 +1,178 @@ +import { Mistral } from "@mistralai/mistralai"; +import { UserMessage } from "@mistralai/mistralai/models/components/usermessage.js"; + +const apiKey = process.env["MISTRAL_API_KEY"]; +if (!apiKey) { + throw new Error("missing MISTRAL_API_KEY environment variable"); +} + +// Assuming we have the following data +const data = { + transactionId: ["T1001", "T1002", "T1003", "T1004", "T1005"], + customerId: ["C001", "C002", "C003", "C002", "C001"], + paymentAmount: [125.5, 89.99, 120.0, 54.3, 210.2], + paymentDate: [ + "2021-10-05", + "2021-10-06", + "2021-10-07", + "2021-10-05", + "2021-10-08", + ], + paymentStatus: ["Paid", "Unpaid", "Paid", "Paid", "Pending"], +}; + +/** + * This function retrieves the payment status of a transaction id. + * @param {object} data - The data object. + * @param {string} transactionId - The transaction id. + * @return {string} - The payment status. + */ +function retrievePaymentStatus({ data, transactionId }) { + const transactionIndex = data.transactionId.indexOf(transactionId); + if (transactionIndex != -1) { + return JSON.stringify({ status: data.paymentStatus[transactionIndex] }); + } else { + return JSON.stringify({ status: "error - transaction id not found." }); + } +} + +/** + * This function retrieves the payment date of a transaction id. + * @param {object} data - The data object. + * @param {string} transactionId - The transaction id. + * @return {string} - The payment date. + * + */ +function retrievePaymentDate({ data, transactionId }) { + const transactionIndex = data.transactionId.indexOf(transactionId); + if (transactionIndex != -1) { + return JSON.stringify({ status: data.paymentDate[transactionIndex] }); + } else { + return JSON.stringify({ status: "error - transaction id not found." }); + } +} + +const namesToFunctions = { + retrievePaymentStatus: (transactionId) => + retrievePaymentStatus({ data, ...transactionId }), + retrievePaymentDate: (transactionId) => + retrievePaymentDate({ data, ...transactionId }), +}; + +const tools = [ + { + type: "function", + function: { + name: "retrievePaymentStatus", + description: "Get payment status of a transaction id", + parameters: { + type: "object", + required: ["transactionId"], + properties: { + transactionId: { type: "string", description: "The transaction id." }, + }, + }, + }, + }, + { + type: "function", + function: { + name: "retrievePaymentDate", + description: "Get payment date of a transaction id", + parameters: { + type: "object", + required: ["transactionId"], + properties: { + transactionId: { type: "string", description: "The transaction id." }, + }, + }, + }, + }, +]; + +const model = "mistral-large-latest"; + +const client = new Mistral({ apiKey: apiKey }); + +const messages = [ + { role: "user", content: "What's the status of my transaction?" }, +]; + +let stream = await client.chat.stream({ + model: model, + messages: messages, + tools: tools, +}); + +let full_content = ""; +for await (const event of stream) { + const content = event.data?.choices[0]?.delta.content; + if (!content) { + continue; + } + + full_content += content; + + process.stdout.write(content); +} +messages.push({ + role: "assistant", + content: full_content, +}); + +messages.push({ role: "user", content: "My transaction ID is T1001." }); + +stream = await client.chat.stream({ + model: model, + messages: messages, + tools: tools, +}); + +full_content = ""; +for await (const event of stream) { + const content = event.data?.choices[0]?.delta.content; + if (!content) { + continue; + } + + full_content += content; + + process.stdout.write(content); +} + +messages.push(response.choices[0].message); + +const toolCalls = response.choices[0].message.toolCalls; +for (const toolCall of toolCalls) { + const functionName = toolCall.function.name; + const functionParams = JSON.parse(toolCall.function.arguments); + + console.log(`calling functionName: ${functionName}`); + console.log(`functionParams: ${toolCall.function.arguments}`); + const functionResult = namesToFunctions[functionName](functionParams); + + messages.push({ + role: "tool", + name: functionName, + content: functionResult, + tool_call_id: toolCall.id, + }); +} +console.log(messages); +console.log(tools); + +stream = await client.chat.stream({ + model: model, + messages: messages, + tools: tools, +}); + +for await (const event of stream) { + const content = event.data?.choices[0]?.delta.content; + if (!content) { + continue; + } + + + process.stdout.write(content); +} \ No newline at end of file diff --git a/jsr.json b/jsr.json index fbc0c6b..b4df6c2 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@mistralai/mistralai", - "version": "1.0.2", + "version": "1.1.2", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 1c691ac..53deb10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mistralai/mistralai", - "version": "1.0.2", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mistralai/mistralai", - "version": "1.0.2", + "version": "1.1.2", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/package.json b/package.json index acb0596..44778c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mistralai/mistralai", - "version": "1.0.2", + "version": "1.1.2", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, diff --git a/packages/mistralai-azure/.speakeasy/gen.lock b/packages/mistralai-azure/.speakeasy/gen.lock index 4ad95dc..d2c3845 100644 --- a/packages/mistralai-azure/.speakeasy/gen.lock +++ b/packages/mistralai-azure/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 01e8a40b-3df3-4d9a-9501-2eb9e0d26c05 management: - docChecksum: ec02d5407fd9354b416518c4b8fa8b95 + docChecksum: 0f6edfd8ad8df6c49b3d429d1af7b9e2 docVersion: 0.0.2 - speakeasyVersion: 1.357.4 - generationVersion: 2.390.6 - releaseVersion: 1.0.2 - configChecksum: fae80dd47df6ce21420df46abe574d77 + speakeasyVersion: 1.372.0 + generationVersion: 2.399.0 + releaseVersion: 1.1.1 + configChecksum: 1f81ca42be4e26105da0dd6f61c4eee5 repoURL: https://github.com/mistralai/client-ts.git repoSubDirectory: packages/mistralai-azure installationURL: https://gitpkg.now.sh/mistralai/client-ts/packages/mistralai-azure @@ -14,8 +14,8 @@ management: features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.6 - core: 3.12.3 + constsAndDefaults: 0.1.8 + core: 3.13.2 defaultEnabledRetries: 0.1.0 envVarSecurityUsage: 0.1.1 examples: 2.81.4 @@ -25,19 +25,21 @@ features: globalServerURLs: 2.82.4 nameOverrides: 2.81.2 nullables: 0.1.0 + openEnums: 0.1.1 responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 serverEvents: 0.1.4 serverEventsSentinels: 0.1.0 serverIDs: 2.81.2 - unions: 2.85.6 + unions: 2.85.7 generatedFiles: - src/funcs/chatStream.ts - src/funcs/chatComplete.ts - src/sdk/chat.ts - .eslintrc.cjs - .npmignore + - FUNCTIONS.md - RUNTIMES.md - jsr.json - package.json @@ -51,6 +53,7 @@ generatedFiles: - src/lib/event-streams.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts - src/lib/matchers.ts - src/lib/primitives.ts - src/lib/retries.ts @@ -63,6 +66,7 @@ generatedFiles: - src/models/errors/sdkerror.ts - src/models/errors/sdkvalidationerror.ts - src/types/blobs.ts + - src/types/constdatetime.ts - src/types/enums.ts - src/types/fp.ts - src/types/index.ts @@ -99,6 +103,7 @@ generatedFiles: - docs/models/components/finishreason.md - docs/models/components/completionresponsestreamchoice.md - docs/models/components/deltamessage.md + - docs/models/components/tooltypes.md - docs/models/components/toolcall.md - docs/models/components/arguments.md - docs/models/components/functioncall.md @@ -109,6 +114,7 @@ generatedFiles: - docs/models/components/messages.md - docs/models/components/toolchoice.md - docs/models/components/chatcompletionstreamrequest.md + - docs/models/components/tooltooltypes.md - docs/models/components/tool.md - docs/models/components/functiont.md - docs/models/components/responseformats.md diff --git a/packages/mistralai-azure/.speakeasy/gen.yaml b/packages/mistralai-azure/.speakeasy/gen.yaml index c173fe7..a5a0554 100644 --- a/packages/mistralai-azure/.speakeasy/gen.yaml +++ b/packages/mistralai-azure/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 1.0.2 + version: 1.1.1 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/packages/mistralai-azure/FUNCTIONS.md b/packages/mistralai-azure/FUNCTIONS.md new file mode 100644 index 0000000..2a14359 --- /dev/null +++ b/packages/mistralai-azure/FUNCTIONS.md @@ -0,0 +1,112 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { MistralAzureCore } from "@mistralai/mistralai-azure/core.js"; +import { chatComplete } from "@mistralai/mistralai-azure/funcs/chatComplete.js"; +import { SDKValidationError } from "@mistralai/mistralai-azure/models/errors/sdkvalidationerror.js"; + +// Use `MistralAzureCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistralAzure = new MistralAzureCore({ + apiKey: process.env["MISTRAL_API_KEY"] ?? "", +}); + +async function run() { + const res = await chatComplete(mistralAzure, { + model: "azureai", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + }); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/arguments.md b/packages/mistralai-azure/docs/models/components/arguments.md index aacbc0b..05b063c 100644 --- a/packages/mistralai-azure/docs/models/components/arguments.md +++ b/packages/mistralai-azure/docs/models/components/arguments.md @@ -1,5 +1,12 @@ # Arguments +## Example Usage + +```typescript +import { Arguments } from "@mistralai/mistralai-azure/models/components"; + +let value: Arguments = ""; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/assistantmessage.md b/packages/mistralai-azure/docs/models/components/assistantmessage.md index 37c243d..84d270e 100644 --- a/packages/mistralai-azure/docs/models/components/assistantmessage.md +++ b/packages/mistralai-azure/docs/models/components/assistantmessage.md @@ -1,5 +1,12 @@ # AssistantMessage +## Example Usage + +```typescript +import { AssistantMessage } from "@mistralai/mistralai-azure/models/components"; + +let value: AssistantMessage = {}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/assistantmessagerole.md b/packages/mistralai-azure/docs/models/components/assistantmessagerole.md index 781c8a5..f23f2e7 100644 --- a/packages/mistralai-azure/docs/models/components/assistantmessagerole.md +++ b/packages/mistralai-azure/docs/models/components/assistantmessagerole.md @@ -1,8 +1,15 @@ # AssistantMessageRole +## Example Usage + +```typescript +import { AssistantMessageRole } from "@mistralai/mistralai-azure/models/components"; + +let value: AssistantMessageRole = "assistant"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Assistant` | assistant | \ No newline at end of file +```typescript +"assistant" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionchoice.md b/packages/mistralai-azure/docs/models/components/chatcompletionchoice.md index be99bf0..fa3bff0 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionchoice.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionchoice.md @@ -1,10 +1,21 @@ # ChatCompletionChoice +## Example Usage + +```typescript +import { ChatCompletionChoice } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionChoice = { + index: 0, + message: {}, + finishReason: "stop", +}; +``` ## Fields | Field | Type | Required | Description | Example | | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | `index` | *number* | :heavy_check_mark: | N/A | 0 | -| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_minus_sign: | N/A | | +| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_check_mark: | N/A | | | `finishReason` | [components.ChatCompletionChoiceFinishReason](../../models/components/chatcompletionchoicefinishreason.md) | :heavy_check_mark: | N/A | stop | \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionchoicefinishreason.md b/packages/mistralai-azure/docs/models/components/chatcompletionchoicefinishreason.md index 7e3e05b..ab9f183 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionchoicefinishreason.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionchoicefinishreason.md @@ -1,12 +1,15 @@ # ChatCompletionChoiceFinishReason +## Example Usage + +```typescript +import { ChatCompletionChoiceFinishReason } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionChoiceFinishReason = "stop"; +``` ## Values -| Name | Value | -| ------------- | ------------- | -| `Stop` | stop | -| `Length` | length | -| `ModelLength` | model_length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "model_length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionrequest.md b/packages/mistralai-azure/docs/models/components/chatcompletionrequest.md index 2fc101f..8de749d 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionrequest.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionrequest.md @@ -1,5 +1,20 @@ # ChatCompletionRequest +## Example Usage + +```typescript +import { ChatCompletionRequest } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionRequest = { + model: "azureai", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | 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. | | | `stop` | *components.ChatCompletionRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.ChatCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.ChatCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ChatCompletionRequestToolChoice](../../models/components/chatcompletionrequesttoolchoice.md) | :heavy_minus_sign: | N/A | | diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionrequestmessages.md b/packages/mistralai-azure/docs/models/components/chatcompletionrequestmessages.md index 6c31be2..ce0f272 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionrequestmessages.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionrequestmessages.md @@ -1,5 +1,18 @@ # ChatCompletionRequestMessages +## Example Usage + +```typescript +import { ChatCompletionRequestMessages } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionRequestMessages = { + content: [ + { + text: "", + }, + ], +}; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionrequeststop.md b/packages/mistralai-azure/docs/models/components/chatcompletionrequeststop.md index 23b73a5..468cf93 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionrequeststop.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { ChatCompletionRequestStop } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionRequestStop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionrequesttoolchoice.md b/packages/mistralai-azure/docs/models/components/chatcompletionrequesttoolchoice.md index 91a7934..2e1ddd2 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionrequesttoolchoice.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionrequesttoolchoice.md @@ -1,10 +1,15 @@ # ChatCompletionRequestToolChoice +## Example Usage + +```typescript +import { ChatCompletionRequestToolChoice } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionRequestToolChoice = "none"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionresponse.md b/packages/mistralai-azure/docs/models/components/chatcompletionresponse.md index 9e595eb..a86adbf 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionresponse.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionresponse.md @@ -1,5 +1,29 @@ # ChatCompletionResponse +## Example Usage + +```typescript +import { ChatCompletionResponse } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "mistral-small-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + created: 1702256327, + choices: [ + { + index: 0, + message: {}, + finishReason: "stop", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/chatcompletionstreamrequest.md b/packages/mistralai-azure/docs/models/components/chatcompletionstreamrequest.md index 5ec831b..b9055a1 100644 --- a/packages/mistralai-azure/docs/models/components/chatcompletionstreamrequest.md +++ b/packages/mistralai-azure/docs/models/components/chatcompletionstreamrequest.md @@ -1,5 +1,20 @@ # ChatCompletionStreamRequest +## Example Usage + +```typescript +import { ChatCompletionStreamRequest } from "@mistralai/mistralai-azure/models/components"; + +let value: ChatCompletionStreamRequest = { + model: "azureai", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | N/A | | | `stop` | *components.Stop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ToolChoice](../../models/components/toolchoice.md) | :heavy_minus_sign: | N/A | | diff --git a/packages/mistralai-azure/docs/models/components/completionchunk.md b/packages/mistralai-azure/docs/models/components/completionchunk.md index 8a6f4e9..01d48ce 100644 --- a/packages/mistralai-azure/docs/models/components/completionchunk.md +++ b/packages/mistralai-azure/docs/models/components/completionchunk.md @@ -1,5 +1,27 @@ # CompletionChunk +## Example Usage + +```typescript +import { CompletionChunk } from "@mistralai/mistralai-azure/models/components"; + +let value: CompletionChunk = { + id: "", + model: "Spyder", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 602763, + delta: {}, + finishReason: "tool_calls", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/completionevent.md b/packages/mistralai-azure/docs/models/components/completionevent.md index 912c4c4..a3aafe4 100644 --- a/packages/mistralai-azure/docs/models/components/completionevent.md +++ b/packages/mistralai-azure/docs/models/components/completionevent.md @@ -1,5 +1,29 @@ # CompletionEvent +## Example Usage + +```typescript +import { CompletionEvent } from "@mistralai/mistralai-azure/models/components"; + +let value: CompletionEvent = { + data: { + id: "", + model: "Model S", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 592845, + delta: {}, + finishReason: "error", + }, + ], + }, +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/completionresponsestreamchoice.md b/packages/mistralai-azure/docs/models/components/completionresponsestreamchoice.md index 29b2acb..2671061 100644 --- a/packages/mistralai-azure/docs/models/components/completionresponsestreamchoice.md +++ b/packages/mistralai-azure/docs/models/components/completionresponsestreamchoice.md @@ -1,5 +1,16 @@ # CompletionResponseStreamChoice +## Example Usage + +```typescript +import { CompletionResponseStreamChoice } from "@mistralai/mistralai-azure/models/components"; + +let value: CompletionResponseStreamChoice = { + index: 847252, + delta: {}, + finishReason: "length", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/content.md b/packages/mistralai-azure/docs/models/components/content.md index 4b41002..2cc5c53 100644 --- a/packages/mistralai-azure/docs/models/components/content.md +++ b/packages/mistralai-azure/docs/models/components/content.md @@ -1,5 +1,12 @@ # Content +## Example Usage + +```typescript +import { Content } from "@mistralai/mistralai-azure/models/components"; + +let value: Content = ""; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/contentchunk.md b/packages/mistralai-azure/docs/models/components/contentchunk.md index 83896db..f3f5388 100644 --- a/packages/mistralai-azure/docs/models/components/contentchunk.md +++ b/packages/mistralai-azure/docs/models/components/contentchunk.md @@ -1,5 +1,14 @@ # ContentChunk +## Example Usage + +```typescript +import { ContentChunk } from "@mistralai/mistralai-azure/models/components"; + +let value: ContentChunk = { + text: "", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/deltamessage.md b/packages/mistralai-azure/docs/models/components/deltamessage.md index 51c99bf..c505bf6 100644 --- a/packages/mistralai-azure/docs/models/components/deltamessage.md +++ b/packages/mistralai-azure/docs/models/components/deltamessage.md @@ -1,5 +1,12 @@ # DeltaMessage +## Example Usage + +```typescript +import { DeltaMessage } from "@mistralai/mistralai-azure/models/components"; + +let value: DeltaMessage = {}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/finishreason.md b/packages/mistralai-azure/docs/models/components/finishreason.md index 1261549..9d6a00f 100644 --- a/packages/mistralai-azure/docs/models/components/finishreason.md +++ b/packages/mistralai-azure/docs/models/components/finishreason.md @@ -1,11 +1,15 @@ # FinishReason +## Example Usage + +```typescript +import { FinishReason } from "@mistralai/mistralai-azure/models/components"; + +let value: FinishReason = "error"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Stop` | stop | -| `Length` | length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/functioncall.md b/packages/mistralai-azure/docs/models/components/functioncall.md index 75750f4..ea741ff 100644 --- a/packages/mistralai-azure/docs/models/components/functioncall.md +++ b/packages/mistralai-azure/docs/models/components/functioncall.md @@ -1,5 +1,17 @@ # FunctionCall +## Example Usage + +```typescript +import { FunctionCall } from "@mistralai/mistralai-azure/models/components"; + +let value: FunctionCall = { + name: "", + arguments: { + key: "", + }, +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/functiont.md b/packages/mistralai-azure/docs/models/components/functiont.md index ed230e5..7f967d3 100644 --- a/packages/mistralai-azure/docs/models/components/functiont.md +++ b/packages/mistralai-azure/docs/models/components/functiont.md @@ -1,5 +1,17 @@ # FunctionT +## Example Usage + +```typescript +import { FunctionT } from "@mistralai/mistralai-azure/models/components"; + +let value: FunctionT = { + name: "", + parameters: { + key: "", + }, +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/loc.md b/packages/mistralai-azure/docs/models/components/loc.md index 1d789e1..7964eb0 100644 --- a/packages/mistralai-azure/docs/models/components/loc.md +++ b/packages/mistralai-azure/docs/models/components/loc.md @@ -1,5 +1,12 @@ # Loc +## Example Usage + +```typescript +import { Loc } from "@mistralai/mistralai-azure/models/components"; + +let value: Loc = ""; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/messages.md b/packages/mistralai-azure/docs/models/components/messages.md index b2462b3..8939c7e 100644 --- a/packages/mistralai-azure/docs/models/components/messages.md +++ b/packages/mistralai-azure/docs/models/components/messages.md @@ -1,5 +1,12 @@ # Messages +## Example Usage + +```typescript +import { Messages } from "@mistralai/mistralai-azure/models/components"; + +let value: Messages = {}; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/responseformat.md b/packages/mistralai-azure/docs/models/components/responseformat.md index f2d1257..b81cadd 100644 --- a/packages/mistralai-azure/docs/models/components/responseformat.md +++ b/packages/mistralai-azure/docs/models/components/responseformat.md @@ -1,5 +1,12 @@ # ResponseFormat +## Example Usage + +```typescript +import { ResponseFormat } from "@mistralai/mistralai-azure/models/components"; + +let value: ResponseFormat = {}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/responseformats.md b/packages/mistralai-azure/docs/models/components/responseformats.md index d2429dc..a1bc56a 100644 --- a/packages/mistralai-azure/docs/models/components/responseformats.md +++ b/packages/mistralai-azure/docs/models/components/responseformats.md @@ -2,10 +2,16 @@ An object specifying the format that the model must output. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. +## Example Usage + +```typescript +import { ResponseFormats } from "@mistralai/mistralai-azure/models/components"; + +let value: ResponseFormats = "text"; +``` ## Values -| Name | Value | -| ------------ | ------------ | -| `Text` | text | -| `JsonObject` | json_object | \ No newline at end of file +```typescript +"text" | "json_object" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/role.md b/packages/mistralai-azure/docs/models/components/role.md index 38d07ee..ae6b1cc 100644 --- a/packages/mistralai-azure/docs/models/components/role.md +++ b/packages/mistralai-azure/docs/models/components/role.md @@ -1,8 +1,15 @@ # Role +## Example Usage + +```typescript +import { Role } from "@mistralai/mistralai-azure/models/components"; + +let value: Role = "system"; +``` ## Values -| Name | Value | -| -------- | -------- | -| `System` | system | \ No newline at end of file +```typescript +"system" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/security.md b/packages/mistralai-azure/docs/models/components/security.md index 217b33b..21a71d6 100644 --- a/packages/mistralai-azure/docs/models/components/security.md +++ b/packages/mistralai-azure/docs/models/components/security.md @@ -1,5 +1,12 @@ # Security +## Example Usage + +```typescript +import { Security } from "@mistralai/mistralai-azure/models/components"; + +let value: Security = {}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/stop.md b/packages/mistralai-azure/docs/models/components/stop.md index a25543c..029f69e 100644 --- a/packages/mistralai-azure/docs/models/components/stop.md +++ b/packages/mistralai-azure/docs/models/components/stop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { Stop } from "@mistralai/mistralai-azure/models/components"; + +let value: Stop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/systemmessage.md b/packages/mistralai-azure/docs/models/components/systemmessage.md index 37ee0ae..0062212 100644 --- a/packages/mistralai-azure/docs/models/components/systemmessage.md +++ b/packages/mistralai-azure/docs/models/components/systemmessage.md @@ -1,5 +1,14 @@ # SystemMessage +## Example Usage + +```typescript +import { SystemMessage } from "@mistralai/mistralai-azure/models/components"; + +let value: SystemMessage = { + content: "", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/textchunk.md b/packages/mistralai-azure/docs/models/components/textchunk.md index b9426f2..c637972 100644 --- a/packages/mistralai-azure/docs/models/components/textchunk.md +++ b/packages/mistralai-azure/docs/models/components/textchunk.md @@ -1,5 +1,14 @@ # TextChunk +## Example Usage + +```typescript +import { TextChunk } from "@mistralai/mistralai-azure/models/components"; + +let value: TextChunk = { + text: "", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/tool.md b/packages/mistralai-azure/docs/models/components/tool.md index 5fe4a6c..30d0547 100644 --- a/packages/mistralai-azure/docs/models/components/tool.md +++ b/packages/mistralai-azure/docs/models/components/tool.md @@ -1,9 +1,23 @@ # Tool +## Example Usage + +```typescript +import { Tool } from "@mistralai/mistralai-azure/models/components"; + +let value: Tool = { + function: { + name: "", + parameters: { + key: "", + }, + }, +}; +``` ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `type` | *string* | :heavy_minus_sign: | N/A | -| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `type` | [components.ToolToolTypes](../../models/components/tooltooltypes.md) | :heavy_minus_sign: | N/A | +| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/toolcall.md b/packages/mistralai-azure/docs/models/components/toolcall.md index 2145c1b..4cc693b 100644 --- a/packages/mistralai-azure/docs/models/components/toolcall.md +++ b/packages/mistralai-azure/docs/models/components/toolcall.md @@ -1,10 +1,22 @@ # ToolCall +## Example Usage + +```typescript +import { ToolCall } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolCall = { + function: { + name: "", + arguments: "", + }, +}; +``` ## Fields | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `id` | *string* | :heavy_minus_sign: | N/A | -| `type` | *string* | :heavy_minus_sign: | N/A | +| `type` | [components.ToolTypes](../../models/components/tooltypes.md) | :heavy_minus_sign: | N/A | | `function` | [components.FunctionCall](../../models/components/functioncall.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/toolchoice.md b/packages/mistralai-azure/docs/models/components/toolchoice.md index 54bc57c..86dfade 100644 --- a/packages/mistralai-azure/docs/models/components/toolchoice.md +++ b/packages/mistralai-azure/docs/models/components/toolchoice.md @@ -1,10 +1,15 @@ # ToolChoice +## Example Usage + +```typescript +import { ToolChoice } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolChoice = "any"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/toolmessage.md b/packages/mistralai-azure/docs/models/components/toolmessage.md index e8135ba..858f7b8 100644 --- a/packages/mistralai-azure/docs/models/components/toolmessage.md +++ b/packages/mistralai-azure/docs/models/components/toolmessage.md @@ -1,5 +1,14 @@ # ToolMessage +## Example Usage + +```typescript +import { ToolMessage } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolMessage = { + content: "", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/toolmessagerole.md b/packages/mistralai-azure/docs/models/components/toolmessagerole.md index f4fd3c6..986c04f 100644 --- a/packages/mistralai-azure/docs/models/components/toolmessagerole.md +++ b/packages/mistralai-azure/docs/models/components/toolmessagerole.md @@ -1,8 +1,15 @@ # ToolMessageRole +## Example Usage + +```typescript +import { ToolMessageRole } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolMessageRole = "tool"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Tool` | tool | \ No newline at end of file +```typescript +"tool" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/tooltooltypes.md b/packages/mistralai-azure/docs/models/components/tooltooltypes.md new file mode 100644 index 0000000..4ae5c07 --- /dev/null +++ b/packages/mistralai-azure/docs/models/components/tooltooltypes.md @@ -0,0 +1,17 @@ +# ToolToolTypes + +## Example Usage + +```typescript +import { ToolToolTypes } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/tooltypes.md b/packages/mistralai-azure/docs/models/components/tooltypes.md new file mode 100644 index 0000000..b917433 --- /dev/null +++ b/packages/mistralai-azure/docs/models/components/tooltypes.md @@ -0,0 +1,17 @@ +# ToolTypes + +## Example Usage + +```typescript +import { ToolTypes } from "@mistralai/mistralai-azure/models/components"; + +let value: ToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/usageinfo.md b/packages/mistralai-azure/docs/models/components/usageinfo.md index b317b51..20e4bbb 100644 --- a/packages/mistralai-azure/docs/models/components/usageinfo.md +++ b/packages/mistralai-azure/docs/models/components/usageinfo.md @@ -1,5 +1,16 @@ # UsageInfo +## Example Usage + +```typescript +import { UsageInfo } from "@mistralai/mistralai-azure/models/components"; + +let value: UsageInfo = { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/usermessage.md b/packages/mistralai-azure/docs/models/components/usermessage.md index 1e06816..8d4e0bc 100644 --- a/packages/mistralai-azure/docs/models/components/usermessage.md +++ b/packages/mistralai-azure/docs/models/components/usermessage.md @@ -1,5 +1,18 @@ # UserMessage +## Example Usage + +```typescript +import { UserMessage } from "@mistralai/mistralai-azure/models/components"; + +let value: UserMessage = { + content: [ + { + text: "", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/components/usermessagecontent.md b/packages/mistralai-azure/docs/models/components/usermessagecontent.md index 2d9bd3f..1276406 100644 --- a/packages/mistralai-azure/docs/models/components/usermessagecontent.md +++ b/packages/mistralai-azure/docs/models/components/usermessagecontent.md @@ -1,5 +1,16 @@ # UserMessageContent +## Example Usage + +```typescript +import { UserMessageContent } from "@mistralai/mistralai-azure/models/components"; + +let value: UserMessageContent = [ + { + text: "", + }, +]; +``` ## Supported Types diff --git a/packages/mistralai-azure/docs/models/components/usermessagerole.md b/packages/mistralai-azure/docs/models/components/usermessagerole.md index 30a5286..63ab97a 100644 --- a/packages/mistralai-azure/docs/models/components/usermessagerole.md +++ b/packages/mistralai-azure/docs/models/components/usermessagerole.md @@ -1,8 +1,15 @@ # UserMessageRole +## Example Usage + +```typescript +import { UserMessageRole } from "@mistralai/mistralai-azure/models/components"; + +let value: UserMessageRole = "user"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `User` | user | \ No newline at end of file +```typescript +"user" +``` \ No newline at end of file diff --git a/packages/mistralai-azure/docs/models/components/validationerror.md b/packages/mistralai-azure/docs/models/components/validationerror.md index 865d485..1e3fe2f 100644 --- a/packages/mistralai-azure/docs/models/components/validationerror.md +++ b/packages/mistralai-azure/docs/models/components/validationerror.md @@ -1,5 +1,16 @@ # ValidationError +## Example Usage + +```typescript +import { ValidationError } from "@mistralai/mistralai-azure/models/components"; + +let value: ValidationError = { + loc: [""], + msg: "", + type: "", +}; +``` ## Fields diff --git a/packages/mistralai-azure/docs/models/errors/httpvalidationerror.md b/packages/mistralai-azure/docs/models/errors/httpvalidationerror.md index 50ca4db..42f8e8e 100644 --- a/packages/mistralai-azure/docs/models/errors/httpvalidationerror.md +++ b/packages/mistralai-azure/docs/models/errors/httpvalidationerror.md @@ -2,6 +2,13 @@ Validation Error +## Example Usage + +```typescript +import { HTTPValidationError } from "@mistralai/mistralai-azure/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/mistralai-azure/jsr.json b/packages/mistralai-azure/jsr.json index 5722e7f..24961e0 100644 --- a/packages/mistralai-azure/jsr.json +++ b/packages/mistralai-azure/jsr.json @@ -2,7 +2,7 @@ { "name": "@mistralai/mistralai-azure", - "version": "1.0.2", + "version": "1.1.1", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/packages/mistralai-azure/package-lock.json b/packages/mistralai-azure/package-lock.json index a96191f..9601fc2 100644 --- a/packages/mistralai-azure/package-lock.json +++ b/packages/mistralai-azure/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mistralai/mistralai-azure", - "version": "1.0.2", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mistralai/mistralai-azure", - "version": "1.0.2", + "version": "1.1.1", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/packages/mistralai-azure/package.json b/packages/mistralai-azure/package.json index 9ed891b..fc1c9c7 100644 --- a/packages/mistralai-azure/package.json +++ b/packages/mistralai-azure/package.json @@ -1,6 +1,6 @@ { "name": "@mistralai/mistralai-azure", - "version": "1.0.2", + "version": "1.1.1", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, diff --git a/packages/mistralai-azure/src/lib/config.ts b/packages/mistralai-azure/src/lib/config.ts index 3fe985c..bf0aa7e 100644 --- a/packages/mistralai-azure/src/lib/config.ts +++ b/packages/mistralai-azure/src/lib/config.ts @@ -3,6 +3,7 @@ */ import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; import { RetryConfig } from "./retries.js"; import { Params, pathToFunc } from "./url.js"; @@ -34,6 +35,7 @@ export type SDKOptions = { */ retryConfig?: RetryConfig; timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { @@ -53,7 +55,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.2", - sdkVersion: "1.0.2", - genVersion: "2.390.6", - userAgent: "speakeasy-sdk/typescript 1.0.2 2.390.6 0.0.2 @mistralai/mistralai-azure", + sdkVersion: "1.1.1", + genVersion: "2.399.0", + userAgent: "speakeasy-sdk/typescript 1.1.1 2.399.0 0.0.2 @mistralai/mistralai-azure", } as const; diff --git a/packages/mistralai-azure/src/lib/http.ts b/packages/mistralai-azure/src/lib/http.ts index f8c544d..13cf1fd 100644 --- a/packages/mistralai-azure/src/lib/http.ts +++ b/packages/mistralai-azure/src/lib/http.ts @@ -157,7 +157,7 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { +export function matchContentType(response: Response, pattern: string): boolean { // `*` is a special case which means anything is acceptable. if (pattern === "*") { return true; diff --git a/packages/mistralai-azure/src/lib/logger.ts b/packages/mistralai-azure/src/lib/logger.ts new file mode 100644 index 0000000..d181f29 --- /dev/null +++ b/packages/mistralai-azure/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/packages/mistralai-azure/src/lib/sdks.ts b/packages/mistralai-azure/src/lib/sdks.ts index 0e92ce7..51b49bd 100644 --- a/packages/mistralai-azure/src/lib/sdks.ts +++ b/packages/mistralai-azure/src/lib/sdks.ts @@ -4,6 +4,7 @@ import { HTTPClient, + matchContentType, matchStatusCode, isAbortError, isTimeoutError, @@ -11,6 +12,7 @@ import { } from "./http.js"; import { SecurityState } from "./security.js"; import { retry, RetryConfig } from "./retries.js"; +import { Logger } from "./logger.js"; import { encodeForm } from "./encodings.js"; import { stringToBase64 } from "./base64.js"; import { SDKOptions, SDK_METADATA, serverURLFromOptions } from "./config.js"; @@ -74,6 +76,7 @@ export class ClientSDK { private readonly httpClient: HTTPClient; protected readonly baseURL: URL | null; protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; public readonly options$: SDKOptions & { hooks?: SDKHooks }; constructor(options: SDKOptions = {}) { @@ -100,6 +103,7 @@ export class ClientSDK { }); this.baseURL = baseURL; this.httpClient = client; + this.logger = options.debugLogger; } public createRequest$( @@ -217,12 +221,13 @@ export class ClientSDK { return retry( async () => { - const req = request.clone(); - - let response = await this.httpClient.request( - await this.hooks$.beforeRequest(context, req) + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) ); + let response = await this.httpClient.request(req); + if (matchStatusCode(response, errorCodes)) { const result = await this.hooks$.afterError(context, response, null); if (result.error) { @@ -233,6 +238,10 @@ export class ClientSDK { response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req).catch((e) => + this.logger?.log("Failed to log response:", e) + ); + return response; }, { config: retryConfig, statusCodes: retryCodes } @@ -259,3 +268,90 @@ export class ClientSDK { ); } } + +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} + +async function logResponse(logger: Logger | undefined, res: Response, req: Request) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} diff --git a/packages/mistralai-azure/src/models/components/chatcompletionchoice.ts b/packages/mistralai-azure/src/models/components/chatcompletionchoice.ts index 9c6201f..45fbd2f 100644 --- a/packages/mistralai-azure/src/models/components/chatcompletionchoice.ts +++ b/packages/mistralai-azure/src/models/components/chatcompletionchoice.ts @@ -23,7 +23,7 @@ export type ChatCompletionChoiceFinishReason = ClosedEnum = z .object({ index: z.number().int(), - message: AssistantMessage$inboundSchema.optional(), + message: AssistantMessage$inboundSchema, finish_reason: ChatCompletionChoiceFinishReason$inboundSchema, }) .transform((v) => { @@ -68,7 +68,7 @@ export const ChatCompletionChoice$inboundSchema: z.ZodType< /** @internal */ export type ChatCompletionChoice$Outbound = { index: number; - message?: AssistantMessage$Outbound | undefined; + message: AssistantMessage$Outbound; finish_reason: string; }; @@ -80,7 +80,7 @@ export const ChatCompletionChoice$outboundSchema: z.ZodType< > = z .object({ index: z.number().int(), - message: AssistantMessage$outboundSchema.optional(), + message: AssistantMessage$outboundSchema, finishReason: ChatCompletionChoiceFinishReason$outboundSchema, }) .transform((v) => { diff --git a/packages/mistralai-azure/src/models/components/contentchunk.ts b/packages/mistralai-azure/src/models/components/contentchunk.ts index 40713a3..1a1ce72 100644 --- a/packages/mistralai-azure/src/models/components/contentchunk.ts +++ b/packages/mistralai-azure/src/models/components/contentchunk.ts @@ -11,7 +11,7 @@ export type ContentChunk = { /** @internal */ export const ContentChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/packages/mistralai-azure/src/models/components/textchunk.ts b/packages/mistralai-azure/src/models/components/textchunk.ts index afaae98..0cd4902 100644 --- a/packages/mistralai-azure/src/models/components/textchunk.ts +++ b/packages/mistralai-azure/src/models/components/textchunk.ts @@ -11,7 +11,7 @@ export type TextChunk = { /** @internal */ export const TextChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/packages/mistralai-azure/src/models/components/tool.ts b/packages/mistralai-azure/src/models/components/tool.ts index 6a56f6b..55ae3b4 100644 --- a/packages/mistralai-azure/src/models/components/tool.ts +++ b/packages/mistralai-azure/src/models/components/tool.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionT, FunctionT$inboundSchema, @@ -10,26 +11,51 @@ import { } from "./function.js"; import * as z from "zod"; +export const ToolToolTypes = { + Function: "function", +} as const; +export type ToolToolTypes = OpenEnum; + export type Tool = { - type?: "function" | undefined; + type?: ToolToolTypes | undefined; function: FunctionT; }; +/** @internal */ +export const ToolToolTypes$inboundSchema: z.ZodType = z.union( + [z.nativeEnum(ToolToolTypes), z.string().transform(catchUnrecognizedEnum)] +); + +/** @internal */ +export const ToolToolTypes$outboundSchema: z.ZodType = + z.union([z.nativeEnum(ToolToolTypes), z.string().and(z.custom>())]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolToolTypes$ { + /** @deprecated use `ToolToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolToolTypes$inboundSchema; + /** @deprecated use `ToolToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolToolTypes$outboundSchema; +} + /** @internal */ export const Tool$inboundSchema: z.ZodType = z.object({ - type: z.literal("function"), + type: ToolToolTypes$inboundSchema.default("function"), function: FunctionT$inboundSchema, }); /** @internal */ export type Tool$Outbound = { - type: "function"; + type: string; function: FunctionT$Outbound; }; /** @internal */ export const Tool$outboundSchema: z.ZodType = z.object({ - type: z.literal("function").default("function" as const), + type: ToolToolTypes$outboundSchema.default("function"), function: FunctionT$outboundSchema, }); diff --git a/packages/mistralai-azure/src/models/components/toolcall.ts b/packages/mistralai-azure/src/models/components/toolcall.ts index 56e05d0..35b0dca 100644 --- a/packages/mistralai-azure/src/models/components/toolcall.ts +++ b/packages/mistralai-azure/src/models/components/toolcall.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionCall, FunctionCall$inboundSchema, @@ -10,23 +11,51 @@ import { } from "./functioncall.js"; import * as z from "zod"; +export const ToolTypes = { + Function: "function", +} as const; +export type ToolTypes = OpenEnum; + export type ToolCall = { id?: string | undefined; - type?: "function" | undefined; + type?: ToolTypes | undefined; function: FunctionCall; }; +/** @internal */ +export const ToolTypes$inboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().transform(catchUnrecognizedEnum), +]); + +/** @internal */ +export const ToolTypes$outboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().and(z.custom>()), +]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolTypes$ { + /** @deprecated use `ToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolTypes$inboundSchema; + /** @deprecated use `ToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolTypes$outboundSchema; +} + /** @internal */ export const ToolCall$inboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function"), + type: ToolTypes$inboundSchema.default("function"), function: FunctionCall$inboundSchema, }); /** @internal */ export type ToolCall$Outbound = { id: string; - type: "function"; + type: string; function: FunctionCall$Outbound; }; @@ -34,7 +63,7 @@ export type ToolCall$Outbound = { export const ToolCall$outboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function").default("function" as const), + type: ToolTypes$outboundSchema.default("function"), function: FunctionCall$outboundSchema, }); diff --git a/packages/mistralai-azure/src/models/errors/index.ts b/packages/mistralai-azure/src/models/errors/index.ts index 570cd55..8a5df29 100644 --- a/packages/mistralai-azure/src/models/errors/index.ts +++ b/packages/mistralai-azure/src/models/errors/index.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +export * from "./httpclienterrors.js"; export * from "./httpvalidationerror.js"; export * from "./sdkerror.js"; export * from "./sdkvalidationerror.js"; diff --git a/packages/mistralai-azure/src/models/errors/sdkvalidationerror.ts b/packages/mistralai-azure/src/models/errors/sdkvalidationerror.ts index 3030cd7..16929b9 100644 --- a/packages/mistralai-azure/src/models/errors/sdkvalidationerror.ts +++ b/packages/mistralai-azure/src/models/errors/sdkvalidationerror.ts @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/packages/mistralai-azure/src/types/constdatetime.ts b/packages/mistralai-azure/src/types/constdatetime.ts new file mode 100644 index 0000000..c0a4409 --- /dev/null +++ b/packages/mistralai-azure/src/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/packages/mistralai-gcp/.speakeasy/gen.lock b/packages/mistralai-gcp/.speakeasy/gen.lock index b2d6e31..c9dc697 100644 --- a/packages/mistralai-gcp/.speakeasy/gen.lock +++ b/packages/mistralai-gcp/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: c6044247-eaf9-46da-b078-0e1334e93be2 management: - docChecksum: e2bc44269918d569bbc51b1521c4c29b + docChecksum: 4cc6e7c5c5ba15491872c600d4a247ef docVersion: 0.0.2 - speakeasyVersion: 1.357.4 - generationVersion: 2.390.6 - releaseVersion: 1.0.2 - configChecksum: a530616ee173c76a1e031e7301d7834e + speakeasyVersion: 1.372.0 + generationVersion: 2.399.0 + releaseVersion: 1.1.2 + configChecksum: aee01235f4e46aef1a055407ead7ae83 repoURL: https://github.com/mistralai/client-ts.git repoSubDirectory: packages/mistralai-gcp installationURL: https://gitpkg.now.sh/mistralai/client-ts/packages/mistralai-gcp @@ -14,8 +14,8 @@ management: features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.6 - core: 3.12.3 + constsAndDefaults: 0.1.8 + core: 3.13.2 defaultEnabledRetries: 0.1.0 envVarSecurityUsage: 0.1.1 examples: 2.81.4 @@ -25,13 +25,14 @@ features: globalServerURLs: 2.82.4 nameOverrides: 2.81.2 nullables: 0.1.0 + openEnums: 0.1.1 responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 serverEvents: 0.1.4 serverEventsSentinels: 0.1.0 serverIDs: 2.81.2 - unions: 2.85.6 + unions: 2.85.7 generatedFiles: - src/funcs/chatStream.ts - src/funcs/chatComplete.ts @@ -41,6 +42,7 @@ generatedFiles: - src/sdk/fim.ts - .eslintrc.cjs - .npmignore + - FUNCTIONS.md - RUNTIMES.md - jsr.json - package.json @@ -53,6 +55,7 @@ generatedFiles: - src/lib/event-streams.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts - src/lib/matchers.ts - src/lib/primitives.ts - src/lib/retries.ts @@ -65,6 +68,7 @@ generatedFiles: - src/models/errors/sdkerror.ts - src/models/errors/sdkvalidationerror.ts - src/types/blobs.ts + - src/types/constdatetime.ts - src/types/enums.ts - src/types/fp.ts - src/types/index.ts @@ -104,6 +108,7 @@ generatedFiles: - docs/models/components/finishreason.md - docs/models/components/completionresponsestreamchoice.md - docs/models/components/deltamessage.md + - docs/models/components/tooltypes.md - docs/models/components/toolcall.md - docs/models/components/arguments.md - docs/models/components/functioncall.md @@ -114,6 +119,7 @@ generatedFiles: - docs/models/components/messages.md - docs/models/components/toolchoice.md - docs/models/components/chatcompletionstreamrequest.md + - docs/models/components/tooltooltypes.md - docs/models/components/tool.md - docs/models/components/functiont.md - docs/models/components/responseformats.md diff --git a/packages/mistralai-gcp/.speakeasy/gen.yaml b/packages/mistralai-gcp/.speakeasy/gen.yaml index ddd597e..5059078 100644 --- a/packages/mistralai-gcp/.speakeasy/gen.yaml +++ b/packages/mistralai-gcp/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 1.0.2 + version: 1.1.2 additionalDependencies: dependencies: google-auth-library: ^9.11.0 diff --git a/packages/mistralai-gcp/FUNCTIONS.md b/packages/mistralai-gcp/FUNCTIONS.md new file mode 100644 index 0000000..f0a3b38 --- /dev/null +++ b/packages/mistralai-gcp/FUNCTIONS.md @@ -0,0 +1,112 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { MistralGoogleCloudCore } from "@mistralai/mistralai-gcp/core.js"; +import { chatComplete } from "@mistralai/mistralai-gcp/funcs/chatComplete.js"; +import { SDKValidationError } from "@mistralai/mistralai-gcp/models/errors/sdkvalidationerror.js"; + +// Use `MistralGoogleCloudCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const mistralGoogleCloud = new MistralGoogleCloudCore({ + apiKey: "", +}); + +async function run() { + const res = await chatComplete(mistralGoogleCloud, { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], + }); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/arguments.md b/packages/mistralai-gcp/docs/models/components/arguments.md index aacbc0b..63fac53 100644 --- a/packages/mistralai-gcp/docs/models/components/arguments.md +++ b/packages/mistralai-gcp/docs/models/components/arguments.md @@ -1,5 +1,12 @@ # Arguments +## Example Usage + +```typescript +import { Arguments } from "@mistralai/mistralai-gcp/models/components"; + +let value: Arguments = ""; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/assistantmessage.md b/packages/mistralai-gcp/docs/models/components/assistantmessage.md index 37c243d..cd15de7 100644 --- a/packages/mistralai-gcp/docs/models/components/assistantmessage.md +++ b/packages/mistralai-gcp/docs/models/components/assistantmessage.md @@ -1,5 +1,12 @@ # AssistantMessage +## Example Usage + +```typescript +import { AssistantMessage } from "@mistralai/mistralai-gcp/models/components"; + +let value: AssistantMessage = {}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/assistantmessagerole.md b/packages/mistralai-gcp/docs/models/components/assistantmessagerole.md index 781c8a5..a276059 100644 --- a/packages/mistralai-gcp/docs/models/components/assistantmessagerole.md +++ b/packages/mistralai-gcp/docs/models/components/assistantmessagerole.md @@ -1,8 +1,15 @@ # AssistantMessageRole +## Example Usage + +```typescript +import { AssistantMessageRole } from "@mistralai/mistralai-gcp/models/components"; + +let value: AssistantMessageRole = "assistant"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Assistant` | assistant | \ No newline at end of file +```typescript +"assistant" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionchoice.md b/packages/mistralai-gcp/docs/models/components/chatcompletionchoice.md index be99bf0..21f89d2 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionchoice.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionchoice.md @@ -1,10 +1,21 @@ # ChatCompletionChoice +## Example Usage + +```typescript +import { ChatCompletionChoice } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionChoice = { + index: 0, + message: {}, + finishReason: "stop", +}; +``` ## Fields | Field | Type | Required | Description | Example | | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | `index` | *number* | :heavy_check_mark: | N/A | 0 | -| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_minus_sign: | N/A | | +| `message` | [components.AssistantMessage](../../models/components/assistantmessage.md) | :heavy_check_mark: | N/A | | | `finishReason` | [components.ChatCompletionChoiceFinishReason](../../models/components/chatcompletionchoicefinishreason.md) | :heavy_check_mark: | N/A | stop | \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionchoicefinishreason.md b/packages/mistralai-gcp/docs/models/components/chatcompletionchoicefinishreason.md index 7e3e05b..93ef7b4 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionchoicefinishreason.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionchoicefinishreason.md @@ -1,12 +1,15 @@ # ChatCompletionChoiceFinishReason +## Example Usage + +```typescript +import { ChatCompletionChoiceFinishReason } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionChoiceFinishReason = "stop"; +``` ## Values -| Name | Value | -| ------------- | ------------- | -| `Stop` | stop | -| `Length` | length | -| `ModelLength` | model_length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "model_length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionrequest.md b/packages/mistralai-gcp/docs/models/components/chatcompletionrequest.md index 5d982c0..92bf889 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionrequest.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionrequest.md @@ -1,11 +1,26 @@ # ChatCompletionRequest +## Example Usage + +```typescript +import { ChatCompletionRequest } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionRequest = { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields | Field | Type | Required | Description | Example | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | +| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | | `temperature` | *number* | :heavy_minus_sign: | 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. | | | `topP` | *number* | :heavy_minus_sign: | 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. | | | `maxTokens` | *number* | :heavy_minus_sign: | 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. | | @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | 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. | | | `stop` | *components.ChatCompletionRequestStop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.ChatCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.ChatCompletionRequestMessages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ChatCompletionRequestToolChoice](../../models/components/chatcompletionrequesttoolchoice.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionrequestmessages.md b/packages/mistralai-gcp/docs/models/components/chatcompletionrequestmessages.md index 6c31be2..037325a 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionrequestmessages.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionrequestmessages.md @@ -1,5 +1,18 @@ # ChatCompletionRequestMessages +## Example Usage + +```typescript +import { ChatCompletionRequestMessages } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionRequestMessages = { + content: [ + { + text: "", + }, + ], +}; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionrequeststop.md b/packages/mistralai-gcp/docs/models/components/chatcompletionrequeststop.md index 23b73a5..19ab34b 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionrequeststop.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { ChatCompletionRequestStop } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionRequestStop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionrequesttoolchoice.md b/packages/mistralai-gcp/docs/models/components/chatcompletionrequesttoolchoice.md index 91a7934..9620d01 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionrequesttoolchoice.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionrequesttoolchoice.md @@ -1,10 +1,15 @@ # ChatCompletionRequestToolChoice +## Example Usage + +```typescript +import { ChatCompletionRequestToolChoice } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionRequestToolChoice = "none"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionresponse.md b/packages/mistralai-gcp/docs/models/components/chatcompletionresponse.md index 9e595eb..a084373 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionresponse.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionresponse.md @@ -1,5 +1,29 @@ # ChatCompletionResponse +## Example Usage + +```typescript +import { ChatCompletionResponse } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "mistral-small-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + created: 1702256327, + choices: [ + { + index: 0, + message: {}, + finishReason: "stop", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/chatcompletionstreamrequest.md b/packages/mistralai-gcp/docs/models/components/chatcompletionstreamrequest.md index c2e2af8..4357cbd 100644 --- a/packages/mistralai-gcp/docs/models/components/chatcompletionstreamrequest.md +++ b/packages/mistralai-gcp/docs/models/components/chatcompletionstreamrequest.md @@ -1,11 +1,26 @@ # ChatCompletionStreamRequest +## Example Usage + +```typescript +import { ChatCompletionStreamRequest } from "@mistralai/mistralai-gcp/models/components"; + +let value: ChatCompletionStreamRequest = { + model: "mistral-small-latest", + messages: [ + { + content: "Who is the best French painter? Answer in one short sentence.", + role: "user", + }, + ], +}; +``` ## Fields | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | +| `model` | *string* | :heavy_check_mark: | ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. | mistral-small-latest | | `temperature` | *number* | :heavy_minus_sign: | 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. | | | `topP` | *number* | :heavy_minus_sign: | 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. | | | `maxTokens` | *number* | :heavy_minus_sign: | 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. | | @@ -13,7 +28,7 @@ | `stream` | *boolean* | :heavy_minus_sign: | N/A | | | `stop` | *components.Stop* | :heavy_minus_sign: | Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | | | `randomSeed` | *number* | :heavy_minus_sign: | The seed to use for random sampling. If set, different calls will generate deterministic results. | | -| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | {
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
} | +| `messages` | *components.Messages*[] | :heavy_check_mark: | The prompt(s) to generate completions for, encoded as a list of dict with role and content. | [
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence."
}
] | | `responseFormat` | [components.ResponseFormat](../../models/components/responseformat.md) | :heavy_minus_sign: | N/A | | | `tools` | [components.Tool](../../models/components/tool.md)[] | :heavy_minus_sign: | N/A | | | `toolChoice` | [components.ToolChoice](../../models/components/toolchoice.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/completionchunk.md b/packages/mistralai-gcp/docs/models/components/completionchunk.md index 8a6f4e9..416f095 100644 --- a/packages/mistralai-gcp/docs/models/components/completionchunk.md +++ b/packages/mistralai-gcp/docs/models/components/completionchunk.md @@ -1,5 +1,27 @@ # CompletionChunk +## Example Usage + +```typescript +import { CompletionChunk } from "@mistralai/mistralai-gcp/models/components"; + +let value: CompletionChunk = { + id: "", + model: "Spyder", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 602763, + delta: {}, + finishReason: "tool_calls", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/completionevent.md b/packages/mistralai-gcp/docs/models/components/completionevent.md index 912c4c4..4bc7ac0 100644 --- a/packages/mistralai-gcp/docs/models/components/completionevent.md +++ b/packages/mistralai-gcp/docs/models/components/completionevent.md @@ -1,5 +1,29 @@ # CompletionEvent +## Example Usage + +```typescript +import { CompletionEvent } from "@mistralai/mistralai-gcp/models/components"; + +let value: CompletionEvent = { + data: { + id: "", + model: "Model S", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + choices: [ + { + index: 592845, + delta: {}, + finishReason: "error", + }, + ], + }, +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/completionresponsestreamchoice.md b/packages/mistralai-gcp/docs/models/components/completionresponsestreamchoice.md index 29b2acb..3fcbd18 100644 --- a/packages/mistralai-gcp/docs/models/components/completionresponsestreamchoice.md +++ b/packages/mistralai-gcp/docs/models/components/completionresponsestreamchoice.md @@ -1,5 +1,16 @@ # CompletionResponseStreamChoice +## Example Usage + +```typescript +import { CompletionResponseStreamChoice } from "@mistralai/mistralai-gcp/models/components"; + +let value: CompletionResponseStreamChoice = { + index: 847252, + delta: {}, + finishReason: "length", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/content.md b/packages/mistralai-gcp/docs/models/components/content.md index 4b41002..70b03a4 100644 --- a/packages/mistralai-gcp/docs/models/components/content.md +++ b/packages/mistralai-gcp/docs/models/components/content.md @@ -1,5 +1,12 @@ # Content +## Example Usage + +```typescript +import { Content } from "@mistralai/mistralai-gcp/models/components"; + +let value: Content = ""; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/contentchunk.md b/packages/mistralai-gcp/docs/models/components/contentchunk.md index 83896db..468f9b3 100644 --- a/packages/mistralai-gcp/docs/models/components/contentchunk.md +++ b/packages/mistralai-gcp/docs/models/components/contentchunk.md @@ -1,5 +1,14 @@ # ContentChunk +## Example Usage + +```typescript +import { ContentChunk } from "@mistralai/mistralai-gcp/models/components"; + +let value: ContentChunk = { + text: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/deltamessage.md b/packages/mistralai-gcp/docs/models/components/deltamessage.md index 51c99bf..beae339 100644 --- a/packages/mistralai-gcp/docs/models/components/deltamessage.md +++ b/packages/mistralai-gcp/docs/models/components/deltamessage.md @@ -1,5 +1,12 @@ # DeltaMessage +## Example Usage + +```typescript +import { DeltaMessage } from "@mistralai/mistralai-gcp/models/components"; + +let value: DeltaMessage = {}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/fimcompletionrequest.md b/packages/mistralai-gcp/docs/models/components/fimcompletionrequest.md index b3ceb22..1d4ad1d 100644 --- a/packages/mistralai-gcp/docs/models/components/fimcompletionrequest.md +++ b/packages/mistralai-gcp/docs/models/components/fimcompletionrequest.md @@ -1,5 +1,16 @@ # FIMCompletionRequest +## Example Usage + +```typescript +import { FIMCompletionRequest } from "@mistralai/mistralai-gcp/models/components"; + +let value: FIMCompletionRequest = { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/fimcompletionrequeststop.md b/packages/mistralai-gcp/docs/models/components/fimcompletionrequeststop.md index 03bd871..8749576 100644 --- a/packages/mistralai-gcp/docs/models/components/fimcompletionrequeststop.md +++ b/packages/mistralai-gcp/docs/models/components/fimcompletionrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { FIMCompletionRequestStop } from "@mistralai/mistralai-gcp/models/components"; + +let value: FIMCompletionRequestStop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/fimcompletionresponse.md b/packages/mistralai-gcp/docs/models/components/fimcompletionresponse.md index b3705f7..b5bda9d 100644 --- a/packages/mistralai-gcp/docs/models/components/fimcompletionresponse.md +++ b/packages/mistralai-gcp/docs/models/components/fimcompletionresponse.md @@ -1,5 +1,29 @@ # FIMCompletionResponse +## Example Usage + +```typescript +import { FIMCompletionResponse } from "@mistralai/mistralai-gcp/models/components"; + +let value: FIMCompletionResponse = { + id: "cmpl-e5cc70bb28c444948073e77776eb30ef", + object: "chat.completion", + model: "codestral-latest", + usage: { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, + }, + created: 1702256327, + choices: [ + { + index: 0, + message: {}, + finishReason: "stop", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequest.md b/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequest.md index 8f32a6e..14ac8f4 100644 --- a/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequest.md +++ b/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequest.md @@ -1,5 +1,16 @@ # FIMCompletionStreamRequest +## Example Usage + +```typescript +import { FIMCompletionStreamRequest } from "@mistralai/mistralai-gcp/models/components"; + +let value: FIMCompletionStreamRequest = { + model: "codestral-2405", + prompt: "def", + suffix: "return a+b", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequeststop.md b/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequeststop.md index 2ab10b5..23e9ff0 100644 --- a/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequeststop.md +++ b/packages/mistralai-gcp/docs/models/components/fimcompletionstreamrequeststop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { FIMCompletionStreamRequestStop } from "@mistralai/mistralai-gcp/models/components"; + +let value: FIMCompletionStreamRequestStop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/finishreason.md b/packages/mistralai-gcp/docs/models/components/finishreason.md index 1261549..aa34c23 100644 --- a/packages/mistralai-gcp/docs/models/components/finishreason.md +++ b/packages/mistralai-gcp/docs/models/components/finishreason.md @@ -1,11 +1,15 @@ # FinishReason +## Example Usage + +```typescript +import { FinishReason } from "@mistralai/mistralai-gcp/models/components"; + +let value: FinishReason = "error"; +``` ## Values -| Name | Value | -| ----------- | ----------- | -| `Stop` | stop | -| `Length` | length | -| `Error` | error | -| `ToolCalls` | tool_calls | \ No newline at end of file +```typescript +"stop" | "length" | "error" | "tool_calls" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/functioncall.md b/packages/mistralai-gcp/docs/models/components/functioncall.md index 75750f4..f5d2696 100644 --- a/packages/mistralai-gcp/docs/models/components/functioncall.md +++ b/packages/mistralai-gcp/docs/models/components/functioncall.md @@ -1,5 +1,17 @@ # FunctionCall +## Example Usage + +```typescript +import { FunctionCall } from "@mistralai/mistralai-gcp/models/components"; + +let value: FunctionCall = { + name: "", + arguments: { + key: "", + }, +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/functiont.md b/packages/mistralai-gcp/docs/models/components/functiont.md index ed230e5..3481bfa 100644 --- a/packages/mistralai-gcp/docs/models/components/functiont.md +++ b/packages/mistralai-gcp/docs/models/components/functiont.md @@ -1,5 +1,17 @@ # FunctionT +## Example Usage + +```typescript +import { FunctionT } from "@mistralai/mistralai-gcp/models/components"; + +let value: FunctionT = { + name: "", + parameters: { + key: "", + }, +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/loc.md b/packages/mistralai-gcp/docs/models/components/loc.md index 1d789e1..a87585f 100644 --- a/packages/mistralai-gcp/docs/models/components/loc.md +++ b/packages/mistralai-gcp/docs/models/components/loc.md @@ -1,5 +1,12 @@ # Loc +## Example Usage + +```typescript +import { Loc } from "@mistralai/mistralai-gcp/models/components"; + +let value: Loc = ""; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/messages.md b/packages/mistralai-gcp/docs/models/components/messages.md index b2462b3..d899339 100644 --- a/packages/mistralai-gcp/docs/models/components/messages.md +++ b/packages/mistralai-gcp/docs/models/components/messages.md @@ -1,5 +1,12 @@ # Messages +## Example Usage + +```typescript +import { Messages } from "@mistralai/mistralai-gcp/models/components"; + +let value: Messages = {}; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/responseformat.md b/packages/mistralai-gcp/docs/models/components/responseformat.md index f2d1257..4bf53fe 100644 --- a/packages/mistralai-gcp/docs/models/components/responseformat.md +++ b/packages/mistralai-gcp/docs/models/components/responseformat.md @@ -1,5 +1,12 @@ # ResponseFormat +## Example Usage + +```typescript +import { ResponseFormat } from "@mistralai/mistralai-gcp/models/components"; + +let value: ResponseFormat = {}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/responseformats.md b/packages/mistralai-gcp/docs/models/components/responseformats.md index d2429dc..27021bb 100644 --- a/packages/mistralai-gcp/docs/models/components/responseformats.md +++ b/packages/mistralai-gcp/docs/models/components/responseformats.md @@ -2,10 +2,16 @@ An object specifying the format that the model must output. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. +## Example Usage + +```typescript +import { ResponseFormats } from "@mistralai/mistralai-gcp/models/components"; + +let value: ResponseFormats = "text"; +``` ## Values -| Name | Value | -| ------------ | ------------ | -| `Text` | text | -| `JsonObject` | json_object | \ No newline at end of file +```typescript +"text" | "json_object" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/role.md b/packages/mistralai-gcp/docs/models/components/role.md index 38d07ee..73d494a 100644 --- a/packages/mistralai-gcp/docs/models/components/role.md +++ b/packages/mistralai-gcp/docs/models/components/role.md @@ -1,8 +1,15 @@ # Role +## Example Usage + +```typescript +import { Role } from "@mistralai/mistralai-gcp/models/components"; + +let value: Role = "system"; +``` ## Values -| Name | Value | -| -------- | -------- | -| `System` | system | \ No newline at end of file +```typescript +"system" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/security.md b/packages/mistralai-gcp/docs/models/components/security.md index e4a21be..7498411 100644 --- a/packages/mistralai-gcp/docs/models/components/security.md +++ b/packages/mistralai-gcp/docs/models/components/security.md @@ -1,5 +1,14 @@ # Security +## Example Usage + +```typescript +import { Security } from "@mistralai/mistralai-gcp/models/components"; + +let value: Security = { + apiKey: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/stop.md b/packages/mistralai-gcp/docs/models/components/stop.md index a25543c..02a699d 100644 --- a/packages/mistralai-gcp/docs/models/components/stop.md +++ b/packages/mistralai-gcp/docs/models/components/stop.md @@ -2,6 +2,13 @@ Stop generation if this token is detected. Or if one of these tokens is detected when providing an array +## Example Usage + +```typescript +import { Stop } from "@mistralai/mistralai-gcp/models/components"; + +let value: Stop = [""]; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/systemmessage.md b/packages/mistralai-gcp/docs/models/components/systemmessage.md index 37ee0ae..4857cd5 100644 --- a/packages/mistralai-gcp/docs/models/components/systemmessage.md +++ b/packages/mistralai-gcp/docs/models/components/systemmessage.md @@ -1,5 +1,14 @@ # SystemMessage +## Example Usage + +```typescript +import { SystemMessage } from "@mistralai/mistralai-gcp/models/components"; + +let value: SystemMessage = { + content: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/textchunk.md b/packages/mistralai-gcp/docs/models/components/textchunk.md index b9426f2..6853e82 100644 --- a/packages/mistralai-gcp/docs/models/components/textchunk.md +++ b/packages/mistralai-gcp/docs/models/components/textchunk.md @@ -1,5 +1,14 @@ # TextChunk +## Example Usage + +```typescript +import { TextChunk } from "@mistralai/mistralai-gcp/models/components"; + +let value: TextChunk = { + text: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/tool.md b/packages/mistralai-gcp/docs/models/components/tool.md index 5fe4a6c..5739a77 100644 --- a/packages/mistralai-gcp/docs/models/components/tool.md +++ b/packages/mistralai-gcp/docs/models/components/tool.md @@ -1,9 +1,23 @@ # Tool +## Example Usage + +```typescript +import { Tool } from "@mistralai/mistralai-gcp/models/components"; + +let value: Tool = { + function: { + name: "", + parameters: { + key: "", + }, + }, +}; +``` ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `type` | *string* | :heavy_minus_sign: | N/A | -| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `type` | [components.ToolToolTypes](../../models/components/tooltooltypes.md) | :heavy_minus_sign: | N/A | +| `function` | [components.FunctionT](../../models/components/functiont.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/toolcall.md b/packages/mistralai-gcp/docs/models/components/toolcall.md index 2145c1b..4b82dde 100644 --- a/packages/mistralai-gcp/docs/models/components/toolcall.md +++ b/packages/mistralai-gcp/docs/models/components/toolcall.md @@ -1,10 +1,22 @@ # ToolCall +## Example Usage + +```typescript +import { ToolCall } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolCall = { + function: { + name: "", + arguments: "", + }, +}; +``` ## Fields | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `id` | *string* | :heavy_minus_sign: | N/A | -| `type` | *string* | :heavy_minus_sign: | N/A | +| `type` | [components.ToolTypes](../../models/components/tooltypes.md) | :heavy_minus_sign: | N/A | | `function` | [components.FunctionCall](../../models/components/functioncall.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/toolchoice.md b/packages/mistralai-gcp/docs/models/components/toolchoice.md index 54bc57c..079ae80 100644 --- a/packages/mistralai-gcp/docs/models/components/toolchoice.md +++ b/packages/mistralai-gcp/docs/models/components/toolchoice.md @@ -1,10 +1,15 @@ # ToolChoice +## Example Usage + +```typescript +import { ToolChoice } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolChoice = "any"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Auto` | auto | -| `None` | none | -| `Any` | any | \ No newline at end of file +```typescript +"auto" | "none" | "any" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/toolmessage.md b/packages/mistralai-gcp/docs/models/components/toolmessage.md index e8135ba..7c33063 100644 --- a/packages/mistralai-gcp/docs/models/components/toolmessage.md +++ b/packages/mistralai-gcp/docs/models/components/toolmessage.md @@ -1,5 +1,14 @@ # ToolMessage +## Example Usage + +```typescript +import { ToolMessage } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolMessage = { + content: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/toolmessagerole.md b/packages/mistralai-gcp/docs/models/components/toolmessagerole.md index f4fd3c6..8322d1f 100644 --- a/packages/mistralai-gcp/docs/models/components/toolmessagerole.md +++ b/packages/mistralai-gcp/docs/models/components/toolmessagerole.md @@ -1,8 +1,15 @@ # ToolMessageRole +## Example Usage + +```typescript +import { ToolMessageRole } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolMessageRole = "tool"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `Tool` | tool | \ No newline at end of file +```typescript +"tool" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/tooltooltypes.md b/packages/mistralai-gcp/docs/models/components/tooltooltypes.md new file mode 100644 index 0000000..e42658c --- /dev/null +++ b/packages/mistralai-gcp/docs/models/components/tooltooltypes.md @@ -0,0 +1,17 @@ +# ToolToolTypes + +## Example Usage + +```typescript +import { ToolToolTypes } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/tooltypes.md b/packages/mistralai-gcp/docs/models/components/tooltypes.md new file mode 100644 index 0000000..64ea77d --- /dev/null +++ b/packages/mistralai-gcp/docs/models/components/tooltypes.md @@ -0,0 +1,17 @@ +# ToolTypes + +## Example Usage + +```typescript +import { ToolTypes } from "@mistralai/mistralai-gcp/models/components"; + +let value: ToolTypes = "function"; +``` + +## Values + +This is an open enum. Unrecognized values will be captured as the `Unrecognized` branded type. + +```typescript +"function" | Unrecognized +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/usageinfo.md b/packages/mistralai-gcp/docs/models/components/usageinfo.md index b317b51..2ca9f4c 100644 --- a/packages/mistralai-gcp/docs/models/components/usageinfo.md +++ b/packages/mistralai-gcp/docs/models/components/usageinfo.md @@ -1,5 +1,16 @@ # UsageInfo +## Example Usage + +```typescript +import { UsageInfo } from "@mistralai/mistralai-gcp/models/components"; + +let value: UsageInfo = { + promptTokens: 16, + completionTokens: 34, + totalTokens: 50, +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/usermessage.md b/packages/mistralai-gcp/docs/models/components/usermessage.md index 1e06816..329b206 100644 --- a/packages/mistralai-gcp/docs/models/components/usermessage.md +++ b/packages/mistralai-gcp/docs/models/components/usermessage.md @@ -1,5 +1,18 @@ # UserMessage +## Example Usage + +```typescript +import { UserMessage } from "@mistralai/mistralai-gcp/models/components"; + +let value: UserMessage = { + content: [ + { + text: "", + }, + ], +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/components/usermessagecontent.md b/packages/mistralai-gcp/docs/models/components/usermessagecontent.md index 2d9bd3f..5f400dd 100644 --- a/packages/mistralai-gcp/docs/models/components/usermessagecontent.md +++ b/packages/mistralai-gcp/docs/models/components/usermessagecontent.md @@ -1,5 +1,16 @@ # UserMessageContent +## Example Usage + +```typescript +import { UserMessageContent } from "@mistralai/mistralai-gcp/models/components"; + +let value: UserMessageContent = [ + { + text: "", + }, +]; +``` ## Supported Types diff --git a/packages/mistralai-gcp/docs/models/components/usermessagerole.md b/packages/mistralai-gcp/docs/models/components/usermessagerole.md index 30a5286..0c9f3ee 100644 --- a/packages/mistralai-gcp/docs/models/components/usermessagerole.md +++ b/packages/mistralai-gcp/docs/models/components/usermessagerole.md @@ -1,8 +1,15 @@ # UserMessageRole +## Example Usage + +```typescript +import { UserMessageRole } from "@mistralai/mistralai-gcp/models/components"; + +let value: UserMessageRole = "user"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `User` | user | \ No newline at end of file +```typescript +"user" +``` \ No newline at end of file diff --git a/packages/mistralai-gcp/docs/models/components/validationerror.md b/packages/mistralai-gcp/docs/models/components/validationerror.md index 865d485..a1ed7d2 100644 --- a/packages/mistralai-gcp/docs/models/components/validationerror.md +++ b/packages/mistralai-gcp/docs/models/components/validationerror.md @@ -1,5 +1,16 @@ # ValidationError +## Example Usage + +```typescript +import { ValidationError } from "@mistralai/mistralai-gcp/models/components"; + +let value: ValidationError = { + loc: [""], + msg: "", + type: "", +}; +``` ## Fields diff --git a/packages/mistralai-gcp/docs/models/errors/httpvalidationerror.md b/packages/mistralai-gcp/docs/models/errors/httpvalidationerror.md index 50ca4db..50f1ce9 100644 --- a/packages/mistralai-gcp/docs/models/errors/httpvalidationerror.md +++ b/packages/mistralai-gcp/docs/models/errors/httpvalidationerror.md @@ -2,6 +2,13 @@ Validation Error +## Example Usage + +```typescript +import { HTTPValidationError } from "@mistralai/mistralai-gcp/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/mistralai-gcp/jsr.json b/packages/mistralai-gcp/jsr.json index ccaf187..bbb4130 100644 --- a/packages/mistralai-gcp/jsr.json +++ b/packages/mistralai-gcp/jsr.json @@ -2,7 +2,7 @@ { "name": "@mistralai/mistralai-gcp", - "version": "1.0.2", + "version": "1.1.2", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/packages/mistralai-gcp/package-lock.json b/packages/mistralai-gcp/package-lock.json index 5c5cd94..b492dab 100644 --- a/packages/mistralai-gcp/package-lock.json +++ b/packages/mistralai-gcp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mistralai/mistralai-gcp", - "version": "1.0.2", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mistralai/mistralai-gcp", - "version": "1.0.2", + "version": "1.1.2", "dependencies": { "google-auth-library": "^9.11.0" }, diff --git a/packages/mistralai-gcp/package.json b/packages/mistralai-gcp/package.json index d287878..ac08081 100644 --- a/packages/mistralai-gcp/package.json +++ b/packages/mistralai-gcp/package.json @@ -1,6 +1,6 @@ { "name": "@mistralai/mistralai-gcp", - "version": "1.0.2", + "version": "1.1.2", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, diff --git a/packages/mistralai-gcp/src/lib/config.ts b/packages/mistralai-gcp/src/lib/config.ts index 50ea72e..201ff01 100644 --- a/packages/mistralai-gcp/src/lib/config.ts +++ b/packages/mistralai-gcp/src/lib/config.ts @@ -3,6 +3,7 @@ */ import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; import { RetryConfig } from "./retries.js"; import { Params, pathToFunc } from "./url.js"; @@ -34,6 +35,7 @@ export type SDKOptions = { */ retryConfig?: RetryConfig; timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { @@ -53,7 +55,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.2", - sdkVersion: "1.0.2", - genVersion: "2.390.6", - userAgent: "speakeasy-sdk/typescript 1.0.2 2.390.6 0.0.2 @mistralai/mistralai-gcp", + sdkVersion: "1.1.2", + genVersion: "2.399.0", + userAgent: "speakeasy-sdk/typescript 1.1.2 2.399.0 0.0.2 @mistralai/mistralai-gcp", } as const; diff --git a/packages/mistralai-gcp/src/lib/http.ts b/packages/mistralai-gcp/src/lib/http.ts index f8c544d..13cf1fd 100644 --- a/packages/mistralai-gcp/src/lib/http.ts +++ b/packages/mistralai-gcp/src/lib/http.ts @@ -157,7 +157,7 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { +export function matchContentType(response: Response, pattern: string): boolean { // `*` is a special case which means anything is acceptable. if (pattern === "*") { return true; diff --git a/packages/mistralai-gcp/src/lib/logger.ts b/packages/mistralai-gcp/src/lib/logger.ts new file mode 100644 index 0000000..d181f29 --- /dev/null +++ b/packages/mistralai-gcp/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/packages/mistralai-gcp/src/lib/sdks.ts b/packages/mistralai-gcp/src/lib/sdks.ts index 0e92ce7..51b49bd 100644 --- a/packages/mistralai-gcp/src/lib/sdks.ts +++ b/packages/mistralai-gcp/src/lib/sdks.ts @@ -4,6 +4,7 @@ import { HTTPClient, + matchContentType, matchStatusCode, isAbortError, isTimeoutError, @@ -11,6 +12,7 @@ import { } from "./http.js"; import { SecurityState } from "./security.js"; import { retry, RetryConfig } from "./retries.js"; +import { Logger } from "./logger.js"; import { encodeForm } from "./encodings.js"; import { stringToBase64 } from "./base64.js"; import { SDKOptions, SDK_METADATA, serverURLFromOptions } from "./config.js"; @@ -74,6 +76,7 @@ export class ClientSDK { private readonly httpClient: HTTPClient; protected readonly baseURL: URL | null; protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; public readonly options$: SDKOptions & { hooks?: SDKHooks }; constructor(options: SDKOptions = {}) { @@ -100,6 +103,7 @@ export class ClientSDK { }); this.baseURL = baseURL; this.httpClient = client; + this.logger = options.debugLogger; } public createRequest$( @@ -217,12 +221,13 @@ export class ClientSDK { return retry( async () => { - const req = request.clone(); - - let response = await this.httpClient.request( - await this.hooks$.beforeRequest(context, req) + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) ); + let response = await this.httpClient.request(req); + if (matchStatusCode(response, errorCodes)) { const result = await this.hooks$.afterError(context, response, null); if (result.error) { @@ -233,6 +238,10 @@ export class ClientSDK { response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req).catch((e) => + this.logger?.log("Failed to log response:", e) + ); + return response; }, { config: retryConfig, statusCodes: retryCodes } @@ -259,3 +268,90 @@ export class ClientSDK { ); } } + +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} + +async function logResponse(logger: Logger | undefined, res: Response, req: Request) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} diff --git a/packages/mistralai-gcp/src/models/components/chatcompletionchoice.ts b/packages/mistralai-gcp/src/models/components/chatcompletionchoice.ts index 9c6201f..45fbd2f 100644 --- a/packages/mistralai-gcp/src/models/components/chatcompletionchoice.ts +++ b/packages/mistralai-gcp/src/models/components/chatcompletionchoice.ts @@ -23,7 +23,7 @@ export type ChatCompletionChoiceFinishReason = ClosedEnum = z .object({ index: z.number().int(), - message: AssistantMessage$inboundSchema.optional(), + message: AssistantMessage$inboundSchema, finish_reason: ChatCompletionChoiceFinishReason$inboundSchema, }) .transform((v) => { @@ -68,7 +68,7 @@ export const ChatCompletionChoice$inboundSchema: z.ZodType< /** @internal */ export type ChatCompletionChoice$Outbound = { index: number; - message?: AssistantMessage$Outbound | undefined; + message: AssistantMessage$Outbound; finish_reason: string; }; @@ -80,7 +80,7 @@ export const ChatCompletionChoice$outboundSchema: z.ZodType< > = z .object({ index: z.number().int(), - message: AssistantMessage$outboundSchema.optional(), + message: AssistantMessage$outboundSchema, finishReason: ChatCompletionChoiceFinishReason$outboundSchema, }) .transform((v) => { diff --git a/packages/mistralai-gcp/src/models/components/chatcompletionrequest.ts b/packages/mistralai-gcp/src/models/components/chatcompletionrequest.ts index 1ac8ab2..8fdfea1 100644 --- a/packages/mistralai-gcp/src/models/components/chatcompletionrequest.ts +++ b/packages/mistralai-gcp/src/models/components/chatcompletionrequest.ts @@ -57,7 +57,7 @@ export type ChatCompletionRequestToolChoice = ClosedEnum; export type ChatCompletionStreamRequest = { /** - * ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. + * ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. */ model: string | null; /** diff --git a/packages/mistralai-gcp/src/models/components/contentchunk.ts b/packages/mistralai-gcp/src/models/components/contentchunk.ts index 40713a3..1a1ce72 100644 --- a/packages/mistralai-gcp/src/models/components/contentchunk.ts +++ b/packages/mistralai-gcp/src/models/components/contentchunk.ts @@ -11,7 +11,7 @@ export type ContentChunk = { /** @internal */ export const ContentChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/packages/mistralai-gcp/src/models/components/textchunk.ts b/packages/mistralai-gcp/src/models/components/textchunk.ts index afaae98..0cd4902 100644 --- a/packages/mistralai-gcp/src/models/components/textchunk.ts +++ b/packages/mistralai-gcp/src/models/components/textchunk.ts @@ -11,7 +11,7 @@ export type TextChunk = { /** @internal */ export const TextChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/packages/mistralai-gcp/src/models/components/tool.ts b/packages/mistralai-gcp/src/models/components/tool.ts index 6a56f6b..55ae3b4 100644 --- a/packages/mistralai-gcp/src/models/components/tool.ts +++ b/packages/mistralai-gcp/src/models/components/tool.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionT, FunctionT$inboundSchema, @@ -10,26 +11,51 @@ import { } from "./function.js"; import * as z from "zod"; +export const ToolToolTypes = { + Function: "function", +} as const; +export type ToolToolTypes = OpenEnum; + export type Tool = { - type?: "function" | undefined; + type?: ToolToolTypes | undefined; function: FunctionT; }; +/** @internal */ +export const ToolToolTypes$inboundSchema: z.ZodType = z.union( + [z.nativeEnum(ToolToolTypes), z.string().transform(catchUnrecognizedEnum)] +); + +/** @internal */ +export const ToolToolTypes$outboundSchema: z.ZodType = + z.union([z.nativeEnum(ToolToolTypes), z.string().and(z.custom>())]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolToolTypes$ { + /** @deprecated use `ToolToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolToolTypes$inboundSchema; + /** @deprecated use `ToolToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolToolTypes$outboundSchema; +} + /** @internal */ export const Tool$inboundSchema: z.ZodType = z.object({ - type: z.literal("function"), + type: ToolToolTypes$inboundSchema.default("function"), function: FunctionT$inboundSchema, }); /** @internal */ export type Tool$Outbound = { - type: "function"; + type: string; function: FunctionT$Outbound; }; /** @internal */ export const Tool$outboundSchema: z.ZodType = z.object({ - type: z.literal("function").default("function" as const), + type: ToolToolTypes$outboundSchema.default("function"), function: FunctionT$outboundSchema, }); diff --git a/packages/mistralai-gcp/src/models/components/toolcall.ts b/packages/mistralai-gcp/src/models/components/toolcall.ts index 56e05d0..35b0dca 100644 --- a/packages/mistralai-gcp/src/models/components/toolcall.ts +++ b/packages/mistralai-gcp/src/models/components/toolcall.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionCall, FunctionCall$inboundSchema, @@ -10,23 +11,51 @@ import { } from "./functioncall.js"; import * as z from "zod"; +export const ToolTypes = { + Function: "function", +} as const; +export type ToolTypes = OpenEnum; + export type ToolCall = { id?: string | undefined; - type?: "function" | undefined; + type?: ToolTypes | undefined; function: FunctionCall; }; +/** @internal */ +export const ToolTypes$inboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().transform(catchUnrecognizedEnum), +]); + +/** @internal */ +export const ToolTypes$outboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().and(z.custom>()), +]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolTypes$ { + /** @deprecated use `ToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolTypes$inboundSchema; + /** @deprecated use `ToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolTypes$outboundSchema; +} + /** @internal */ export const ToolCall$inboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function"), + type: ToolTypes$inboundSchema.default("function"), function: FunctionCall$inboundSchema, }); /** @internal */ export type ToolCall$Outbound = { id: string; - type: "function"; + type: string; function: FunctionCall$Outbound; }; @@ -34,7 +63,7 @@ export type ToolCall$Outbound = { export const ToolCall$outboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function").default("function" as const), + type: ToolTypes$outboundSchema.default("function"), function: FunctionCall$outboundSchema, }); diff --git a/packages/mistralai-gcp/src/models/errors/index.ts b/packages/mistralai-gcp/src/models/errors/index.ts index 570cd55..8a5df29 100644 --- a/packages/mistralai-gcp/src/models/errors/index.ts +++ b/packages/mistralai-gcp/src/models/errors/index.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +export * from "./httpclienterrors.js"; export * from "./httpvalidationerror.js"; export * from "./sdkerror.js"; export * from "./sdkvalidationerror.js"; diff --git a/packages/mistralai-gcp/src/models/errors/sdkvalidationerror.ts b/packages/mistralai-gcp/src/models/errors/sdkvalidationerror.ts index 3030cd7..16929b9 100644 --- a/packages/mistralai-gcp/src/models/errors/sdkvalidationerror.ts +++ b/packages/mistralai-gcp/src/models/errors/sdkvalidationerror.ts @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/packages/mistralai-gcp/src/types/constdatetime.ts b/packages/mistralai-gcp/src/types/constdatetime.ts new file mode 100644 index 0000000..c0a4409 --- /dev/null +++ b/packages/mistralai-gcp/src/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/src/lib/config.ts b/src/lib/config.ts index b77ded1..bf1d61b 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -3,6 +3,7 @@ */ import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; import { RetryConfig } from "./retries.js"; import { Params, pathToFunc } from "./url.js"; @@ -34,6 +35,7 @@ export type SDKOptions = { */ retryConfig?: RetryConfig; timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { @@ -53,7 +55,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.2", - sdkVersion: "1.0.2", - genVersion: "2.390.6", - userAgent: "speakeasy-sdk/typescript 1.0.2 2.390.6 0.0.2 @mistralai/mistralai", + sdkVersion: "1.1.2", + genVersion: "2.399.0", + userAgent: "speakeasy-sdk/typescript 1.1.2 2.399.0 0.0.2 @mistralai/mistralai", } as const; diff --git a/src/lib/http.ts b/src/lib/http.ts index f8c544d..13cf1fd 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -157,7 +157,7 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { +export function matchContentType(response: Response, pattern: string): boolean { // `*` is a special case which means anything is acceptable. if (pattern === "*") { return true; diff --git a/src/lib/logger.ts b/src/lib/logger.ts new file mode 100644 index 0000000..d181f29 --- /dev/null +++ b/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index 0e92ce7..51b49bd 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -4,6 +4,7 @@ import { HTTPClient, + matchContentType, matchStatusCode, isAbortError, isTimeoutError, @@ -11,6 +12,7 @@ import { } from "./http.js"; import { SecurityState } from "./security.js"; import { retry, RetryConfig } from "./retries.js"; +import { Logger } from "./logger.js"; import { encodeForm } from "./encodings.js"; import { stringToBase64 } from "./base64.js"; import { SDKOptions, SDK_METADATA, serverURLFromOptions } from "./config.js"; @@ -74,6 +76,7 @@ export class ClientSDK { private readonly httpClient: HTTPClient; protected readonly baseURL: URL | null; protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; public readonly options$: SDKOptions & { hooks?: SDKHooks }; constructor(options: SDKOptions = {}) { @@ -100,6 +103,7 @@ export class ClientSDK { }); this.baseURL = baseURL; this.httpClient = client; + this.logger = options.debugLogger; } public createRequest$( @@ -217,12 +221,13 @@ export class ClientSDK { return retry( async () => { - const req = request.clone(); - - let response = await this.httpClient.request( - await this.hooks$.beforeRequest(context, req) + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) ); + let response = await this.httpClient.request(req); + if (matchStatusCode(response, errorCodes)) { const result = await this.hooks$.afterError(context, response, null); if (result.error) { @@ -233,6 +238,10 @@ export class ClientSDK { response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req).catch((e) => + this.logger?.log("Failed to log response:", e) + ); + return response; }, { config: retryConfig, statusCodes: retryCodes } @@ -259,3 +268,90 @@ export class ClientSDK { ); } } + +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} + +async function logResponse(logger: Logger | undefined, res: Response, req: Request) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} diff --git a/src/models/components/agentscompletionstreamrequest.ts b/src/models/components/agentscompletionstreamrequest.ts index 00ea943..6d1fdf8 100644 --- a/src/models/components/agentscompletionstreamrequest.ts +++ b/src/models/components/agentscompletionstreamrequest.ts @@ -3,6 +3,32 @@ */ import { remap as remap$ } from "../../lib/primitives.js"; +import { ClosedEnum } from "../../types/enums.js"; +import { + AssistantMessage, + AssistantMessage$inboundSchema, + AssistantMessage$Outbound, + AssistantMessage$outboundSchema, +} from "./assistantmessage.js"; +import { + ResponseFormat, + ResponseFormat$inboundSchema, + ResponseFormat$Outbound, + ResponseFormat$outboundSchema, +} from "./responseformat.js"; +import { Tool, Tool$inboundSchema, Tool$Outbound, Tool$outboundSchema } from "./tool.js"; +import { + ToolMessage, + ToolMessage$inboundSchema, + ToolMessage$Outbound, + ToolMessage$outboundSchema, +} from "./toolmessage.js"; +import { + UserMessage, + UserMessage$inboundSchema, + UserMessage$Outbound, + UserMessage$outboundSchema, +} from "./usermessage.js"; import * as z from "zod"; /** @@ -10,23 +36,21 @@ import * as z from "zod"; */ export type AgentsCompletionStreamRequestStop = string | Array; +export type AgentsCompletionStreamRequestMessages = + | (UserMessage & { role: "user" }) + | (AssistantMessage & { role: "assistant" }) + | (ToolMessage & { role: "tool" }); + +export const AgentsCompletionStreamRequestToolChoice = { + Auto: "auto", + None: "none", + Any: "any", +} as const; +export type AgentsCompletionStreamRequestToolChoice = ClosedEnum< + typeof AgentsCompletionStreamRequestToolChoice +>; + export type AgentsCompletionStreamRequest = { - /** - * ID of the model to use. Only compatible for now with: - * - * @remarks - * - `codestral-2405` - * - `codestral-latest` - */ - model: string | null; - /** - * 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. - */ - temperature?: number | undefined; - /** - * 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. - */ - topP?: number | undefined; /** * 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. */ @@ -45,13 +69,20 @@ export type AgentsCompletionStreamRequest = { */ randomSeed?: number | null | undefined; /** - * The text/code to complete. + * The prompt(s) to generate completions for, encoded as a list of dict with role and content. */ - prompt: string; + messages: Array< + | (UserMessage & { role: "user" }) + | (AssistantMessage & { role: "assistant" }) + | (ToolMessage & { role: "tool" }) + >; + responseFormat?: ResponseFormat | undefined; + tools?: Array | null | undefined; + toolChoice?: AgentsCompletionStreamRequestToolChoice | undefined; /** - * 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`. + * The ID of the agent to use for this completion. */ - suffix?: string | null | undefined; + agentId: string; }; /** @internal */ @@ -84,6 +115,80 @@ export namespace AgentsCompletionStreamRequestStop$ { export type Outbound = AgentsCompletionStreamRequestStop$Outbound; } +/** @internal */ +export const AgentsCompletionStreamRequestMessages$inboundSchema: z.ZodType< + AgentsCompletionStreamRequestMessages, + z.ZodTypeDef, + unknown +> = z.union([ + UserMessage$inboundSchema.and( + z.object({ role: z.literal("user") }).transform((v) => ({ role: v.role })) + ), + AssistantMessage$inboundSchema.and( + z.object({ role: z.literal("assistant") }).transform((v) => ({ role: v.role })) + ), + ToolMessage$inboundSchema.and( + z.object({ role: z.literal("tool") }).transform((v) => ({ role: v.role })) + ), +]); + +/** @internal */ +export type AgentsCompletionStreamRequestMessages$Outbound = + | (UserMessage$Outbound & { role: "user" }) + | (AssistantMessage$Outbound & { role: "assistant" }) + | (ToolMessage$Outbound & { role: "tool" }); + +/** @internal */ +export const AgentsCompletionStreamRequestMessages$outboundSchema: z.ZodType< + AgentsCompletionStreamRequestMessages$Outbound, + z.ZodTypeDef, + AgentsCompletionStreamRequestMessages +> = z.union([ + UserMessage$outboundSchema.and( + z.object({ role: z.literal("user") }).transform((v) => ({ role: v.role })) + ), + AssistantMessage$outboundSchema.and( + z.object({ role: z.literal("assistant") }).transform((v) => ({ role: v.role })) + ), + ToolMessage$outboundSchema.and( + z.object({ role: z.literal("tool") }).transform((v) => ({ role: v.role })) + ), +]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AgentsCompletionStreamRequestMessages$ { + /** @deprecated use `AgentsCompletionStreamRequestMessages$inboundSchema` instead. */ + export const inboundSchema = AgentsCompletionStreamRequestMessages$inboundSchema; + /** @deprecated use `AgentsCompletionStreamRequestMessages$outboundSchema` instead. */ + export const outboundSchema = AgentsCompletionStreamRequestMessages$outboundSchema; + /** @deprecated use `AgentsCompletionStreamRequestMessages$Outbound` instead. */ + export type Outbound = AgentsCompletionStreamRequestMessages$Outbound; +} + +/** @internal */ +export const AgentsCompletionStreamRequestToolChoice$inboundSchema: z.ZodNativeEnum< + typeof AgentsCompletionStreamRequestToolChoice +> = z.nativeEnum(AgentsCompletionStreamRequestToolChoice); + +/** @internal */ +export const AgentsCompletionStreamRequestToolChoice$outboundSchema: z.ZodNativeEnum< + typeof AgentsCompletionStreamRequestToolChoice +> = AgentsCompletionStreamRequestToolChoice$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AgentsCompletionStreamRequestToolChoice$ { + /** @deprecated use `AgentsCompletionStreamRequestToolChoice$inboundSchema` instead. */ + export const inboundSchema = AgentsCompletionStreamRequestToolChoice$inboundSchema; + /** @deprecated use `AgentsCompletionStreamRequestToolChoice$outboundSchema` instead. */ + export const outboundSchema = AgentsCompletionStreamRequestToolChoice$outboundSchema; +} + /** @internal */ export const AgentsCompletionStreamRequest$inboundSchema: z.ZodType< AgentsCompletionStreamRequest, @@ -91,38 +196,56 @@ export const AgentsCompletionStreamRequest$inboundSchema: z.ZodType< unknown > = z .object({ - model: z.nullable(z.string()), - temperature: z.number().default(0.7), - top_p: z.number().default(1), max_tokens: z.nullable(z.number().int()).optional(), min_tokens: z.nullable(z.number().int()).optional(), stream: z.boolean().default(true), stop: z.union([z.string(), z.array(z.string())]).optional(), random_seed: z.nullable(z.number().int()).optional(), - prompt: z.string(), - suffix: z.nullable(z.string()).optional(), + messages: z.array( + z.union([ + UserMessage$inboundSchema.and( + z.object({ role: z.literal("user") }).transform((v) => ({ role: v.role })) + ), + AssistantMessage$inboundSchema.and( + z.object({ role: z.literal("assistant") }).transform((v) => ({ role: v.role })) + ), + ToolMessage$inboundSchema.and( + z.object({ role: z.literal("tool") }).transform((v) => ({ role: v.role })) + ), + ]) + ), + response_format: ResponseFormat$inboundSchema.optional(), + tools: z.nullable(z.array(Tool$inboundSchema)).optional(), + tool_choice: AgentsCompletionStreamRequestToolChoice$inboundSchema.default("auto"), + agent_id: z.string(), }) .transform((v) => { return remap$(v, { - top_p: "topP", max_tokens: "maxTokens", min_tokens: "minTokens", random_seed: "randomSeed", + response_format: "responseFormat", + tool_choice: "toolChoice", + agent_id: "agentId", }); }); /** @internal */ export type AgentsCompletionStreamRequest$Outbound = { - model: string | null; - temperature: number; - top_p: number; max_tokens?: number | null | undefined; min_tokens?: number | null | undefined; stream: boolean; stop?: string | Array | undefined; random_seed?: number | null | undefined; - prompt: string; - suffix?: string | null | undefined; + messages: Array< + | (UserMessage$Outbound & { role: "user" }) + | (AssistantMessage$Outbound & { role: "assistant" }) + | (ToolMessage$Outbound & { role: "tool" }) + >; + response_format?: ResponseFormat$Outbound | undefined; + tools?: Array | null | undefined; + tool_choice: string; + agent_id: string; }; /** @internal */ @@ -132,23 +255,37 @@ export const AgentsCompletionStreamRequest$outboundSchema: z.ZodType< AgentsCompletionStreamRequest > = z .object({ - model: z.nullable(z.string()), - temperature: z.number().default(0.7), - topP: z.number().default(1), maxTokens: z.nullable(z.number().int()).optional(), minTokens: z.nullable(z.number().int()).optional(), stream: z.boolean().default(true), stop: z.union([z.string(), z.array(z.string())]).optional(), randomSeed: z.nullable(z.number().int()).optional(), - prompt: z.string(), - suffix: z.nullable(z.string()).optional(), + messages: z.array( + z.union([ + UserMessage$outboundSchema.and( + z.object({ role: z.literal("user") }).transform((v) => ({ role: v.role })) + ), + AssistantMessage$outboundSchema.and( + z.object({ role: z.literal("assistant") }).transform((v) => ({ role: v.role })) + ), + ToolMessage$outboundSchema.and( + z.object({ role: z.literal("tool") }).transform((v) => ({ role: v.role })) + ), + ]) + ), + responseFormat: ResponseFormat$outboundSchema.optional(), + tools: z.nullable(z.array(Tool$outboundSchema)).optional(), + toolChoice: AgentsCompletionStreamRequestToolChoice$outboundSchema.default("auto"), + agentId: z.string(), }) .transform((v) => { return remap$(v, { - topP: "top_p", maxTokens: "max_tokens", minTokens: "min_tokens", randomSeed: "random_seed", + responseFormat: "response_format", + toolChoice: "tool_choice", + agentId: "agent_id", }); }); diff --git a/src/models/components/archiveftmodelout.ts b/src/models/components/archiveftmodelout.ts index 3c38cc7..764092b 100644 --- a/src/models/components/archiveftmodelout.ts +++ b/src/models/components/archiveftmodelout.ts @@ -14,7 +14,7 @@ export type ArchiveFTModelOut = { export const ArchiveFTModelOut$inboundSchema: z.ZodType = z.object({ id: z.string(), - object: z.literal("model"), + object: z.literal("model").default("model" as const), archived: z.boolean().default(true), }); diff --git a/src/models/components/chatcompletionchoice.ts b/src/models/components/chatcompletionchoice.ts index bc3b9f8..343df09 100644 --- a/src/models/components/chatcompletionchoice.ts +++ b/src/models/components/chatcompletionchoice.ts @@ -23,7 +23,7 @@ export type FinishReason = ClosedEnum; export type ChatCompletionChoice = { index: number; - message?: AssistantMessage | undefined; + message: AssistantMessage; finishReason: FinishReason; }; @@ -54,7 +54,7 @@ export const ChatCompletionChoice$inboundSchema: z.ZodType< > = z .object({ index: z.number().int(), - message: AssistantMessage$inboundSchema.optional(), + message: AssistantMessage$inboundSchema, finish_reason: FinishReason$inboundSchema, }) .transform((v) => { @@ -66,7 +66,7 @@ export const ChatCompletionChoice$inboundSchema: z.ZodType< /** @internal */ export type ChatCompletionChoice$Outbound = { index: number; - message?: AssistantMessage$Outbound | undefined; + message: AssistantMessage$Outbound; finish_reason: string; }; @@ -78,7 +78,7 @@ export const ChatCompletionChoice$outboundSchema: z.ZodType< > = z .object({ index: z.number().int(), - message: AssistantMessage$outboundSchema.optional(), + message: AssistantMessage$outboundSchema, finishReason: FinishReason$outboundSchema, }) .transform((v) => { diff --git a/src/models/components/chatcompletionrequest.ts b/src/models/components/chatcompletionrequest.ts index ec09ea0..3132d71 100644 --- a/src/models/components/chatcompletionrequest.ts +++ b/src/models/components/chatcompletionrequest.ts @@ -57,7 +57,7 @@ export type ToolChoice = ClosedEnum; export type ChatCompletionRequest = { /** - * ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. + * ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. */ model: string | null; /** diff --git a/src/models/components/chatcompletionstreamrequest.ts b/src/models/components/chatcompletionstreamrequest.ts index 1f63a69..b38fd96 100644 --- a/src/models/components/chatcompletionstreamrequest.ts +++ b/src/models/components/chatcompletionstreamrequest.ts @@ -59,7 +59,7 @@ export type ChatCompletionStreamRequestToolChoice = ClosedEnum< export type ChatCompletionStreamRequest = { /** - * ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions. + * ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions. */ model: string | null; /** diff --git a/src/models/components/contentchunk.ts b/src/models/components/contentchunk.ts index 40713a3..1a1ce72 100644 --- a/src/models/components/contentchunk.ts +++ b/src/models/components/contentchunk.ts @@ -11,7 +11,7 @@ export type ContentChunk = { /** @internal */ export const ContentChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/src/models/components/detailedjobout.ts b/src/models/components/detailedjobout.ts index 48a2c60..23f5849 100644 --- a/src/models/components/detailedjobout.ts +++ b/src/models/components/detailedjobout.ts @@ -121,7 +121,7 @@ export const DetailedJobOut$inboundSchema: z.ZodType = z .object({ id: z.string(), - object: z.literal("model"), + object: z.literal("model").default("model" as const), created: z.number().int(), owned_by: z.string(), root: z.string(), diff --git a/src/models/components/githubrepositoryin.ts b/src/models/components/githubrepositoryin.ts index 5457f0f..77fb31f 100644 --- a/src/models/components/githubrepositoryin.ts +++ b/src/models/components/githubrepositoryin.ts @@ -19,7 +19,7 @@ export const GithubRepositoryIn$inboundSchema: z.ZodType< z.ZodTypeDef, unknown > = z.object({ - type: z.literal("github"), + type: z.literal("github").default("github" as const), name: z.string(), owner: z.string(), ref: z.nullable(z.string()).optional(), diff --git a/src/models/components/githubrepositoryout.ts b/src/models/components/githubrepositoryout.ts index f8c5022..1d8beb1 100644 --- a/src/models/components/githubrepositoryout.ts +++ b/src/models/components/githubrepositoryout.ts @@ -21,7 +21,7 @@ export const GithubRepositoryOut$inboundSchema: z.ZodType< unknown > = z .object({ - type: z.literal("github"), + type: z.literal("github").default("github" as const), name: z.string(), owner: z.string(), ref: z.nullable(z.string()).optional(), diff --git a/src/models/components/jobout.ts b/src/models/components/jobout.ts index b59d664..13c2fe7 100644 --- a/src/models/components/jobout.ts +++ b/src/models/components/jobout.ts @@ -144,7 +144,7 @@ export const JobOut$inboundSchema: z.ZodType = z modified_at: z.number().int(), training_files: z.array(z.string()), validation_files: z.nullable(z.array(z.string())).optional(), - object: z.literal("job"), + object: z.literal("job").default("job" as const), fine_tuned_model: z.nullable(z.string()).optional(), suffix: z.nullable(z.string()).optional(), integrations: z.nullable(z.array(WandbIntegrationOut$inboundSchema)).optional(), diff --git a/src/models/components/jobsout.ts b/src/models/components/jobsout.ts index f2d8045..34a7d82 100644 --- a/src/models/components/jobsout.ts +++ b/src/models/components/jobsout.ts @@ -14,7 +14,7 @@ export type JobsOut = { /** @internal */ export const JobsOut$inboundSchema: z.ZodType = z.object({ data: z.array(JobOut$inboundSchema).optional(), - object: z.literal("list"), + object: z.literal("list").default("list" as const), total: z.number().int(), }); diff --git a/src/models/components/legacyjobmetadataout.ts b/src/models/components/legacyjobmetadataout.ts index 287b626..307658a 100644 --- a/src/models/components/legacyjobmetadataout.ts +++ b/src/models/components/legacyjobmetadataout.ts @@ -62,7 +62,7 @@ export const LegacyJobMetadataOut$inboundSchema: z.ZodType< details: z.string(), epochs: z.nullable(z.number()).optional(), training_steps: z.nullable(z.number().int()).optional(), - object: z.literal("job.metadata"), + object: z.literal("job.metadata").default("job.metadata" as const), }) .transform((v) => { return remap$(v, { diff --git a/src/models/components/textchunk.ts b/src/models/components/textchunk.ts index afaae98..0cd4902 100644 --- a/src/models/components/textchunk.ts +++ b/src/models/components/textchunk.ts @@ -11,7 +11,7 @@ export type TextChunk = { /** @internal */ export const TextChunk$inboundSchema: z.ZodType = z.object({ - type: z.literal("text"), + type: z.literal("text").default("text" as const), text: z.string(), }); diff --git a/src/models/components/tool.ts b/src/models/components/tool.ts index 6a56f6b..55ae3b4 100644 --- a/src/models/components/tool.ts +++ b/src/models/components/tool.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionT, FunctionT$inboundSchema, @@ -10,26 +11,51 @@ import { } from "./function.js"; import * as z from "zod"; +export const ToolToolTypes = { + Function: "function", +} as const; +export type ToolToolTypes = OpenEnum; + export type Tool = { - type?: "function" | undefined; + type?: ToolToolTypes | undefined; function: FunctionT; }; +/** @internal */ +export const ToolToolTypes$inboundSchema: z.ZodType = z.union( + [z.nativeEnum(ToolToolTypes), z.string().transform(catchUnrecognizedEnum)] +); + +/** @internal */ +export const ToolToolTypes$outboundSchema: z.ZodType = + z.union([z.nativeEnum(ToolToolTypes), z.string().and(z.custom>())]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolToolTypes$ { + /** @deprecated use `ToolToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolToolTypes$inboundSchema; + /** @deprecated use `ToolToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolToolTypes$outboundSchema; +} + /** @internal */ export const Tool$inboundSchema: z.ZodType = z.object({ - type: z.literal("function"), + type: ToolToolTypes$inboundSchema.default("function"), function: FunctionT$inboundSchema, }); /** @internal */ export type Tool$Outbound = { - type: "function"; + type: string; function: FunctionT$Outbound; }; /** @internal */ export const Tool$outboundSchema: z.ZodType = z.object({ - type: z.literal("function").default("function" as const), + type: ToolToolTypes$outboundSchema.default("function"), function: FunctionT$outboundSchema, }); diff --git a/src/models/components/toolcall.ts b/src/models/components/toolcall.ts index 56e05d0..35b0dca 100644 --- a/src/models/components/toolcall.ts +++ b/src/models/components/toolcall.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { catchUnrecognizedEnum, OpenEnum, Unrecognized } from "../../types/enums.js"; import { FunctionCall, FunctionCall$inboundSchema, @@ -10,23 +11,51 @@ import { } from "./functioncall.js"; import * as z from "zod"; +export const ToolTypes = { + Function: "function", +} as const; +export type ToolTypes = OpenEnum; + export type ToolCall = { id?: string | undefined; - type?: "function" | undefined; + type?: ToolTypes | undefined; function: FunctionCall; }; +/** @internal */ +export const ToolTypes$inboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().transform(catchUnrecognizedEnum), +]); + +/** @internal */ +export const ToolTypes$outboundSchema: z.ZodType = z.union([ + z.nativeEnum(ToolTypes), + z.string().and(z.custom>()), +]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ToolTypes$ { + /** @deprecated use `ToolTypes$inboundSchema` instead. */ + export const inboundSchema = ToolTypes$inboundSchema; + /** @deprecated use `ToolTypes$outboundSchema` instead. */ + export const outboundSchema = ToolTypes$outboundSchema; +} + /** @internal */ export const ToolCall$inboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function"), + type: ToolTypes$inboundSchema.default("function"), function: FunctionCall$inboundSchema, }); /** @internal */ export type ToolCall$Outbound = { id: string; - type: "function"; + type: string; function: FunctionCall$Outbound; }; @@ -34,7 +63,7 @@ export type ToolCall$Outbound = { export const ToolCall$outboundSchema: z.ZodType = z.object({ id: z.string().default("null"), - type: z.literal("function").default("function" as const), + type: ToolTypes$outboundSchema.default("function"), function: FunctionCall$outboundSchema, }); diff --git a/src/models/components/unarchiveftmodelout.ts b/src/models/components/unarchiveftmodelout.ts index 055fc2a..8fd0646 100644 --- a/src/models/components/unarchiveftmodelout.ts +++ b/src/models/components/unarchiveftmodelout.ts @@ -17,7 +17,7 @@ export const UnarchiveFTModelOut$inboundSchema: z.ZodType< unknown > = z.object({ id: z.string(), - object: z.literal("model"), + object: z.literal("model").default("model" as const), archived: z.boolean().default(false), }); diff --git a/src/models/components/wandbintegration.ts b/src/models/components/wandbintegration.ts index 0ee3cd7..490b418 100644 --- a/src/models/components/wandbintegration.ts +++ b/src/models/components/wandbintegration.ts @@ -25,7 +25,7 @@ export type WandbIntegration = { /** @internal */ export const WandbIntegration$inboundSchema: z.ZodType = z .object({ - type: z.literal("wandb"), + type: z.literal("wandb").default("wandb" as const), project: z.string(), name: z.nullable(z.string()).optional(), api_key: z.string(), diff --git a/src/models/components/wandbintegrationout.ts b/src/models/components/wandbintegrationout.ts index a3286a1..0275f40 100644 --- a/src/models/components/wandbintegrationout.ts +++ b/src/models/components/wandbintegrationout.ts @@ -25,7 +25,7 @@ export const WandbIntegrationOut$inboundSchema: z.ZodType< unknown > = z .object({ - type: z.literal("wandb"), + type: z.literal("wandb").default("wandb" as const), project: z.string(), name: z.nullable(z.string()).optional(), run_name: z.nullable(z.string()).optional(), diff --git a/src/models/errors/index.ts b/src/models/errors/index.ts index 570cd55..8a5df29 100644 --- a/src/models/errors/index.ts +++ b/src/models/errors/index.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +export * from "./httpclienterrors.js"; export * from "./httpvalidationerror.js"; export * from "./sdkerror.js"; export * from "./sdkvalidationerror.js"; diff --git a/src/models/errors/sdkvalidationerror.ts b/src/models/errors/sdkvalidationerror.ts index 3030cd7..16929b9 100644 --- a/src/models/errors/sdkvalidationerror.ts +++ b/src/models/errors/sdkvalidationerror.ts @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/src/models/operations/filesapiroutesuploadfile.ts b/src/models/operations/filesapiroutesuploadfile.ts index ee934ac..8a7adf9 100644 --- a/src/models/operations/filesapiroutesuploadfile.ts +++ b/src/models/operations/filesapiroutesuploadfile.ts @@ -67,7 +67,7 @@ export const FilesApiRoutesUploadFileMultiPartBodyParams$inboundSchema: z.ZodTyp unknown > = z.object({ file: z.lazy(() => FileT$inboundSchema), - purpose: z.literal("fine-tune"), + purpose: z.literal("fine-tune").default("fine-tune" as const), }); /** @internal */ diff --git a/src/types/constdatetime.ts b/src/types/constdatetime.ts new file mode 100644 index 0000000..c0a4409 --- /dev/null +++ b/src/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +}