diff --git a/cspell.config.yaml b/cspell.config.yaml index e94bc5a..2d3d79f 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -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 diff --git a/packages/providers/src/providers/index.ts b/packages/providers/src/providers/index.ts index cc64f1d..a9aed77 100644 --- a/packages/providers/src/providers/index.ts +++ b/packages/providers/src/providers/index.ts @@ -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' diff --git a/packages/providers/src/providers/mistral-ai.ts b/packages/providers/src/providers/mistral-ai.ts new file mode 100644 index 0000000..aabb064 --- /dev/null +++ b/packages/providers/src/providers/mistral-ai.ts @@ -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): + /** @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, + } +}