MistralFrontendAdapter
Defined in: adapters/mistral.ts:148
Frontend adapter interface.
Frontend adapters represent how developers want to interact with AI APIs. They normalize provider-specific request formats into universal IR and denormalize IR responses back to provider-specific formats.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MistralFrontendAdapter():
MistralFrontendAdapter
Returns
Section titled “Returns”MistralFrontendAdapter
Properties
Section titled “Properties”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata
Defined in: adapters/mistral.ts:149
Adapter metadata for identification and capabilities.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”fromIR()
Section titled “fromIR()”fromIR(
response):Promise<MistralResponse>
Defined in: adapters/mistral.ts:225
Convert Universal IR response back to Mistral API format.
This method transforms the standardized IR response into the format expected by Mistral’s API. It handles message conversion, finish reason mapping (stop, length, model_length), and usage statistics formatting specific to Mistral’s response structure.
Parameters
Section titled “Parameters”response
Section titled “response”Universal IR chat response
Returns
Section titled “Returns”Promise<MistralResponse>
Promise resolving to Mistral API response
Example
Section titled “Example”const adapter = new MistralFrontendAdapter();const mistralResponse = await adapter.fromIR(irResponse);console.log(mistralResponse.choices[0].message.content);Implementation of
Section titled “Implementation of”fromIRStream()
Section titled “fromIRStream()”fromIRStream(
stream,_options?):AsyncGenerator<string>
Defined in: adapters/mistral.ts:276
Convert Universal IR stream to Mistral Server-Sent Events format.
This async generator method transforms a stream of IR chunks into Mistral-formatted SSE responses. It yields Server-Sent Event strings with the “data: “ prefix containing JSON with delta content, and emits “data: [DONE]” when the stream completes.
Parameters
Section titled “Parameters”stream
Section titled “stream”AsyncGenerator<IRStreamChunk>
Universal IR chat stream
_options?
Section titled “_options?”Optional stream conversion options (currently unused)
Returns
Section titled “Returns”AsyncGenerator<string>
Yields
Section titled “Yields”Server-Sent Event formatted strings
Example
Section titled “Example”const adapter = new MistralFrontendAdapter();for await (const sseData of adapter.fromIRStream(irStream)) { console.log(sseData); // "data: {...}\n\n" or "data: [DONE]\n\n"}Implementation of
Section titled “Implementation of”toIR()
Section titled “toIR()”toIR(
request):Promise<IRChatRequest>
Defined in: adapters/mistral.ts:183
Convert Mistral API request to Universal IR format.
This method transforms a Mistral-formatted request into the standardized Intermediate Representation (IR) format. Since Mistral’s format is similar to OpenAI and close to IR, this is largely a pass-through adapter with field name mapping (e.g., random_seed → seed).
Parameters
Section titled “Parameters”request
Section titled “request”Mistral API request
Returns
Section titled “Returns”Promise<IRChatRequest>
Promise resolving to IR chat request
Example
Section titled “Example”const adapter = new MistralFrontendAdapter();const irRequest = await adapter.toIR({ model: 'mistral-small', messages: [{ role: 'user', content: 'Hello!' }], temperature: 0.7});