Skip to content

Commit

Permalink
✨ feat: support Mistral model provider (#1455)
Browse files Browse the repository at this point in the history
* ✨ feat: support mistral as model provider

* 🐛 fix: a test case bug

* ✅ add missing tests for anthropic and mistral
  • Loading branch information
danielglh authored Mar 7, 2024
1 parent 883fdd8 commit 4f94bfe
Show file tree
Hide file tree
Showing 78 changed files with 1,122 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ OPENAI_API_KEY=sk-xxxxxxxxx
# The local/remote ollama service url
# OLLAMA_PROXY_URL=http://127.0.0.1:11434/v1

########### Mistral AI Service ##########
########################################

#MISTRAL_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

########################################
######### Perplexity Service ##########
########################################
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,7 @@ ENV PERPLEXITY_API_KEY ""
# Anthropic
ENV ANTHROPIC_API_KEY ""

# Mistral
ENV MISTRAL_API_KEY ""

CMD ["node", "server.js"]
8 changes: 8 additions & 0 deletions docs/self-hosting/environment-variables/model-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,11 @@ When using the `turn` mode, the API Keys will be retrieved in a round-robin mann
- Default: -
- Example: `sk-ant-apixx-xxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx`

## Mistral AI

### `MISTRAL_API_KEY`

- Type: Required
- Description: This is the API key you applied for in the Mistral AI service
- Default: -
- Example: `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=`
11 changes: 10 additions & 1 deletion docs/self-hosting/environment-variables/model-provider.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,13 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
- 类型:必选
- 描述:这是你在 Anthropic AI 服务中申请的 API 密钥
- 默认值:-
- 示例:`sk-ant-apixx-xxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx`
- 示例:`sk-ant-apixx-xxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx`

## Mistral AI

### `MISTRAL_API_KEY`

- 类型:必选
- 描述:这是你在 Mistral AI 服务中申请的 API 密钥
- 默认值:-
- 示例:`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=`
1 change: 1 addition & 0 deletions locales/ar/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "أزور",
"bedrock": "بيدروك لأمازون ويب سيرفيس",
"google": "جوجل",
"mistral": "Mistral AI",
"moonshot": "مونشوت الذكاء الاصطناعي",
"ollama": "أولاما",
"oneapi": "وان آبي آي",
Expand Down
6 changes: 6 additions & 0 deletions locales/ar/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"InvalidAzureAPIKey": "مفتاح Azure API غير صحيح أو فارغ، يرجى التحقق من مفتاح Azure API وإعادة المحاولة",
"InvalidBedrockCredentials": "فشلت مصادقة Bedrock، يرجى التحقق من AccessKeyId/SecretAccessKey وإعادة المحاولة",
"InvalidGoogleAPIKey": "مفتاح Google API غير صحيح أو فارغ، يرجى التحقق من مفتاح Google API وإعادة المحاولة",
"InvalidMistralAPIKey": "مفتاح Mistral AI API غير صحيح أو فارغ، يرجى التحقق من مفتاح Mistral API وإعادة المحاولة",
"InvalidMoonshotAPIKey": "مفتاح API لـ Moonshot AI غير صحيح أو فارغ، يرجى التحقق من مفتاح API لـ Moonshot وإعادة المحاولة",
"InvalidOllamaArgs": "تكوين Ollama غير صحيح، يرجى التحقق من تكوين Ollama وإعادة المحاولة",
"InvalidPerplexityAPIKey": "مفتاح Perplexity API غير صحيح أو فارغ، يرجى التحقق من مفتاح Perplexity API وإعادة المحاولة",
"InvalidZhipuAPIKey": "مفتاح Zhipu API غير صحيح أو فارغ، يرجى التحقق من مفتاح Zhipu API وإعادة المحاولة",
"LocationNotSupportError": "عذرًا، لا يدعم موقعك الحالي خدمة هذا النموذج، قد يكون ذلك بسبب قيود المنطقة أو عدم توفر الخدمة. يرجى التحقق مما إذا كان الموقع الحالي يدعم استخدام هذه الخدمة، أو محاولة استخدام معلومات الموقع الأخرى.",
"MistralBizError": "طلب خدمة Mistral AI خاطئ، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
"MoonshotBizError": "حدث خطأ في خدمة جانب القمر، يرجى التحقق من المعلومات أدناه أو إعادة المحاولة",
"NoOpenAIAPIKey": "مفتاح API الخاص بـ OpenAI فارغ، يرجى إضافة مفتاح API الخاص بـ OpenAI",
"OllamaBizError": "خطأ في طلب خدمة Ollama، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
Expand Down Expand Up @@ -88,6 +90,10 @@
"description": "أدخل مفتاح Google API الخاص بك لبدء الجلسة. لن يقوم التطبيق بتسجيل مفتاح الواجهة البرمجية الخاص بك",
"title": "استخدام مفتاح Google API المخصص"
},
"Mistral": {
"description": "أدخل مفتاح Mistral AI API الخاص بك لبدء الجلسة. لن يتم تسجيل مفتاح الواجهة البرمجية الخاص بك من قبل التطبيق",
"title": "استخدام مفتاح Mistral AI API المخصص"
},
"Moonshot": {
"description": "قم بإدخال مفتاح API الخاص بك لـ Moonshot AI لبدء الجلسة. لن يتم تسجيل مفتاح الـ API الخاص بك من قبل التطبيق",
"title": "استخدام مفتاح API مخصص لـ Moonshot AI"
Expand Down
8 changes: 8 additions & 0 deletions locales/ar/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"title": "مفتاح واجهة برمجة التطبيقات"
}
},
"Mistral": {
"title": "Mistral AI",
"token": {
"desc": "أدخل مفتاح API من Mistral AI",
"placeholder": "مفتاح API من Mistral AI",
"title": "مفتاح API"
}
},
"Moonshot": {
"title": "الجانب المظلم من القمر",
"token": {
Expand Down
1 change: 1 addition & 0 deletions locales/de-DE/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "Azure",
"bedrock": "AWS Bedrock",
"google": "Google",
"mistral": "Mistral KI",
"moonshot": "Moonshot KI",
"ollama": "Ollama",
"oneapi": "One API",
Expand Down
6 changes: 6 additions & 0 deletions locales/de-DE/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"InvalidAzureAPIKey": "Der Azure API-Schlüssel ist ungültig oder leer. Bitte überprüfen Sie den Azure API-Schlüssel und versuchen Sie es erneut.",
"InvalidBedrockCredentials": "Die Bedrock-Authentifizierung ist fehlgeschlagen. Bitte überprüfen Sie AccessKeyId/SecretAccessKey und versuchen Sie es erneut.",
"InvalidGoogleAPIKey": "Der Google API-Schlüssel ist ungültig oder leer. Bitte überprüfen Sie den Google API-Schlüssel und versuchen Sie es erneut.",
"InvalidMistralAPIKey": "Der Mistral AI-API-Schlüssel ist ungültig oder leer. Bitte überprüfen Sie den Mistral-API-Schlüssel und versuchen Sie es erneut.",
"InvalidMoonshotAPIKey": "Ungültiger oder leerer Moonshot AI API-Schlüssel. Bitte überprüfen Sie den Moonshot API-Schlüssel und versuchen Sie es erneut.",
"InvalidOllamaArgs": "Ollama-Konfiguration ist ungültig. Bitte überprüfen Sie die Ollama-Konfiguration und versuchen Sie es erneut.",
"InvalidPerplexityAPIKey": "Perplexity API Key ist ungültig oder leer. Bitte überprüfen Sie den Perplexity API Key und versuchen Sie es erneut.",
"InvalidZhipuAPIKey": "Der Zhipu API-Schlüssel ist ungültig oder leer. Bitte überprüfen Sie den Zhipu API-Schlüssel und versuchen Sie es erneut.",
"LocationNotSupportError": "Entschuldigung, Ihr Standort unterstützt diesen Modellservice möglicherweise aufgrund von regionalen Einschränkungen oder nicht aktivierten Diensten nicht. Bitte überprüfen Sie, ob der aktuelle Standort die Verwendung dieses Dienstes unterstützt, oder versuchen Sie, andere Standortinformationen zu verwenden.",
"MistralBizError": "Beim Anfordern des Mistral AI-Dienstes ist ein Fehler aufgetreten. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
"MoonshotBizError": "Fehler beim Abrufen des Dark Side of the Moon-Services. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
"NoOpenAIAPIKey": "Der OpenAI-API-Schlüssel ist leer. Bitte fügen Sie einen benutzerdefinierten OpenAI-API-Schlüssel hinzu",
"OllamaBizError": "Fehler bei der Anforderung des Ollama-Dienstes. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
Expand Down Expand Up @@ -88,6 +90,10 @@
"description": "Geben Sie Ihren Google API-Schlüssel ein, um die Sitzung zu starten. Die Anwendung speichert Ihren API-Schlüssel nicht.",
"title": "Verwenden von benutzerdefinierten Google API-Schlüssel"
},
"Mistral": {
"description": "Geben Sie Ihren eigenen Mistral AI-API-Schlüssel ein, um die Sitzung zu starten. Die App speichert Ihren API-Schlüssel nicht.",
"title": "Verwenden Sie einen benutzerdefinierten Mistral AI-API-Schlüssel"
},
"Moonshot": {
"description": "Geben Sie Ihren individuellen Moonshot AI API-Schlüssel ein, um die Sitzung zu starten. Die App speichert Ihren API-Schlüssel nicht.",
"title": "Verwenden Sie einen benutzerdefinierten Moonshot AI API-Schlüssel"
Expand Down
8 changes: 8 additions & 0 deletions locales/de-DE/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"title": "API-Schlüssel"
}
},
"Mistral": {
"title": "Mistral KI",
"token": {
"desc": "Geben Sie den API-Schlüssel von Mistral KI ein",
"placeholder": "Mistral KI API-Schlüssel",
"title": "API-Schlüssel"
}
},
"Moonshot": {
"title": "月球着陆",
"token": {
Expand Down
1 change: 1 addition & 0 deletions locales/en-US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "Azure",
"bedrock": "AWS Bedrock",
"google": "Google",
"mistral": "Mistral AI",
"moonshot": "Moonshot AI",
"ollama": "Ollama",
"oneapi": "One API",
Expand Down
6 changes: 6 additions & 0 deletions locales/en-US/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"InvalidAzureAPIKey": "Azure API Key is incorrect or empty. Please check the Azure API Key and retry.",
"InvalidBedrockCredentials": "Bedrock authentication failed. Please check the AccessKeyId/SecretAccessKey and retry.",
"InvalidGoogleAPIKey": "Google API Key is incorrect or empty. Please check the Google API Key and retry.",
"InvalidMistralAPIKey": "Incorrect or empty Mistral AI API Key. Please check your Mistral API Key and try again.",
"InvalidMoonshotAPIKey": "The Moonshot AI API Key is incorrect or empty, please check the Moonshot API Key and try again.",
"InvalidOllamaArgs": "Invalid Ollama configuration, please check Ollama configuration and try again",
"InvalidPerplexityAPIKey": "Perplexity API Key is incorrect or empty. Please check the Perplexity API Key and retry.",
"InvalidZhipuAPIKey": "Zhipu API Key is incorrect or empty. Please check the Zhipu API Key and retry.",
"LocationNotSupportError": "We're sorry, your current location does not support this model service. This may be due to regional restrictions or the service not being available. Please confirm if the current location supports using this service, or try using a different location.",
"MistralBizError": "Error occurred while requesting Mistral AI service. Please troubleshoot based on the following information or retry.",
"MoonshotBizError": "There was an error with the Moonshot service, please troubleshoot or retry based on the following information.",
"NoOpenAIAPIKey": "OpenAI API Key is empty, please add a custom OpenAI API Key",
"OllamaBizError": "Error requesting Ollama service, please troubleshoot or retry based on the following information",
Expand Down Expand Up @@ -88,6 +90,10 @@
"description": "Enter your Google API Key to start the session. The app will not store your API Key.",
"title": "Use custom Google API Key"
},
"Mistral": {
"description": "Enter your Mistral AI API Key to start the session. The application will not store your API Key.",
"title": "Use Custom Mistral AI API Key"
},
"Moonshot": {
"description": "Enter your Moonshot AI API Key to start the session. The app will not store your API Key.",
"title": "Use Custom Moonshot AI API Key"
Expand Down
8 changes: 8 additions & 0 deletions locales/en-US/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"title": "API Key"
}
},
"Mistral": {
"title": "Mistral AI",
"token": {
"desc": "Enter the API Key from Mistral AI",
"placeholder": "Mistral AI API Key",
"title": "API Key"
}
},
"Moonshot": {
"title": "Dark Side of the Moon",
"token": {
Expand Down
1 change: 1 addition & 0 deletions locales/es-ES/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "Azure",
"bedrock": "AWS Bedrock",
"google": "Google",
"mistral": "Mistral IA",
"moonshot": "Moonshot IA",
"ollama": "Ollama",
"oneapi": "One API",
Expand Down
6 changes: 6 additions & 0 deletions locales/es-ES/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"InvalidAzureAPIKey": "La clave de API de Azure es incorrecta o está vacía, por favor, verifica la clave de API de Azure e inténtalo de nuevo",
"InvalidBedrockCredentials": "La autenticación de Bedrock no se ha completado con éxito, por favor, verifica AccessKeyId/SecretAccessKey e inténtalo de nuevo",
"InvalidGoogleAPIKey": "La clave de API de Google es incorrecta o está vacía, por favor, verifica la clave de API de Google e inténtalo de nuevo",
"InvalidMistralAPIKey": "La clave de API de Mistral AI es incorrecta o está vacía. Por favor, revise la clave de API de Mistral y vuelva a intentarlo.",
"InvalidMoonshotAPIKey": "La clave de API de Moonshot AI no es válida o está vacía. Por favor, revise la clave de API de Moonshot e inténtelo de nuevo.",
"InvalidOllamaArgs": "La configuración de Ollama no es válida, por favor revisa la configuración de Ollama e inténtalo de nuevo",
"InvalidPerplexityAPIKey": "La clave de API de Perplexity es inválida o está vacía. Por favor, verifica la clave de API de Perplexity e inténtalo de nuevo",
"InvalidZhipuAPIKey": "La clave de API de Zhipu es incorrecta o está vacía, por favor, verifica la clave de API de Zhipu e inténtalo de nuevo",
"LocationNotSupportError": "Lo sentimos, tu ubicación actual no es compatible con este servicio de modelo, puede ser debido a restricciones geográficas o a que el servicio no está disponible. Por favor, verifica si tu ubicación actual es compatible con este servicio o intenta usar otra información de ubicación.",
"MistralBizError": "Se produjo un error al solicitar el servicio Mistral AI. Por favor, revise la siguiente información o inténtelo de nuevo.",
"MoonshotBizError": "Se produjo un error al solicitar el servicio de Moonshot en el lado oscuro de la luna. Por favor, revise la siguiente información o inténtelo de nuevo.",
"NoOpenAIAPIKey": "La clave de API de OpenAI está vacía. Agregue una clave de API de OpenAI personalizada",
"OllamaBizError": "Error al solicitar el servicio de Ollama, por favor verifica la siguiente información o inténtalo de nuevo",
Expand Down Expand Up @@ -88,6 +90,10 @@
"description": "Ingresa tu clave de API de Google para comenzar la sesión. La aplicación no guardará tu clave de API",
"title": "Usar clave de API personalizada de Google"
},
"Mistral": {
"description": "Ingrese su clave de API de Mistral AI para comenzar la sesión. La aplicación no almacenará su clave de API.",
"title": "Usar clave de API personalizada de Mistral AI"
},
"Moonshot": {
"description": "Ingrese su clave de API de Moonshot AI personalizada para comenzar la sesión. La aplicación no almacenará su clave de API.",
"title": "Usar una clave de API personalizada de Moonshot AI"
Expand Down
8 changes: 8 additions & 0 deletions locales/es-ES/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"title": "Clave API"
}
},
"Mistral": {
"title": "Mistral AI",
"token": {
"desc": "Introduce la clave API de Mistral AI",
"placeholder": "Clave API de Mistral AI",
"title": "Clave API"
}
},
"Moonshot": {
"title": "Lado oscuro de la luna",
"token": {
Expand Down
1 change: 1 addition & 0 deletions locales/fr-FR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "Azure",
"bedrock": "AWS Bedrock",
"google": "Google",
"mistral": "Mistral AI",
"moonshot": "Moonshot IA",
"ollama": "Ollama",
"oneapi": "One API",
Expand Down
6 changes: 6 additions & 0 deletions locales/fr-FR/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"InvalidAzureAPIKey": "Clé API Azure incorrecte ou vide, veuillez vérifier la clé API Azure et réessayer",
"InvalidBedrockCredentials": "L'authentification Bedrock a échoué, veuillez vérifier AccessKeyId/SecretAccessKey et réessayer",
"InvalidGoogleAPIKey": "Clé API Google incorrecte ou vide, veuillez vérifier la clé API Google et réessayer",
"InvalidMistralAPIKey": "Clé API Mistral AI incorrecte ou manquante. Veuillez vérifier la clé API Mistral et réessayer.",
"InvalidMoonshotAPIKey": "Clé API Moonshot AI incorrecte ou manquante. Veuillez vérifier la clé API Moonshot et réessayer.",
"InvalidOllamaArgs": "La configuration d'Ollama n'est pas valide, veuillez vérifier la configuration d'Ollama et réessayer",
"InvalidPerplexityAPIKey": "La clé API Perplexity est incorrecte ou vide. Veuillez vérifier la clé API Perplexity et réessayer.",
"InvalidZhipuAPIKey": "Clé API Zhipu incorrecte ou vide, veuillez vérifier la clé API Zhipu et réessayer",
"LocationNotSupportError": "Désolé, votre emplacement actuel ne prend pas en charge ce service de modèle, peut-être en raison de restrictions géographiques ou de services non disponibles. Veuillez vérifier si votre emplacement actuel prend en charge ce service ou essayer avec une autre localisation.",
"MistralBizError": "Erreur de service Mistral AI. Veuillez vérifier les informations ci-dessous ou réessayer.",
"MoonshotBizError": "Erreur de service Moonshot : une erreur s'est produite lors de la demande du service Côté Obscur de la Lune. Veuillez vérifier les informations suivantes ou réessayer.",
"NoOpenAIAPIKey": "La clé API OpenAI est vide. Veuillez ajouter une clé API OpenAI personnalisée",
"OllamaBizError": "Erreur commerciale lors de la demande de service Ollama, veuillez vérifier les informations ci-dessous ou réessayer",
Expand Down Expand Up @@ -88,6 +90,10 @@
"description": "Entrez votre clé API Google pour commencer la session. L'application ne conservera pas votre clé API",
"title": "Utiliser une clé API Google personnalisée"
},
"Mistral": {
"description": "Entrez votre clé API Mistral AI pour commencer la session. L'application ne stockera pas votre clé API.",
"title": "Utiliser une clé API Mistral AI personnalisée"
},
"Moonshot": {
"description": "Entrez votre clé API Moonshot AI personnalisée pour commencer la session. L'application ne conservera pas votre clé API.",
"title": "Utiliser une clé API Moonshot AI personnalisée"
Expand Down
8 changes: 8 additions & 0 deletions locales/fr-FR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"title": "Clé API"
}
},
"Mistral": {
"title": "Mistral AI",
"token": {
"desc": "Veuillez saisir la clé API de Mistral AI",
"placeholder": "Clé API Mistral AI",
"title": "Clé API"
}
},
"Moonshot": {
"title": "月球着陆",
"token": {
Expand Down
1 change: 1 addition & 0 deletions locales/it-IT/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"azure": "Azure",
"bedrock": "AWS Bedrock",
"google": "Google",
"mistral": "Mistral AI",
"moonshot": "Moonshot AI",
"ollama": "Ollama",
"oneapi": "One API",
Expand Down
Loading

0 comments on commit 4f94bfe

Please sign in to comment.