feat(providers): add mistral-ai (#57)

This commit is contained in:
Neko authored and GitHub committed 2025-02-17 17:27:50 +08:00
1 parent 417343f31b
commit b58cf93de9
3 files changed
+47

No files matched your search

+3
View File
@@ -8,6 +8,7 @@ words:
- BAAI
- bumpp
- changelogithub
- codestral
- cognitivecomputations
- deepseek
- elevenlabs
@@ -18,6 +19,7 @@ words:
- importantimport
- koemotion
- masknet
- ministral
- mistralai
- mixtral
- moeru
@@ -32,6 +34,7 @@ words:
- ollama
- openrouter
- pkgroll
- Plateforme
- qwen
- reranker
- siliconflow
@@ -2,6 +2,7 @@ export * from './deepseek'
export * from './fireworks-ai'
export * from './google-generative-ai'
export * from './groq'
export * from './mistral-ai'
export * from './novita'
export * from './ollama'
export * from './openai'
@@ -0,0 +1,43 @@
import type { ChatProvider, EmbedProvider, ModelProvider, ProviderOptions, ProviderResult } from '../types'
import { generateCRO } from '../utils/generate-cro'
/**
* [Mistral AI](https://mistral.ai/) provider
*
* Mistral AI is a research lab building the best open source models in the world. La
* Plateforme enables developers and enterprises to build new products and applications,
* powered by Mistral's open source and commercial LLMs.
*
* @see {@link https://docs.mistral.ai/}
*
*/
export const createMistralAI = (userOptions: ProviderOptions<true>):
/** @see {@link https://docs.mistral.ai/getting-started/models/models_overview/} */
ChatProvider<
| 'codestral-latest'
| 'codestral-mamba-latest'
| 'ministral-3b-latest'
| 'ministral-8b-latest'
| 'mistral-large-latest'
| 'mistral-moderation-latest'
| 'mistral-small-latest'
| 'mistral-tiny-latest'
>
& EmbedProvider<
| 'mistral-embed'
>
& ModelProvider => {
const options: ProviderResult = {
...userOptions,
baseURL: userOptions.baseURL ?? new URL('https://api.mistral.ai/v1/'),
}
const result = (model: string) => generateCRO(model, options)
return {
chat: result,
embed: result,
model: () => options,
}
}