/** * Mistral-specific message types for the Chat Completions API. * * These types mirror the shape expected by the Mistral SDK (`@mistralai/mistralai`) * and are used internally by the adapter to avoid tight coupling to the SDK's * exported types. * * @see https://docs.mistral.ai/api/ */ export interface ChatCompletionContentPartText { /** The text content. */ text: string; /** The type of the content part. */ type: 'text'; } export interface ChatCompletionContentPartImage { imageUrl: string | { url: string; detail?: 'auto' | 'low' | 'high'; }; /** The type of the content part. */ type: 'image_url'; } export interface ChatCompletionContentPartDocumentUrl { documentUrl: string; /** The type of the content part. */ type: 'document_url'; } export type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartDocumentUrl; export interface ChatCompletionMessageToolCall { /** The ID of the tool call. */ id: string; /** The type of the tool. Currently only `function` is supported. */ type?: 'function'; /** The function that the model called. */ function: { /** The name of the function to call. */ name: string; /** Arguments generated by the model as a JSON string. */ arguments: string; }; } export type FunctionParameters = { [key: string]: unknown; }; export interface FunctionDefinition { /** * The name of the function. Must be a-z, A-Z, 0-9, or contain underscores and * dashes, with a maximum length of 64. */ name: string; /** A description of what the function does. */ description?: string; /** Function parameters defined as a JSON Schema object. */ parameters?: FunctionParameters; /** Whether to enable strict schema adherence. */ strict?: boolean; } export interface ChatCompletionTool { /** The type of the tool. */ type: 'function'; function: FunctionDefinition; } export interface ChatCompletionNamedToolChoice { type: 'function'; function: { name: string; }; } /** * Controls which (if any) tool is called by the model. * * - `none` — never call tools * - `auto` — model decides * - `any` / `required` — model must call one or more tools * - Named tool choice — forces a specific tool */ export type ChatCompletionToolChoiceOption = 'none' | 'auto' | 'any' | 'required' | ChatCompletionNamedToolChoice; export interface ChatCompletionSystemMessageParam { role: 'system'; content: string | Array; } export interface ChatCompletionUserMessageParam { role: 'user'; content: string | Array; } export interface ChatCompletionAssistantMessageParam { role: 'assistant'; content?: string | Array | null; toolCalls?: Array; prefix?: boolean; } export interface ChatCompletionToolMessageParam { role: 'tool'; content: string | Array; toolCallId: string; name?: string; } export type ChatCompletionMessageParam = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam | ChatCompletionToolMessageParam; export interface ResponseFormatText { type: 'text'; } export interface ResponseFormatJsonObject { type: 'json_object'; } export interface ResponseFormatJsonSchema { type: 'json_schema'; jsonSchema: { name: string; description?: string; schemaDefinition: { [key: string]: unknown; }; strict?: boolean; }; } /** * Metadata for Mistral text content parts. */ export type MistralTextMetadata = Record; /** * Metadata for Mistral image content parts. */ export interface MistralImageMetadata { /** * Specifies the detail level of the image. * @default 'auto' */ detail?: 'auto' | 'low' | 'high'; } /** * Metadata for Mistral audio content parts. * Mistral does not currently support audio input. */ export type MistralAudioMetadata = Record; /** * Metadata for Mistral video content parts. * Mistral does not currently support video input. */ export type MistralVideoMetadata = Record; /** * Metadata for Mistral document content parts. * Used with document understanding models via `document_url` parts. */ export type MistralDocumentMetadata = Record; /** * Map of modality types to their Mistral-specific metadata types. */ export interface MistralMessageMetadataByModality { text: MistralTextMetadata; image: MistralImageMetadata; audio: MistralAudioMetadata; video: MistralVideoMetadata; document: MistralDocumentMetadata; }