mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
✨ feat: support anthropic as model provider (#1409)
* ✨ feat: support anthropic as model provider * ✨ feat: support anthropic with vision * ✅ test: fix some with test * 🐛 fix: anthropic error handling * ✅ chore: fix broken tests * 🐛 fix: remove unused imports * 📝 doc: add note for anthropic with vercel/cloudflare * 📝 docs: update docs * 📝 docs: update docs * 💄 style: update claude icons * 💄 style: update tags --------- Co-authored-by: arvinxx <arvinx@foxmail.com>
This commit is contained in:
parent
00a2972cb3
commit
a42cf8c2ea
84 changed files with 944 additions and 9 deletions
12
.env.example
12
.env.example
|
|
@ -70,6 +70,18 @@ OPENAI_API_KEY=sk-xxxxxxxxx
|
|||
# The local/remote ollama service url
|
||||
# OLLAMA_PROXY_URL=http://127.0.0.1:11434/v1
|
||||
|
||||
########################################
|
||||
######### Perplexity Service ##########
|
||||
########################################
|
||||
|
||||
#PERPLEXITY_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
########################################
|
||||
######### Anthropic Service ##########
|
||||
########################################
|
||||
|
||||
#ANTHROPIC_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
########################################
|
||||
############ Market Service ############
|
||||
########################################
|
||||
|
|
|
|||
|
|
@ -83,4 +83,10 @@ ENV MOONSHOT_API_KEY ""
|
|||
# Ollama
|
||||
ENV OLLAMA_PROXY_URL ""
|
||||
|
||||
# Perplexity
|
||||
ENV PERPLEXITY_API_KEY ""
|
||||
|
||||
# Anthropic
|
||||
ENV ANTHROPIC_API_KEY ""
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
|
|
|
|||
|
|
@ -144,3 +144,27 @@ When using the `turn` mode, the API Keys will be retrieved in a round-robin mann
|
|||
- Description: Used to enable the Ollama service, setting this will display optional open-source language models in the language model list and can also specify custom language models
|
||||
- Default: -
|
||||
- Example: `http://127.0.0.1:11434/v1`
|
||||
|
||||
## Perplexity AI
|
||||
|
||||
### `PERPLEXITY_API_KEY`
|
||||
|
||||
- Type: Required
|
||||
- Description: This is the API key you applied from Perplexity AI
|
||||
- Default: -
|
||||
- Example: `pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
|
||||
|
||||
## Anthropic AI
|
||||
|
||||
### `ANTHROPIC_API_KEY`
|
||||
|
||||
- Type: Required
|
||||
- Description: This is the API key you applied from Anthropic AI
|
||||
- Default: -
|
||||
- Example: `sk-ant-apixx-xxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx`
|
||||
|
||||
|
||||
<Callout type={'warning'}>
|
||||
There's [a known issue](https://github.com/anthropics/anthropic-sdk-typescript/issues/292) with the official Anthropic SDK on Vercel/Cloudflare edge runtime, which causes chat streams to be interrupted randomly. If you want to use the Anthropic provider, do not use Vercel/Cloudflare for now; the Anthropic provider should be working fine with other hosting options.
|
||||
</Callout>
|
||||
|
||||
|
|
|
|||
|
|
@ -142,3 +142,28 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
|
|||
- 描述:用于启用 Ollama 服务,设置后可在语言模型列表内展示可选开源语言模型,也可以指定自定义语言模型
|
||||
- 默认值:-
|
||||
- 示例:`http://127.0.0.1:11434/v1`
|
||||
|
||||
## Perplexity AI
|
||||
|
||||
### `PERPLEXITY_API_KEY`
|
||||
|
||||
- 类型:必选
|
||||
- 描述:这是你在 Perplexity AI 服务中申请的 API 密钥
|
||||
- 默认值:-
|
||||
- 示例:`pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
|
||||
|
||||
## Anthropic AI
|
||||
|
||||
### `ANTHROPIC_API_KEY`
|
||||
|
||||
- 类型:必选
|
||||
- 描述:这是你在 Anthropic AI 服务中申请的 API 密钥
|
||||
- 默认值:-
|
||||
- 示例:`sk-ant-apixx-xxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx`
|
||||
|
||||
<Callout type={'warning'}>
|
||||
官方 Anthropic SDK 在 Vercel/Cloudflare
|
||||
边缘节点运行时存在一个[已知问题](https://github.com/anthropics/anthropic-sdk-typescript/issues/292)
|
||||
,会导致聊天流出现随机中断。如果您希望在 lobe-chat 中使用 Anthropic 模型,请暂时不要部署到
|
||||
Vercel/Cloudflare。Anthropic 模型在其他部署方式下可以正常工作。
|
||||
</Callout>
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "جاري تحميل التخطيط...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "أزور",
|
||||
"bedrock": "بيدروك لأمازون ويب سيرفيس",
|
||||
"google": "جوجل",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "عذرًا، الخادم غير قادر حاليًا على معالجة طلبك، قد يكون بسبب الحمل الزائد أو الصيانة الجارية، يرجى المحاولة مرة أخرى لاحقًا",
|
||||
"504": "عذرًا، الخادم لم ينتظر ردًا من الخادم الأصلي، يرجى المحاولة مرة أخرى لاحقًا",
|
||||
"AgentRuntimeError": "حدث خطأ في تشغيل نموذج Lobe اللغوي، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
|
||||
"AnthropicBizError": "خطأ في طلب خدمة Anthropic AI، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
|
||||
"AzureBizError": "حدث خطأ في طلب خدمة Azure AI، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
|
||||
"BedrockBizError": "حدث خطأ في طلب خدمة Bedrock، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
|
||||
"GoogleBizError": "حدث خطأ في طلب خدمة Google، يرجى التحقق من المعلومات التالية أو إعادة المحاولة",
|
||||
"InvalidAccessCode": "كلمة المرور غير صحيحة أو فارغة، يرجى إدخال كلمة مرور الوصول الصحيحة أو إضافة مفتاح API مخصص",
|
||||
"InvalidAnthropicAPIKey": "مفتاح Anthropic API غير صحيح أو فارغ، يرجى التحقق من مفتاح Anthropic API وإعادة المحاولة",
|
||||
"InvalidAzureAPIKey": "مفتاح Azure API غير صحيح أو فارغ، يرجى التحقق من مفتاح Azure API وإعادة المحاولة",
|
||||
"InvalidBedrockCredentials": "فشلت مصادقة Bedrock، يرجى التحقق من AccessKeyId/SecretAccessKey وإعادة المحاولة",
|
||||
"InvalidGoogleAPIKey": "مفتاح Google API غير صحيح أو فارغ، يرجى التحقق من مفتاح Google API وإعادة المحاولة",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "أدخل مفتاح Anthropic API الخاص بك للبدء في الجلسة. لن يقوم التطبيق بتسجيل مفتاح الواجهة البرمجية الخاص بك",
|
||||
"title": "استخدام مفتاح واجهة برمجة التطبيقات الخاص بـ Anthropic"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "منطقة خدمة مخصصة",
|
||||
"description": "أدخل مفتاح الوصول الخاص بك لـ Aws AccessKeyId / SecretAccessKey لبدء الجلسة. لن يقوم التطبيق بتسجيل تكوين المصادقة الخاص بك",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "إعدادات الجلسة · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "أنثروبيك",
|
||||
"token": {
|
||||
"desc": "أدخل مفتاح API من أنثروبيك",
|
||||
"placeholder": "مفتاح API من أنثروبيك",
|
||||
"title": "مفتاح API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "إصدار واجهة برمجة التطبيقات لـ Azure، يتبع تنسيق YYYY-MM-DD، راجع [أحدث الإصدار](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Layout wird geladen...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Entschuldigung, der Server kann Ihre Anfrage derzeit nicht verarbeiten. Möglicherweise aufgrund von Überlastung oder Wartungsarbeiten. Bitte versuchen Sie es später erneut",
|
||||
"504": "Entschuldigung, der Server hat keine Antwort vom Upstream-Server erhalten. Bitte versuchen Sie es später erneut",
|
||||
"AgentRuntimeError": "Es ist ein Fehler bei der Ausführung des Lobe-Sprachmodells aufgetreten. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
|
||||
"AnthropicBizError": "Fehler beim Anfordern des Anthropic AI-Dienstes. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
|
||||
"AzureBizError": "Es ist ein Fehler bei der Anforderung des Azure AI-Dienstes aufgetreten. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
|
||||
"BedrockBizError": "Es ist ein Fehler bei der Anforderung des Bedrock-Dienstes aufgetreten. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
|
||||
"GoogleBizError": "Es ist ein Fehler bei der Anforderung des Google-Dienstes aufgetreten. Bitte überprüfen Sie die folgenden Informationen oder versuchen Sie es erneut.",
|
||||
"InvalidAccessCode": "Das Passwort ist ungültig oder leer. Bitte geben Sie das richtige Zugangspasswort ein oder fügen Sie einen benutzerdefinierten API-Schlüssel hinzu.",
|
||||
"InvalidAnthropicAPIKey": "Ungültiger oder leerer Anthropic API-Schlüssel. Bitte überprüfen Sie den Anthropic API-Schlüssel und versuchen Sie es erneut.",
|
||||
"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.",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Geben Sie Ihren Anthropic API-Schlüssel ein, um die Sitzung zu starten. Die Anwendung speichert Ihren API-Schlüssel nicht.",
|
||||
"title": "Verwenden Sie einen benutzerdefinierten Anthropic API-Schlüssel"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Benutzerdefinierte Region",
|
||||
"description": "Geben Sie Ihre Aws AccessKeyId / SecretAccessKey ein, um die Sitzung zu starten. Die Anwendung speichert Ihre Authentifizierungsinformationen nicht.",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Sitzungseinstellungen · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Geben Sie den API-Schlüssel von Anthropic ein",
|
||||
"placeholder": "Anthropic API-Schlüssel",
|
||||
"title": "API-Schlüssel"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Die API-Version von Azure, die dem Format JJJJ-MM-TT folgt. Siehe [Neueste Version](https://learn.microsoft.com/de-de/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Initializing layout...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Sorry, the server is currently unable to process your request, possibly due to overload or maintenance. Please try again later.",
|
||||
"504": "Sorry, the server did not receive a response from the upstream server. Please try again later.",
|
||||
"AgentRuntimeError": "Lobe language model runtime execution error. Please troubleshoot or retry based on the following information.",
|
||||
"AnthropicBizError": "Error requesting Anthropic service. Please troubleshoot or retry based on the following information.",
|
||||
"AzureBizError": "Error requesting Azure AI service. Please troubleshoot or retry based on the following information.",
|
||||
"BedrockBizError": "Error requesting Bedrock service. Please troubleshoot or retry based on the following information.",
|
||||
"GoogleBizError": "Error requesting Google service. Please troubleshoot or retry based on the following information.",
|
||||
"InvalidAccessCode": "Invalid access code or empty. Please enter the correct access code or add a custom API Key.",
|
||||
"InvalidAnthropicAPIKey": "The Anthropic API Key is incorrect or empty. Please check the Anthropic API Key and retry.",
|
||||
"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.",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Enter your Anthropic API Key to start the session. The application will not store your API Key.",
|
||||
"title": "Use Custom Anthropic API Key"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Custom service region",
|
||||
"description": "Enter your Aws AccessKeyId / SecretAccessKey to start the session. The app will not store your authentication configuration.",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Session Settings · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Enter the API Key from Anthropic",
|
||||
"placeholder": "Anthropic API Key",
|
||||
"title": "API Key"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "The API version of Azure, following the format YYYY-MM-DD. Check the [latest version](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Inicializando diseño...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Antropico",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Lo sentimos, el servidor no puede procesar su solicitud en este momento, posiblemente debido a una sobrecarga o mantenimiento. Por favor, inténtelo de nuevo más tarde",
|
||||
"504": "Lo sentimos, el servidor no recibió respuesta del servidor upstream. Por favor, inténtelo de nuevo más tarde",
|
||||
"AgentRuntimeError": "Se produjo un error en la ejecución del tiempo de ejecución del modelo de lenguaje Lobe, por favor, verifica la siguiente información o inténtalo de nuevo",
|
||||
"AnthropicBizError": "Se ha producido un error al solicitar el servicio de inteligencia artificial de Anthropic. Por favor, revisa la siguiente información o inténtalo de nuevo.",
|
||||
"AzureBizError": "Se produjo un error al solicitar el servicio de Azure AI, por favor, verifica la siguiente información o inténtalo de nuevo",
|
||||
"BedrockBizError": "Se produjo un error al solicitar el servicio de Bedrock, por favor, verifica la siguiente información o inténtalo de nuevo",
|
||||
"GoogleBizError": "Se produjo un error al solicitar el servicio de Google, por favor, verifica la siguiente información o inténtalo de nuevo",
|
||||
"InvalidAccessCode": "La contraseña no es válida o está vacía. Por favor, introduce una contraseña de acceso válida o añade una clave API personalizada",
|
||||
"InvalidAnthropicAPIKey": "La clave de API de Anthropic es incorrecta o está vacía. Por favor, revisa la clave de API de Anthropic e inténtalo de nuevo.",
|
||||
"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",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Ingresa tu clave de API de Anthropic para comenzar la sesión. La aplicación no almacenará tu clave de API.",
|
||||
"title": "Usar una clave de API personalizada de Anthropic"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Región de servicio personalizada",
|
||||
"description": "Ingresa tu AccessKeyId/SecretAccessKey de Aws para comenzar la sesión. La aplicación no guardará tu configuración de autenticación",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Configuración de la sesión · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Introduce la clave API de Anthropic",
|
||||
"placeholder": "Clave API de Anthropic",
|
||||
"title": "Clave API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Versión de la API de Azure, en formato YYYY-MM-DD. Consulta la [última versión](https://learn.microsoft.com/es-es/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Initialisation de la mise en page en cours...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Désolé, le serveur ne peut actuellement pas traiter votre requête, probablement en raison d'une surcharge ou de travaux de maintenance. Veuillez réessayer plus tard",
|
||||
"504": "Désolé, le serveur n'a pas reçu de réponse de la part du serveur amont. Veuillez réessayer plus tard",
|
||||
"AgentRuntimeError": "Erreur d'exécution du modèle linguistique Lobe, veuillez vérifier les informations ci-dessous ou réessayer",
|
||||
"AnthropicBizError": "Erreur commerciale lors de la demande de service Anthropic AI. Veuillez vérifier les informations ci-dessous ou réessayer.",
|
||||
"AzureBizError": "Erreur lors de la demande de service Azure AI, veuillez vérifier les informations ci-dessous ou réessayer",
|
||||
"BedrockBizError": "Erreur lors de la demande de service Bedrock, veuillez vérifier les informations ci-dessous ou réessayer",
|
||||
"GoogleBizError": "Erreur lors de la demande de service Google, veuillez vérifier les informations ci-dessous ou réessayer",
|
||||
"InvalidAccessCode": "Le mot de passe est incorrect ou vide. Veuillez saisir le mot de passe d'accès correct ou ajouter une clé API personnalisée.",
|
||||
"InvalidAnthropicAPIKey": "La clé API Anthropic est incorrecte ou manquante. Veuillez vérifier la clé API Anthropic et réessayer.",
|
||||
"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",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Entrez votre clé API Anthropic pour commencer la session. L'application ne stockera pas votre clé API.",
|
||||
"title": "Utiliser une clé API Anthropic personnalisée"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Région de service personnalisée",
|
||||
"description": "Entrez votre AccessKeyId/SecretAccessKey AWS pour commencer la session. L'application ne conservera pas votre configuration d'authentification",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Paramètres de session · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Entrez votre clé API Anthropic",
|
||||
"placeholder": "Clé API Anthropic",
|
||||
"title": "Clé API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Version de l'API Azure, au format YYYY-MM-DD. Consultez la [dernière version](https://learn.microsoft.com/fr-fr/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Inizializzazione layout in corso...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Antropico",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Spiacenti, il server non può elaborare la tua richiesta al momento, probabilmente a causa di sovraccarico o manutenzione in corso. Riprova più tardi",
|
||||
"504": "Spiacenti, il server non ha ricevuto risposta dal server upstream. Riprova più tardi",
|
||||
"AgentRuntimeError": "Errore di esecuzione del modello linguistico Lobe, controlla le informazioni seguenti o riprova",
|
||||
"AnthropicBizError": "Si è verificato un errore durante la richiesta del servizio Anthropic AI. Si prega di controllare le informazioni seguenti o riprovare.",
|
||||
"AzureBizError": "Errore nella richiesta del servizio Azure AI, controlla le informazioni seguenti o riprova",
|
||||
"BedrockBizError": "Errore nella richiesta del servizio Bedrock, controlla le informazioni seguenti o riprova",
|
||||
"GoogleBizError": "Errore nella richiesta del servizio Google, controlla le informazioni seguenti o riprova",
|
||||
"InvalidAccessCode": "Password incorrect or empty, please enter the correct access password, or add a custom API Key",
|
||||
"InvalidAnthropicAPIKey": "La chiave API Anthropic non è valida o è vuota. Si prega di controllare la chiave API Anthropic e riprovare.",
|
||||
"InvalidAzureAPIKey": "Chiave API Azure non corretta o vuota, controlla la chiave API Azure e riprova",
|
||||
"InvalidBedrockCredentials": "Autenticazione Bedrock non riuscita, controlla AccessKeyId/SecretAccessKey e riprova",
|
||||
"InvalidGoogleAPIKey": "Chiave API Google non corretta o vuota, controlla la chiave API Google e riprova",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Inserisci la tua chiave API Anthropic per avviare la sessione. L'applicazione non memorizzerà la tua chiave API.",
|
||||
"title": "Utilizza una chiave API Anthropic personalizzata"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Regione del servizio personalizzata",
|
||||
"description": "Inserisci il tuo Aws AccessKeyId / SecretAccessKey per iniziare la sessione. L'applicazione non memorizzerà la tua configurazione di autenticazione",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Impostazioni della sessione · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Inserisci la chiave API di Anthropic",
|
||||
"placeholder": "Chiave API di Anthropic",
|
||||
"title": "Chiave API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Versione dell'API di Azure, nel formato YYYY-MM-DD, consulta la [versione più recente](https://learn.microsoft.com/it-it/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "レイアウトを初期化中...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWSベッドロック",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "申し訳ありませんが、サーバーは現在、リクエストを処理できません。オーバーロードまたはメンテナンス中の可能性があります。しばらくしてから再試行してください",
|
||||
"504": "申し訳ありませんが、サーバーは上位サーバーからの応答を待っていません。しばらくしてから再試行してください",
|
||||
"AgentRuntimeError": "Lobe言語モデルの実行時にエラーが発生しました。以下の情報に基づいてトラブルシューティングを行うか、再試行してください。",
|
||||
"AnthropicBizError": "Anthropic AIサービスのリクエストでエラーが発生しました。以下の情報に基づいてトラブルシューティングを行うか、再度お試しください。",
|
||||
"AzureBizError": "Azure AIサービスのリクエストでエラーが発生しました。以下の情報に基づいてトラブルシューティングを行うか、再試行してください。",
|
||||
"BedrockBizError": "Bedrockサービスのリクエストでエラーが発生しました。以下の情報に基づいてトラブルシューティングを行うか、再試行してください。",
|
||||
"GoogleBizError": "Googleサービスのリクエストでエラーが発生しました。以下の情報に基づいてトラブルシューティングを行うか、再試行してください。",
|
||||
"InvalidAccessCode": "パスワードが正しくないか空です。正しいアクセスパスワードを入力するか、カスタムAPIキーを追加してください",
|
||||
"InvalidAnthropicAPIKey": "Anthropic APIキーが正しくないか空です。Anthropic APIキーを確認してもう一度お試しください。",
|
||||
"InvalidAzureAPIKey": "Azure APIキーが正しくないか空です。Azure APIキーを確認してから再試行してください。",
|
||||
"InvalidBedrockCredentials": "Bedrockの認証に失敗しました。AccessKeyId/SecretAccessKeyを確認してから再試行してください。",
|
||||
"InvalidGoogleAPIKey": "Google APIキーが正しくないか空です。Google APIキーを確認してから再試行してください。",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Anthropic APIキーを入力してセッションを開始します。アプリはAPIキーを記録しません。",
|
||||
"title": "カスタムAnthropic APIキーを使用"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "自定义服务区域",
|
||||
"description": "Aws AccessKeyId / SecretAccessKeyを入力してセッションを開始します。アプリは認証構成を記録しません。",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "セッション設定 · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Anthropic の API キーを入力してください",
|
||||
"placeholder": "Anthropic API キー",
|
||||
"title": "API キー"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "AzureのAPIバージョン。YYYY-MM-DD形式に従う。[最新バージョン](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)を参照",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "레이아웃을 불러오는 중...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "죄송합니다. 서버가 현재 요청을 처리할 수 없습니다. 과부하 또는 유지 보수 중일 수 있습니다. 잠시 후에 다시 시도해주세요.",
|
||||
"504": "죄송합니다. 서버가 상위 서버의 응답을 기다리지 못했습니다. 잠시 후에 다시 시도해주세요.",
|
||||
"AgentRuntimeError": "Lobe 언어 모델 실행 중 오류가 발생했습니다. 아래 정보를 확인하고 다시 시도하십시오.",
|
||||
"AnthropicBizError": "Anthropic AI 서비스 요청 중 오류가 발생했습니다. 다음 정보를 확인하고 다시 시도하십시오.",
|
||||
"AzureBizError": "Azure AI 서비스 요청 중 오류가 발생했습니다. 아래 정보를 확인하고 다시 시도하십시오.",
|
||||
"BedrockBizError": "Bedrock 서비스 요청 중 오류가 발생했습니다. 아래 정보를 확인하고 다시 시도하십시오.",
|
||||
"GoogleBizError": "Google 서비스 요청 중 오류가 발생했습니다. 아래 정보를 확인하고 다시 시도하십시오.",
|
||||
"InvalidAccessCode": "액세스 코드가 잘못되었거나 비어 있습니다. 올바른 액세스 코드를 입력하거나 사용자 지정 API 키를 추가하십시오.",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API 키가 잘못되었거나 비어 있습니다. Anthropic API 키를 확인하고 다시 시도하십시오.",
|
||||
"InvalidAzureAPIKey": "잘못된 또는 비어 있는 Azure API Key입니다. Azure API Key를 확인한 후 다시 시도하십시오.",
|
||||
"InvalidBedrockCredentials": "Bedrock 인증에 실패했습니다. AccessKeyId/SecretAccessKey를 확인한 후 다시 시도하십시오.",
|
||||
"InvalidGoogleAPIKey": "잘못된 또는 비어 있는 Google API Key입니다. Google API Key를 확인한 후 다시 시도하십시오.",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "사용자 정의 Anthropic API 키를 입력하면 세션을 시작할 수 있습니다. 애플리케이션은 API 키를 기록하지 않습니다.",
|
||||
"title": "사용자 정의 Anthropic API 키 사용"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "사용자 정의 서비스 지역",
|
||||
"description": "Aws AccessKeyId / SecretAccessKey를 입력하여 세션을 시작합니다. 앱은 귀하의 인증 구성을 기록하지 않습니다.",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "세션 설정 · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Anthropic의 API 키를 입력하세요",
|
||||
"placeholder": "Anthropic API 키",
|
||||
"title": "API 키"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Azure의 API 버전은 YYYY-MM-DD 형식을 따르며, [최신 버전](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)을 확인하세요.",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Lay-out wordt geladen...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Sorry, de server kan uw verzoek momenteel niet verwerken vanwege overbelasting of onderhoud. Probeer het later opnieuw",
|
||||
"504": "Sorry, de server heeft geen reactie ontvangen van de upstream server. Probeer het later opnieuw",
|
||||
"AgentRuntimeError": "Lobe language model runtime execution error, please troubleshoot or retry based on the following information",
|
||||
"AnthropicBizError": "Er is een fout opgetreden bij het aanvragen van de Anthropic AI-service. Controleer de onderstaande informatie en probeer het opnieuw.",
|
||||
"AzureBizError": "Error requesting Azure AI service, please troubleshoot or retry based on the following information",
|
||||
"BedrockBizError": "Error requesting Bedrock service, please troubleshoot or retry based on the following information",
|
||||
"GoogleBizError": "Error requesting Google service, please troubleshoot or retry based on the following information",
|
||||
"InvalidAccessCode": "Ongeldige toegangscode: het wachtwoord is onjuist of leeg. Voer de juiste toegangscode in of voeg een aangepaste API-sleutel toe.",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API Key is onjuist of leeg. Controleer de Anthropic API Key en probeer het opnieuw.",
|
||||
"InvalidAzureAPIKey": "Incorrect or empty Azure API Key, please check the Azure API Key and retry",
|
||||
"InvalidBedrockCredentials": "Bedrock authentication failed, please check AccessKeyId/SecretAccessKey and retry",
|
||||
"InvalidGoogleAPIKey": "Incorrect or empty Google API Key, please check the Google API Key and retry",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Voer uw eigen Anthropic API Key in om een sessie te starten. De app zal uw API Key niet opslaan.",
|
||||
"title": "Gebruik een aangepaste Anthropic API Key"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Custom service region",
|
||||
"description": "Enter your Aws AccessKeyId / SecretAccessKey to start the session. The app will not record your authentication configuration",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Sessie-instellingen · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Voer de API-sleutel van Anthropic in",
|
||||
"placeholder": "Anthropic API-sleutel",
|
||||
"title": "API-sleutel"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Azure API-versie, in het formaat YYYY-MM-DD, raadpleeg de [laatste versie](https://learn.microsoft.com/nl-nl/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Inicjowanie układu...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Antropiczny",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Przepraszamy, serwer tymczasowo nie może przetworzyć Twojego żądania, prawdopodobnie z powodu przeciążenia lub konserwacji. Proszę spróbuj ponownie później",
|
||||
"504": "Przepraszamy, serwer nie otrzymał odpowiedzi od serwera nadrzędnego. Proszę spróbuj ponownie później",
|
||||
"AgentRuntimeError": "Wystąpił błąd wykonania modelu językowego Lobe, prosimy o sprawdzenie poniższych informacji lub ponowne próbowanie.",
|
||||
"AnthropicBizError": "Wystąpił błąd biznesowy podczas żądania usługi Anthropic AI. Sprawdź poniższe informacje i spróbuj ponownie.",
|
||||
"AzureBizError": "Wystąpił błąd żądania usługi Azure AI, prosimy o sprawdzenie poniższych informacji lub ponowne próbowanie.",
|
||||
"BedrockBizError": "Wystąpił błąd żądania usługi Bedrock, prosimy o sprawdzenie poniższych informacji lub ponowne próbowanie.",
|
||||
"GoogleBizError": "Wystąpił błąd żądania usługi Google, prosimy o sprawdzenie poniższych informacji lub ponowne próbowanie.",
|
||||
"InvalidAccessCode": "Nieprawidłowy kod dostępu: Hasło jest nieprawidłowe lub puste. Proszę wprowadzić poprawne hasło dostępu lub dodać niestandardowy klucz API.",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API Key jest nieprawidłowy lub pusty. Sprawdź poprawność klucza API Anthropic i spróbuj ponownie.",
|
||||
"InvalidAzureAPIKey": "Nieprawidłowy lub pusty klucz API Azure, prosimy sprawdzić klucz API Azure i spróbować ponownie.",
|
||||
"InvalidBedrockCredentials": "Uwierzytelnienie Bedrock nie powiodło się, prosimy sprawdzić AccessKeyId/SecretAccessKey i spróbować ponownie.",
|
||||
"InvalidGoogleAPIKey": "Nieprawidłowy lub pusty klucz API Google, prosimy sprawdzić klucz API Google i spróbować ponownie.",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Wprowadź swój klucz API Anthropic, aby rozpocząć sesję. Aplikacja nie będzie przechowywać Twojego klucza API.",
|
||||
"title": "Użyj niestandardowego klucza API Anthropic"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Własny obszar usług",
|
||||
"description": "Wprowadź swój Aws AccessKeyId / SecretAccessKey, aby rozpocząć sesję. Aplikacja nie będzie przechowywać Twojej konfiguracji uwierzytelniania.",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Ustawienia sesji · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Antropijny",
|
||||
"token": {
|
||||
"desc": "Wprowadź klucz API z Anthropic",
|
||||
"placeholder": "Klucz API Anthropic",
|
||||
"title": "Klucz API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Wersja API usługi Azure, zgodna z formatem RRRR-MM-DD, zobacz [najnowszą wersję](https://learn.microsoft.com/pl-pl/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Inicializando layout...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Antropogênico",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Desculpe, o servidor não pode processar sua solicitação no momento, possivelmente devido a sobrecarga ou manutenção. Por favor, tente novamente mais tarde",
|
||||
"504": "Desculpe, o servidor não recebeu resposta do servidor upstream. Por favor, tente novamente mais tarde",
|
||||
"AgentRuntimeError": "Erro de execução do modelo de linguagem Lobe, por favor, verifique as informações abaixo ou tente novamente",
|
||||
"AnthropicBizError": "Erro de negócios ao solicitar o serviço Anthropic AI. Por favor, verifique as informações abaixo ou tente novamente.",
|
||||
"AzureBizError": "Erro ao solicitar o serviço Azure AI, por favor, verifique as informações abaixo ou tente novamente",
|
||||
"BedrockBizError": "Erro ao solicitar o serviço Bedrock, por favor, verifique as informações abaixo ou tente novamente",
|
||||
"GoogleBizError": "Erro ao solicitar o serviço Google, por favor, verifique as informações abaixo ou tente novamente",
|
||||
"InvalidAccessCode": "Senha de acesso inválida ou em branco. Por favor, insira a senha de acesso correta ou adicione uma Chave de API personalizada.",
|
||||
"InvalidAnthropicAPIKey": "A chave da API Anthropic está incorreta ou vazia. Por favor, verifique a chave da API Anthropic e tente novamente.",
|
||||
"InvalidAzureAPIKey": "Chave de API Azure incorreta ou vazia, por favor, verifique a chave de API Azure e tente novamente",
|
||||
"InvalidBedrockCredentials": "Credenciais Bedrock inválidas, por favor, verifique AccessKeyId/SecretAccessKey e tente novamente",
|
||||
"InvalidGoogleAPIKey": "Chave de API Google incorreta ou vazia, por favor, verifique a chave de API Google e tente novamente",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Insira sua chave da API Anthropic para iniciar a sessão. O aplicativo não irá armazenar sua chave da API.",
|
||||
"title": "Usar chave da API Anthropic personalizada"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Região de serviço personalizada",
|
||||
"description": "Digite seu Aws AccessKeyId / SecretAccessKey para iniciar a sessão. O aplicativo não irá armazenar suas configurações de autenticação",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Configurações de Sessão · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Insira a chave da API da Anthropic",
|
||||
"placeholder": "Chave da API da Anthropic",
|
||||
"title": "Chave da API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Versão da API do Azure, seguindo o formato YYYY-MM-DD, consulte a [última versão](https://learn.microsoft.com/pt-br/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Инициализация макета...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Антропный",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "К сожалению, сервер в настоящее время не может обработать ваш запрос, возможно, из-за перегрузки или технического обслуживания. Повторите попытку позже.",
|
||||
"504": "К сожалению, сервер не получил ответа от вышестоящего сервера. Повторите попытку позже.",
|
||||
"AgentRuntimeError": "Ошибка выполнения времени выполнения языковой модели Lobe, пожалуйста, проверьте и повторите попытку в соответствии с предоставленной информацией",
|
||||
"AnthropicBizError": "Ошибка запроса к сервису Anthropic AI. Пожалуйста, проверьте информацию ниже или повторите попытку",
|
||||
"AzureBizError": "Ошибка запроса службы Azure AI, пожалуйста, проверьте и повторите попытку в соответствии с предоставленной информацией",
|
||||
"BedrockBizError": "Ошибка запроса службы Bedrock, пожалуйста, проверьте и повторите попытку в соответствии с предоставленной информацией",
|
||||
"GoogleBizError": "Ошибка запроса службы Google, пожалуйста, проверьте и повторите попытку в соответствии с предоставленной информацией",
|
||||
"InvalidAccessCode": "Неверный код доступа: введите правильный код доступа или добавьте пользовательский ключ API",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API Key недействителен или отсутствует. Пожалуйста, проверьте Anthropic API Key и повторите попытку",
|
||||
"InvalidAzureAPIKey": "Неверный или пустой ключ API Azure, пожалуйста, проверьте ключ API Azure и повторите попытку",
|
||||
"InvalidBedrockCredentials": "Аутентификация Bedrock не прошла, пожалуйста, проверьте AccessKeyId/SecretAccessKey и повторите попытку",
|
||||
"InvalidGoogleAPIKey": "Неверный или пустой ключ API Google, пожалуйста, проверьте ключ API Google и повторите попытку",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Введите свой ключ API Anthropic, чтобы начать сеанс. Приложение не будет сохранять ваш ключ API",
|
||||
"title": "Использовать пользовательский ключ API Anthropic"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Пользовательская область услуг",
|
||||
"description": "Введите свой ключ доступа Aws AccessKeyId / SecretAccessKey, чтобы начать сеанс. Приложение не будет сохранять вашу аутентификационную конфигурацию",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Настройки сеанса · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Антропный",
|
||||
"token": {
|
||||
"desc": "Введите ключ API от Anthropic",
|
||||
"placeholder": "Ключ API Anthropic",
|
||||
"title": "Ключ API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Версия API Azure, следуйте формату YYYY-MM-DD, см. [последнюю версию](https://learn.microsoft.com/ru-ru/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Başlatılıyor...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Antropik",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Üzgünüm, sunucu şu anda isteğinizi işleyemiyor, muhtemelen aşırı yüklenme veya bakım nedeniyle. Lütfen daha sonra tekrar deneyin.",
|
||||
"504": "Üzgünüm, sunucu yukarı akış sunucusundan bir yanıt alamadı. Lütfen daha sonra tekrar deneyin.",
|
||||
"AgentRuntimeError": "Lobe dil modeli çalışma zamanı hatası, lütfen aşağıdaki bilgilere göre sorunu gidermeye çalışın veya tekrar deneyin",
|
||||
"AnthropicBizError": "Anthropic AI hizmetine yönelik istek hatası, lütfen aşağıdaki bilgilere göre sorunu gidermeye çalışın veya tekrar deneyin",
|
||||
"AzureBizError": "Azure AI servisi isteği hatası, lütfen aşağıdaki bilgilere göre sorunu gidermeye çalışın veya tekrar deneyin",
|
||||
"BedrockBizError": "Bedrock servisi isteği hatası, lütfen aşağıdaki bilgilere göre sorunu gidermeye çalışın veya tekrar deneyin",
|
||||
"GoogleBizError": "Google servisi isteği hatası, lütfen aşağıdaki bilgilere göre sorunu gidermeye çalışın veya tekrar deneyin",
|
||||
"InvalidAccessCode": "Geçersiz Erişim Kodu: Geçersiz veya boş bir şifre girdiniz. Lütfen doğru erişim şifresini girin veya özel API Anahtarı ekleyin.",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API Key geçersiz veya boş, lütfen Anthropic API Key'inizi kontrol edip tekrar deneyin",
|
||||
"InvalidAzureAPIKey": "Azure API Anahtarı yanlış veya boş, lütfen Azure API Anahtarınızı kontrol edip tekrar deneyin",
|
||||
"InvalidBedrockCredentials": "Bedrock kimlik doğrulaması geçersiz, lütfen AccessKeyId/SecretAccessKey bilgilerinizi kontrol edip tekrar deneyin",
|
||||
"InvalidGoogleAPIKey": "Google API Anahtarı yanlış veya boş, lütfen Google API Anahtarınızı kontrol edip tekrar deneyin",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Oturumu başlatmak için Anthropic API Key'inizi girin. Uygulama API Key'inizi kaydetmez",
|
||||
"title": "Özel Anthropic API Key'i Kullan"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Özel bölgeyi kullan",
|
||||
"description": "Aws AccessKeyId / SecretAccessKey bilgilerinizi girerek oturumu başlatabilirsiniz. Uygulama kimlik doğrulama yapılandırmanızı kaydetmez",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Oturum Ayarları · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Anthropic 的 API 密钥",
|
||||
"placeholder": "Anthropic API 密钥",
|
||||
"title": "API 密钥"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Azure'nin API sürümü, YYYY-MM-DD biçimini takip eder, [en son sürümü buradan bulabilirsiniz](https://learn.microsoft.com/tr-tr/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "Đang tải bố cục...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "Xin lỗi, máy chủ hiện không thể xử lý yêu cầu của bạn, có thể do quá tải hoặc đang bảo trì, vui lòng thử lại sau",
|
||||
"504": "Xin lỗi, máy chủ không đợi được phản hồi từ máy chủ upstream, vui lòng thử lại sau",
|
||||
"AgentRuntimeError": "Lobe mô hình ngôn ngữ thực thi gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
|
||||
"AnthropicBizError": "Yêu cầu dịch vụ AI Anthropic gặp lỗi, vui lòng kiểm tra thông tin dưới đây hoặc thử lại",
|
||||
"AzureBizError": "Yêu cầu dịch vụ Azure AI gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
|
||||
"BedrockBizError": "Yêu cầu dịch vụ Bedrock gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
|
||||
"GoogleBizError": "Yêu cầu dịch vụ Google gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
|
||||
"InvalidAccessCode": "Mật khẩu truy cập không hợp lệ hoặc trống, vui lòng nhập mật khẩu truy cập đúng hoặc thêm Khóa API tùy chỉnh",
|
||||
"InvalidAnthropicAPIKey": "Khóa API Anthropic không hợp lệ hoặc trống, vui lòng kiểm tra lại và thử lại",
|
||||
"InvalidAzureAPIKey": "Khóa API Azure không chính xác hoặc trống, vui lòng kiểm tra lại Khóa API Azure và thử lại",
|
||||
"InvalidBedrockCredentials": "Xác thực Bedrock không thành công, vui lòng kiểm tra AccessKeyId/SecretAccessKey và thử lại",
|
||||
"InvalidGoogleAPIKey": "Khóa API Google không chính xác hoặc trống, vui lòng kiểm tra lại Khóa API Google và thử lại",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "Nhập Khóa API Anthropic của bạn để bắt đầu phiên làm việc. Ứng dụng sẽ không lưu trữ Khóa API của bạn",
|
||||
"title": "Sử dụng Khóa API Anthropic tùy chỉnh"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "Vùng dịch vụ tùy chỉnh",
|
||||
"description": "Nhập Aws AccessKeyId / SecretAccessKey của bạn để bắt đầu phiên làm việc. Ứng dụng sẽ không lưu trữ cấu hình xác thực của bạn",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "Cài đặt cuộc trò chuyện · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "Nhập API Key từ Anthropic",
|
||||
"placeholder": "Khóa API Anthropic",
|
||||
"title": "Khóa API"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Phiên bản API của Azure, theo định dạng YYYY-MM-DD, xem chi tiết [phiên bản mới nhất](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "正在加载布局...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@
|
|||
"AzureBizError": "请求 Azure AI 服务出错,请根据以下信息排查或重试",
|
||||
"InvalidPerplexityAPIKey": "Perplexity API Key 不正确或为空,请检查 Perplexity API Key 后重试",
|
||||
"PerplexityBizError": "请求 Perplexity AI 服务出错,请根据以下信息排查或重试",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API Key 不正确或为空,请检查 Anthropic API Key 后重试",
|
||||
"AnthropicBizError": "请求 Anthropic AI 服务出错,请根据以下信息排查或重试",
|
||||
"InvalidOllamaArgs": "Ollama 配置不正确,请检查 Ollama 配置后重试",
|
||||
"OllamaBizError": "请求 Ollama 服务出错,请根据以下信息排查或重试",
|
||||
"AgentRuntimeError": "Lobe 语言模型运行时执行出错,请根据以下信息排查或重试"
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "输入你的 Anthropic API Key 即可开始会话。应用不会记录你的 API Key",
|
||||
"title": "使用自定义 Anthropic API Key"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "自定义服务区域",
|
||||
"description": "输入你的 Aws AccessKeyId / SecretAccessKey 即可开始会话。应用不会记录你的鉴权配置",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "会话设置 · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "填入来自 Anthropic 的 API Key",
|
||||
"placeholder": "Anthropic API Key",
|
||||
"title": "API Key"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查阅[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"layoutInitializing": "正在載入版面配置...",
|
||||
"modelProvider": {
|
||||
"anthropic": "Anthropic",
|
||||
"azure": "Azure",
|
||||
"bedrock": "AWS Bedrock",
|
||||
"google": "Google",
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
"503": "抱歉,伺服器目前無法處理您的請求,可能是因為過載或正在進行維護。請稍後再試。",
|
||||
"504": "抱歉,伺服器沒有收到上游伺服器的回應。請稍後再試。",
|
||||
"AgentRuntimeError": "Lobe 語言模型運行時執行出錯,請根據以下信息排查或重試",
|
||||
"AnthropicBizError": "請求 Anthropic AI 服務出錯,請根據以下信息排查或重試",
|
||||
"AzureBizError": "請求 Azure AI 服務出錯,請根據以下信息排查或重試",
|
||||
"BedrockBizError": "請求 Bedrock 服務出錯,請根據以下信息排查或重試",
|
||||
"GoogleBizError": "請求 Google 服務出錯,請根據以下信息排查或重試",
|
||||
"InvalidAccessCode": "密碼不正確或為空,請輸入正確的訪問密碼,或添加自定義 API 金鑰",
|
||||
"InvalidAnthropicAPIKey": "Anthropic API 金鑰不正確或為空,請檢查 Anthropic API 金鑰後重試",
|
||||
"InvalidAzureAPIKey": "Azure API Key 不正確或為空,請檢查 Azure API Key 後重試",
|
||||
"InvalidBedrockCredentials": "Bedrock 驗證未通過,請檢查 AccessKeyId/SecretAccessKey 後重試",
|
||||
"InvalidGoogleAPIKey": "Google API Key 不正確或為空,請檢查 Google API Key 後重試",
|
||||
|
|
@ -73,6 +75,10 @@
|
|||
},
|
||||
"unlock": {
|
||||
"apikey": {
|
||||
"Anthropic": {
|
||||
"description": "輸入你的 Anthropic API 金鑰即可開始會話。應用不會記錄你的 API 金鑰",
|
||||
"title": "使用自定義 Anthropic API 金鑰"
|
||||
},
|
||||
"Bedrock": {
|
||||
"customRegion": "自定義服務區域",
|
||||
"description": "輸入你的 Aws AccessKeyId / SecretAccessKey 即可開始會話。應用不會記錄你的驗證配置",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
"sessionWithName": "對話設定 · {{name}}"
|
||||
},
|
||||
"llm": {
|
||||
"Anthropic": {
|
||||
"title": "Anthropic",
|
||||
"token": {
|
||||
"desc": "填入來自 Anthropic 的 API 金鑰",
|
||||
"placeholder": "Anthropic API 金鑰",
|
||||
"title": "API 金鑰"
|
||||
}
|
||||
},
|
||||
"AzureOpenAI": {
|
||||
"azureApiVersion": {
|
||||
"desc": "Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查閱[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5",
|
||||
"@anthropic-ai/sdk": "^0.16.0",
|
||||
"@auth/core": "latest",
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.503.1",
|
||||
"@azure/openai": "^1.0.0-beta.11",
|
||||
|
|
@ -82,7 +83,7 @@
|
|||
"@icons-pack/react-simple-icons": "^9",
|
||||
"@lobehub/chat-plugin-sdk": "latest",
|
||||
"@lobehub/chat-plugins-gateway": "latest",
|
||||
"@lobehub/icons": "^1.11.2",
|
||||
"@lobehub/icons": "^1.13.0",
|
||||
"@lobehub/tts": "latest",
|
||||
"@lobehub/ui": "^1.129.2",
|
||||
"@vercel/analytics": "^1",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
} from '@/const/trace';
|
||||
import {
|
||||
ChatStreamPayload,
|
||||
LobeAnthropicAI,
|
||||
LobeAzureOpenAI,
|
||||
LobeBedrockAI,
|
||||
LobeGoogleAI,
|
||||
|
|
@ -155,6 +156,11 @@ class AgentRuntime {
|
|||
runtimeModel = this.initPerplexity(payload);
|
||||
break;
|
||||
}
|
||||
|
||||
case ModelProvider.Anthropic: {
|
||||
runtimeModel = this.initAnthropic(payload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new AgentRuntime(runtimeModel);
|
||||
|
|
@ -242,6 +248,13 @@ class AgentRuntime {
|
|||
|
||||
return new LobePerplexityAI({ apiKey });
|
||||
}
|
||||
|
||||
private static initAnthropic(payload: JWTPayload) {
|
||||
const { ANTHROPIC_API_KEY } = getServerConfig();
|
||||
const apiKey = apiKeyManager.pick(payload?.apiKey || ANTHROPIC_API_KEY);
|
||||
|
||||
return new LobeAnthropicAI({ apiKey });
|
||||
}
|
||||
}
|
||||
|
||||
export default AgentRuntime;
|
||||
|
|
|
|||
28
src/app/api/chat/anthropic/route.test.ts
Normal file
28
src/app/api/chat/anthropic/route.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// @vitest-environment edge-runtime
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { POST as UniverseRoute } from '../[provider]/route';
|
||||
import { POST, preferredRegion, runtime } from './route';
|
||||
|
||||
// 模拟 '../[provider]/route'
|
||||
vi.mock('../[provider]/route', () => ({
|
||||
POST: vi.fn().mockResolvedValue('mocked response'),
|
||||
}));
|
||||
|
||||
describe('Configuration tests', () => {
|
||||
it('should have runtime set to "edge"', () => {
|
||||
expect(runtime).toBe('edge');
|
||||
});
|
||||
|
||||
it('should contain specific regions in preferredRegion', () => {
|
||||
expect(preferredRegion).not.contain(['hk1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Anthropic POST function tests', () => {
|
||||
it('should call UniverseRoute with correct parameters', async () => {
|
||||
const mockRequest = new Request('https://example.com', { method: 'POST' });
|
||||
await POST(mockRequest);
|
||||
expect(UniverseRoute).toHaveBeenCalledWith(mockRequest, { params: { provider: 'anthropic' } });
|
||||
});
|
||||
});
|
||||
33
src/app/api/chat/anthropic/route.ts
Normal file
33
src/app/api/chat/anthropic/route.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { POST as UniverseRoute } from '../[provider]/route';
|
||||
|
||||
// due to the Chinese region does not support accessing Google
|
||||
// we need to use proxy to access it
|
||||
// refs: https://github.com/google/generative-ai-js/issues/29#issuecomment-1866246513
|
||||
// if (process.env.HTTP_PROXY_URL) {
|
||||
// const { setGlobalDispatcher, ProxyAgent } = require('undici');
|
||||
//
|
||||
// console.log(process.env.HTTP_PROXY_URL)
|
||||
// setGlobalDispatcher(new ProxyAgent({ uri: process.env.HTTP_PROXY_URL }));
|
||||
// }
|
||||
|
||||
// but undici only can be used in NodeJS
|
||||
// so if you want to use with proxy, you need comment the code below
|
||||
export const runtime = 'edge';
|
||||
|
||||
export const preferredRegion = [
|
||||
'bom1',
|
||||
'cle1',
|
||||
'cpt1',
|
||||
'gru1',
|
||||
'hnd1',
|
||||
'iad1',
|
||||
'icn1',
|
||||
'kix1',
|
||||
'pdx1',
|
||||
'sfo1',
|
||||
'sin1',
|
||||
'syd1',
|
||||
];
|
||||
|
||||
export const POST = async (req: Request) =>
|
||||
UniverseRoute(req, { params: { provider: 'anthropic' } });
|
||||
|
|
@ -18,6 +18,7 @@ export const GET = async () => {
|
|||
ENABLE_OAUTH_SSO,
|
||||
ENABLE_OLLAMA,
|
||||
ENABLED_PERPLEXITY,
|
||||
ENABLED_ANTHROPIC,
|
||||
DEFAULT_AGENT_CONFIG,
|
||||
ENABLE_LANGFUSE,
|
||||
} = getServerConfig();
|
||||
|
|
@ -30,6 +31,7 @@ export const GET = async () => {
|
|||
|
||||
enabledOAuthSSO: ENABLE_OAUTH_SSO,
|
||||
languageModel: {
|
||||
anthropic: { enabled: ENABLED_ANTHROPIC },
|
||||
bedrock: { enabled: ENABLED_AWS_BEDROCK },
|
||||
google: { enabled: ENABLED_GOOGLE },
|
||||
moonshot: { enabled: ENABLED_MOONSHOT },
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ const getStatus = (errorType: ILobeAgentRuntimeErrorType | ErrorType) => {
|
|||
case AgentRuntimeErrorType.PerplexityBizError: {
|
||||
return 479;
|
||||
}
|
||||
case AgentRuntimeErrorType.AnthropicBizError: {
|
||||
return 480;
|
||||
}
|
||||
}
|
||||
return errorType as number;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import ModelTag from '@/components/ModelTag';
|
||||
import ModelSwitchPanel from '@/features/ModelSwitchPanel';
|
||||
|
|
@ -18,12 +19,12 @@ const TitleTags = memo(() => {
|
|||
const showPlugin = useGlobalStore(modelProviderSelectors.modelEnabledFunctionCall(model));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flexbox gap={8} horizontal>
|
||||
<ModelSwitchPanel>
|
||||
<ModelTag model={model} />
|
||||
</ModelSwitchPanel>
|
||||
{showPlugin && plugins?.length > 0 && <PluginTag plugins={plugins} />}
|
||||
</>
|
||||
</Flexbox>
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
52
src/app/settings/llm/Anthropic/index.tsx
Normal file
52
src/app/settings/llm/Anthropic/index.tsx
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { Anthropic } from '@lobehub/icons';
|
||||
import { Input } from 'antd';
|
||||
import { useTheme } from 'antd-style';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { ModelProvider } from '@/libs/agent-runtime';
|
||||
|
||||
import Checker from '../components/Checker';
|
||||
import ProviderConfig from '../components/ProviderConfig';
|
||||
import { LLMProviderApiTokenKey, LLMProviderConfigKey } from '../const';
|
||||
|
||||
const providerKey = 'anthropic';
|
||||
|
||||
const AnthropicProvider = memo(() => {
|
||||
const { t } = useTranslation('setting');
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<ProviderConfig
|
||||
configItems={[
|
||||
{
|
||||
children: (
|
||||
<Input.Password
|
||||
autoComplete={'new-password'}
|
||||
placeholder={t('llm.Anthropic.token.placeholder')}
|
||||
/>
|
||||
),
|
||||
desc: t('llm.Anthropic.token.desc'),
|
||||
label: t('llm.Anthropic.token.title'),
|
||||
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
||||
},
|
||||
{
|
||||
children: <Checker model={'claude-2.1'} provider={ModelProvider.Anthropic} />,
|
||||
desc: t('llm.checker.desc'),
|
||||
label: t('llm.checker.title'),
|
||||
minWidth: '100%',
|
||||
},
|
||||
]}
|
||||
provider={providerKey}
|
||||
title={
|
||||
<Anthropic.Text
|
||||
color={theme.isDarkMode ? theme.colorText : Anthropic.colorPrimary}
|
||||
size={18}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export default AnthropicProvider;
|
||||
|
|
@ -8,6 +8,7 @@ import PageTitle from '@/components/PageTitle';
|
|||
import { MORE_MODEL_PROVIDER_REQUEST_URL } from '@/const/url';
|
||||
|
||||
import Footer from '../features/Footer';
|
||||
import Anthropic from './Anthropic';
|
||||
import Bedrock from './Bedrock';
|
||||
import Google from './Google';
|
||||
import Moonshot from './Moonshot';
|
||||
|
|
@ -29,6 +30,7 @@ export default memo<{ showOllama: boolean }>(({ showOllama }) => {
|
|||
<Google />
|
||||
<Bedrock />
|
||||
<Perplexity />
|
||||
<Anthropic />
|
||||
{showOllama && <Ollama />}
|
||||
<Footer>
|
||||
<Trans i18nKey="llm.waitingForMore" ns={'setting'}>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {
|
||||
Anthropic,
|
||||
Aws,
|
||||
Baichuan,
|
||||
ChatGLM,
|
||||
Claude,
|
||||
Gemini,
|
||||
Gemma,
|
||||
Meta,
|
||||
|
|
@ -26,7 +26,7 @@ const ModelIcon = memo<ModelProviderIconProps>(({ model, size = 12 }) => {
|
|||
if (model.startsWith('gpt-3')) return <OpenAI.Avatar size={size} type={'gpt3'} />;
|
||||
if (model.startsWith('gpt-4')) return <OpenAI.Avatar size={size} type={'gpt4'} />;
|
||||
if (model.startsWith('glm')) return <ChatGLM.Avatar size={size} />;
|
||||
if (model.includes('claude')) return <Anthropic.Avatar size={size} />;
|
||||
if (model.includes('claude')) return <Claude.Avatar size={size} />;
|
||||
if (model.includes('titan')) return <Aws.Avatar size={size} />;
|
||||
if (model.includes('llama')) return <Meta.Avatar size={size} />;
|
||||
if (model.includes('gemini')) return <Gemini.Avatar size={size} />;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
Anthropic,
|
||||
Azure,
|
||||
Bedrock,
|
||||
Google,
|
||||
|
|
@ -64,6 +65,10 @@ const ModelProviderIcon = memo<ModelProviderIconProps>(({ provider }) => {
|
|||
return <Mistral size={20} />;
|
||||
}
|
||||
|
||||
case ModelProvider.Anthropic: {
|
||||
return <Anthropic size={20} />;
|
||||
}
|
||||
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {
|
||||
Anthropic,
|
||||
Aws,
|
||||
Baichuan,
|
||||
ChatGLM,
|
||||
Claude,
|
||||
Gemini,
|
||||
Gemma,
|
||||
Meta,
|
||||
|
|
@ -25,7 +25,7 @@ const ModelIcon = memo<ModelIconProps>(({ model, size = 12 }) => {
|
|||
|
||||
if (model.startsWith('gpt')) return <OpenAI size={size} />;
|
||||
if (model.startsWith('glm')) return <ChatGLM size={size} />;
|
||||
if (model.includes('claude')) return <Anthropic size={size} />;
|
||||
if (model.includes('claude')) return <Claude size={size} />;
|
||||
if (model.includes('titan')) return <Aws size={size} />;
|
||||
if (model.includes('llama')) return <Meta size={size} />;
|
||||
if (model.includes('gemini')) return <Gemini size={size} />;
|
||||
|
|
|
|||
56
src/config/modelProviders/anthropic.ts
Normal file
56
src/config/modelProviders/anthropic.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { ModelProviderCard } from '@/types/llm';
|
||||
|
||||
const Anthropic: ModelProviderCard = {
|
||||
chatModels: [
|
||||
{
|
||||
description:
|
||||
'Ideal balance of intelligence and speed for enterprise workloads. Maximum utility at a lower price, dependable, balanced for scaled deployments',
|
||||
displayName: 'Claude 3 Sonnet',
|
||||
id: 'claude-3-sonnet-20240229',
|
||||
maxOutput: 4096,
|
||||
tokens: 200_000,
|
||||
vision: true,
|
||||
},
|
||||
{
|
||||
description:
|
||||
'Most powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding',
|
||||
displayName: 'Claude 3 Opus',
|
||||
id: 'claude-3-opus-20240229',
|
||||
maxOutput: 4096,
|
||||
tokens: 200_000,
|
||||
vision: true,
|
||||
},
|
||||
{
|
||||
description:
|
||||
'Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance',
|
||||
displayName: 'Claude 3 Haiku',
|
||||
hidden: true,
|
||||
id: 'claude-3-haiku-20240229',
|
||||
maxOutput: 4096,
|
||||
tokens: 200_000,
|
||||
vision: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Claude 2.1',
|
||||
id: 'claude-2.1',
|
||||
maxOutput: 4096,
|
||||
tokens: 200_000,
|
||||
},
|
||||
{
|
||||
displayName: 'Claude 2.0',
|
||||
id: 'claude-2.0',
|
||||
maxOutput: 4096,
|
||||
tokens: 100_000,
|
||||
},
|
||||
{
|
||||
displayName: 'Claude Instant 1.2',
|
||||
hidden: true,
|
||||
id: 'claude-instant-1.2',
|
||||
maxOutput: 4096,
|
||||
tokens: 100_000,
|
||||
},
|
||||
],
|
||||
id: 'anthropic',
|
||||
};
|
||||
|
||||
export default Anthropic;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { ChatModelCard } from '@/types/llm';
|
||||
|
||||
import AnthropicProvider from './anthropic';
|
||||
import BedrockProvider from './bedrock';
|
||||
import GoogleProvider from './google';
|
||||
import MoonshotProvider from './moonshot';
|
||||
|
|
@ -16,8 +17,10 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
|
|||
MoonshotProvider.chatModels,
|
||||
OllamaProvider.chatModels,
|
||||
PerplexityProvider.chatModels,
|
||||
AnthropicProvider.chatModels,
|
||||
].flat();
|
||||
|
||||
export { default as AnthropicProvider } from './anthropic';
|
||||
export { default as BedrockProvider } from './bedrock';
|
||||
export { default as GoogleProvider } from './google';
|
||||
export { default as MoonshotProvider } from './moonshot';
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ declare global {
|
|||
// Perplexity Provider
|
||||
PERPLEXITY_API_KEY?: string;
|
||||
|
||||
// Anthropic Provider
|
||||
ANTHROPIC_API_KEY?: string;
|
||||
|
||||
// AWS Credentials
|
||||
AWS_REGION?: string;
|
||||
AWS_ACCESS_KEY_ID?: string;
|
||||
|
|
@ -58,6 +61,8 @@ export const getProviderConfig = () => {
|
|||
|
||||
const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY || '';
|
||||
|
||||
const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || '';
|
||||
|
||||
// region format: iad1,sfo1
|
||||
let regions: string[] = [];
|
||||
if (process.env.OPENAI_FUNCTION_REGIONS) {
|
||||
|
|
@ -82,6 +87,9 @@ export const getProviderConfig = () => {
|
|||
ENABLED_PERPLEXITY: !!PERPLEXITY_API_KEY,
|
||||
PERPLEXITY_API_KEY,
|
||||
|
||||
ENABLED_ANTHROPIC: !!ANTHROPIC_API_KEY,
|
||||
ANTHROPIC_API_KEY,
|
||||
|
||||
ENABLED_MOONSHOT: !!MOONSHOT_API_KEY,
|
||||
MOONSHOT_API_KEY,
|
||||
MOONSHOT_PROXY_URL: process.env.MOONSHOT_PROXY_URL,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
|
|||
};
|
||||
|
||||
export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
|
||||
anthropic: {
|
||||
apiKey: '',
|
||||
enabled: false,
|
||||
},
|
||||
azure: {
|
||||
apiKey: '',
|
||||
deployments: '',
|
||||
|
|
|
|||
40
src/features/Conversation/Error/APIKeyForm/Anthropic.tsx
Normal file
40
src/features/Conversation/Error/APIKeyForm/Anthropic.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { Anthropic } from '@lobehub/icons';
|
||||
import { Input } from 'antd';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { ModelProvider } from '@/libs/agent-runtime';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { modelProviderSelectors } from '@/store/global/selectors';
|
||||
|
||||
import { FormAction } from '../style';
|
||||
|
||||
const AnthropicForm = memo(() => {
|
||||
const { t } = useTranslation('error');
|
||||
// const [showProxy, setShow] = useState(false);
|
||||
|
||||
const [apiKey, setConfig] = useGlobalStore((s) => [
|
||||
modelProviderSelectors.anthropicAPIKey(s),
|
||||
s.setModelProviderConfig,
|
||||
]);
|
||||
|
||||
return (
|
||||
<FormAction
|
||||
avatar={<Anthropic size={56} />}
|
||||
description={t('unlock.apikey.Anthropic.description')}
|
||||
title={t('unlock.apikey.Anthropic.title')}
|
||||
>
|
||||
<Input.Password
|
||||
autoComplete={'new-password'}
|
||||
onChange={(e) => {
|
||||
setConfig(ModelProvider.Anthropic, { apiKey: e.target.value });
|
||||
}}
|
||||
placeholder={'*********************************'}
|
||||
type={'block'}
|
||||
value={apiKey}
|
||||
/>
|
||||
</FormAction>
|
||||
);
|
||||
});
|
||||
|
||||
export default AnthropicForm;
|
||||
|
|
@ -6,6 +6,7 @@ import { Center, Flexbox } from 'react-layout-kit';
|
|||
import { ModelProvider } from '@/libs/agent-runtime';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
|
||||
import AnthropicForm from './Anthropic';
|
||||
import BedrockForm from './Bedrock';
|
||||
import GoogleForm from './Google';
|
||||
import MoonshotForm from './Moonshot';
|
||||
|
|
@ -45,6 +46,10 @@ const APIKeyForm = memo<APIKeyFormProps>(({ id, provider }) => {
|
|||
return <PerplexityForm />;
|
||||
}
|
||||
|
||||
case ModelProvider.Anthropic: {
|
||||
return <AnthropicForm />;
|
||||
}
|
||||
|
||||
default:
|
||||
case ModelProvider.OpenAI: {
|
||||
return <OpenAIForm />;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ const ErrorMessageExtra = memo<{ data: ChatMessage }>(({ data }) => {
|
|||
case AgentRuntimeErrorType.InvalidMoonshotAPIKey:
|
||||
case AgentRuntimeErrorType.InvalidGoogleAPIKey:
|
||||
case AgentRuntimeErrorType.InvalidPerplexityAPIKey:
|
||||
case AgentRuntimeErrorType.InvalidAnthropicAPIKey:
|
||||
case AgentRuntimeErrorType.NoOpenAIAPIKey: {
|
||||
return <InvalidAPIKey id={data.id} provider={data.error?.body?.provider} />;
|
||||
}
|
||||
|
|
|
|||
212
src/libs/agent-runtime/anthropic/index.test.ts
Normal file
212
src/libs/agent-runtime/anthropic/index.test.ts
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
// @vitest-environment node
|
||||
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import * as debugStreamModule from '../utils/debugStream';
|
||||
import { LobeAnthropicAI } from './index';
|
||||
|
||||
const provider = 'anthropic';
|
||||
|
||||
// Mock the console.error to avoid polluting test output
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
let instance: LobeAnthropicAI;
|
||||
|
||||
beforeEach(() => {
|
||||
instance = new LobeAnthropicAI({ apiKey: 'test' });
|
||||
|
||||
// 使用 vi.spyOn 来模拟 chat.completions.create 方法
|
||||
vi.spyOn(instance['client'].messages, 'create').mockReturnValue(new ReadableStream() as any);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('LobeAnthropicAI', () => {
|
||||
describe('init', () => {
|
||||
it('should correctly initialize with an API key', async () => {
|
||||
const instance = new LobeAnthropicAI({ apiKey: 'test_api_key' });
|
||||
expect(instance).toBeInstanceOf(LobeAnthropicAI);
|
||||
});
|
||||
});
|
||||
|
||||
describe('chat', () => {
|
||||
it('should return a StreamingTextResponse on successful API call', async () => {
|
||||
const result = await instance.chat({
|
||||
messages: [{ content: 'Hello', role: 'user' }],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(result).toBeInstanceOf(Response);
|
||||
});
|
||||
it('should handle text messages correctly', async () => {
|
||||
// Arrange
|
||||
const mockStream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue('Hello, world!');
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
const mockResponse = Promise.resolve(mockStream);
|
||||
(instance['client'].messages.create as Mock).mockResolvedValue(mockResponse);
|
||||
|
||||
// Act
|
||||
const result = await instance.chat({
|
||||
messages: [{ content: 'Hello', role: 'user' }],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
top_p: 1
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(instance['client'].messages.create).toHaveBeenCalledWith({
|
||||
max_tokens: 1024,
|
||||
messages: [
|
||||
{ content: 'Hello', role: 'user' },
|
||||
],
|
||||
model: 'claude-instant-1.2',
|
||||
stream: true,
|
||||
temperature: 0,
|
||||
top_p: 1
|
||||
})
|
||||
expect(result).toBeInstanceOf(Response);
|
||||
});
|
||||
it('should handle system prompt correctly', async () => {
|
||||
// Arrange
|
||||
const mockStream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue('Hello, world!');
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
const mockResponse = Promise.resolve(mockStream);
|
||||
(instance['client'].messages.create as Mock).mockResolvedValue(mockResponse);
|
||||
|
||||
// Act
|
||||
const result = await instance.chat({
|
||||
messages: [
|
||||
{ content: 'You are an awesome greeter', role: 'system' },
|
||||
{ content: 'Hello', role: 'user' },
|
||||
],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(instance['client'].messages.create).toHaveBeenCalledWith({
|
||||
max_tokens: 1024,
|
||||
messages: [
|
||||
{ content: 'Hello', role: 'user' },
|
||||
],
|
||||
model: 'claude-instant-1.2',
|
||||
stream: true,
|
||||
system: 'You are an awesome greeter',
|
||||
temperature: 0,
|
||||
})
|
||||
expect(result).toBeInstanceOf(Response);
|
||||
});
|
||||
it('should call debugStream in DEBUG mode', async () => {
|
||||
// Arrange
|
||||
const mockProdStream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue('Hello, world!');
|
||||
controller.close();
|
||||
},
|
||||
}) as any;
|
||||
const mockDebugStream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue('Debug stream content');
|
||||
controller.close();
|
||||
},
|
||||
}) as any;
|
||||
mockDebugStream.toReadableStream = () => mockDebugStream;
|
||||
|
||||
(instance['client'].messages.create as Mock).mockResolvedValue({
|
||||
tee: () => [mockProdStream, { toReadableStream: () => mockDebugStream }],
|
||||
});
|
||||
|
||||
const originalDebugValue = process.env.DEBUG_ANTHROPIC_CHAT_COMPLETION;
|
||||
|
||||
process.env.DEBUG_ANTHROPIC_CHAT_COMPLETION = '1';
|
||||
vi.spyOn(debugStreamModule, 'debugStream').mockImplementation(() => Promise.resolve());
|
||||
|
||||
// Act
|
||||
await instance.chat({
|
||||
messages: [{ content: 'Hello', role: 'user' }],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(debugStreamModule.debugStream).toHaveBeenCalled();
|
||||
|
||||
// Cleanup
|
||||
process.env.DEBUG_ANTHROPIC_CHAT_COMPLETION = originalDebugValue;
|
||||
});
|
||||
|
||||
describe('Error', () => {
|
||||
it('should throw InvalidAnthropicAPIKey error on API_KEY_INVALID error', async () => {
|
||||
// Arrange
|
||||
const apiError = {
|
||||
status: 401,
|
||||
error: {
|
||||
type: 'error',
|
||||
error: {
|
||||
type: 'authentication_error',
|
||||
message: 'invalid x-api-key',
|
||||
},
|
||||
},
|
||||
};
|
||||
(instance['client'].messages.create as Mock).mockRejectedValue(apiError);
|
||||
|
||||
try {
|
||||
// Act
|
||||
await instance.chat({
|
||||
messages: [{ content: 'Hello', role: 'user' }],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
});
|
||||
} catch (e) {
|
||||
// Assert
|
||||
expect(e).toEqual({ errorType: 'InvalidAnthropicAPIKey', error: apiError, provider });
|
||||
}
|
||||
});
|
||||
it('should throw BizError error', async () => {
|
||||
// Arrange
|
||||
const apiError = {
|
||||
status: 529,
|
||||
error: {
|
||||
type: 'error',
|
||||
error: {
|
||||
type: 'overloaded_error',
|
||||
message: "Anthropic's API is temporarily overloaded",
|
||||
},
|
||||
},
|
||||
};
|
||||
(instance['client'].messages.create as Mock).mockRejectedValue(apiError);
|
||||
|
||||
try {
|
||||
// Act
|
||||
await instance.chat({
|
||||
messages: [{ content: 'Hello', role: 'user' }],
|
||||
model: 'claude-instant-1.2',
|
||||
temperature: 0,
|
||||
});
|
||||
} catch (e) {
|
||||
// Assert
|
||||
expect(e).toEqual({ errorType: 'AnthropicBizError', error: apiError, provider });
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw InvalidAnthropicAPIKey if no apiKey is provided', async () => {
|
||||
try {
|
||||
new LobeAnthropicAI({});
|
||||
} catch (e) {
|
||||
expect(e).toEqual({ errorType: 'InvalidAnthropicAPIKey' });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
119
src/libs/agent-runtime/anthropic/index.ts
Normal file
119
src/libs/agent-runtime/anthropic/index.ts
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
// sort-imports-ignore
|
||||
import '@anthropic-ai/sdk/shims/web';
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
import { AnthropicStream, StreamingTextResponse } from 'ai';
|
||||
import { ClientOptions } from 'openai';
|
||||
|
||||
import { LobeRuntimeAI } from '../BaseAI';
|
||||
import { AgentRuntimeErrorType } from '../error';
|
||||
import {
|
||||
ChatCompetitionOptions,
|
||||
ChatStreamPayload,
|
||||
ModelProvider,
|
||||
OpenAIChatMessage,
|
||||
UserMessageContentPart,
|
||||
} from '../types';
|
||||
import { AgentRuntimeError } from '../utils/createError';
|
||||
import { debugStream } from '../utils/debugStream';
|
||||
import { parseDataUri } from '../utils/uriParser';
|
||||
|
||||
export class LobeAnthropicAI implements LobeRuntimeAI {
|
||||
private client: Anthropic;
|
||||
|
||||
constructor({ apiKey }: ClientOptions) {
|
||||
if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidAnthropicAPIKey);
|
||||
|
||||
this.client = new Anthropic({ apiKey });
|
||||
}
|
||||
|
||||
private buildAnthropicMessages = (
|
||||
messages: OpenAIChatMessage[],
|
||||
): Anthropic.Messages.MessageParam[] =>
|
||||
messages.map((message) => this.convertToAnthropicMessage(message));
|
||||
|
||||
private convertToAnthropicMessage = (
|
||||
message: OpenAIChatMessage,
|
||||
): Anthropic.Messages.MessageParam => {
|
||||
const content = message.content as string | UserMessageContentPart[];
|
||||
|
||||
return {
|
||||
content:
|
||||
typeof content === 'string' ? content : content.map((c) => this.convertToAnthropicBlock(c)),
|
||||
role: message.role === 'function' || message.role === 'system' ? 'assistant' : message.role,
|
||||
};
|
||||
};
|
||||
|
||||
async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) {
|
||||
const { messages, model, max_tokens, temperature, top_p } = payload;
|
||||
const system_message = messages.find((m) => m.role === 'system');
|
||||
const user_messages = messages.filter((m) => m.role !== 'system');
|
||||
|
||||
const requestParams: Anthropic.MessageCreateParams = {
|
||||
max_tokens: max_tokens || 1024,
|
||||
messages: this.buildAnthropicMessages(user_messages),
|
||||
model: model,
|
||||
stream: true,
|
||||
system: system_message?.content as string,
|
||||
temperature: temperature,
|
||||
top_p: top_p,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await this.client.messages.create(requestParams);
|
||||
const [prod, debug] = response.tee();
|
||||
|
||||
if (process.env.DEBUG_ANTHROPIC_CHAT_COMPLETION === '1') {
|
||||
debugStream(debug.toReadableStream()).catch(console.error);
|
||||
}
|
||||
|
||||
return new StreamingTextResponse(AnthropicStream(prod, options?.callback), {
|
||||
headers: options?.headers,
|
||||
});
|
||||
} catch (error) {
|
||||
if ('status' in (error as any)) {
|
||||
switch ((error as Response).status) {
|
||||
case 401: {
|
||||
throw AgentRuntimeError.chat({
|
||||
error: error as any,
|
||||
errorType: AgentRuntimeErrorType.InvalidAnthropicAPIKey,
|
||||
provider: ModelProvider.Anthropic,
|
||||
});
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw AgentRuntimeError.chat({
|
||||
error: error as any,
|
||||
errorType: AgentRuntimeErrorType.AnthropicBizError,
|
||||
provider: ModelProvider.Anthropic,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private convertToAnthropicBlock(
|
||||
content: UserMessageContentPart,
|
||||
): Anthropic.ContentBlock | Anthropic.ImageBlockParam {
|
||||
switch (content.type) {
|
||||
case 'text': {
|
||||
return content;
|
||||
}
|
||||
|
||||
case 'image_url': {
|
||||
const { mimeType, base64 } = parseDataUri(content.image_url.url);
|
||||
|
||||
return {
|
||||
source: {
|
||||
data: base64 as string,
|
||||
media_type: mimeType as Anthropic.ImageBlockParam.Source['media_type'],
|
||||
type: 'base64',
|
||||
},
|
||||
type: 'image',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default LobeAnthropicAI;
|
||||
|
|
@ -28,6 +28,9 @@ export const AgentRuntimeErrorType = {
|
|||
|
||||
InvalidPerplexityAPIKey: 'InvalidPerplexityAPIKey',
|
||||
PerplexityBizError: 'PerplexityBizError',
|
||||
|
||||
InvalidAnthropicAPIKey: 'InvalidAnthropicAPIKey',
|
||||
AnthropicBizError: 'AnthropicBizError',
|
||||
} as const;
|
||||
|
||||
export type ILobeAgentRuntimeErrorType =
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export { LobeAnthropicAI } from './anthropic';
|
||||
export { LobeAzureOpenAI } from './azureOpenai';
|
||||
export * from './BaseAI';
|
||||
export { LobeBedrockAI } from './bedrock';
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ interface UserMessageContentPartText {
|
|||
text: string;
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
interface UserMessageContentPartImage {
|
||||
image_url: {
|
||||
detail?: 'auto' | 'low' | 'high';
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ export default {
|
|||
},
|
||||
layoutInitializing: '正在加载布局...',
|
||||
modelProvider: {
|
||||
anthropic: 'Anthropic',
|
||||
azure: 'Azure',
|
||||
bedrock: 'AWS Bedrock',
|
||||
google: 'Google',
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ export default {
|
|||
InvalidPerplexityAPIKey: 'Perplexity API Key 不正确或为空,请检查 Perplexity API Key 后重试',
|
||||
PerplexityBizError: '请求 Perplexity AI 服务出错,请根据以下信息排查或重试',
|
||||
|
||||
InvalidAnthropicAPIKey: 'Anthropic API Key 不正确或为空,请检查 Anthropic API Key 后重试',
|
||||
AnthropicBizError: '请求 Anthropic AI 服务出错,请根据以下信息排查或重试',
|
||||
|
||||
InvalidOllamaArgs: 'Ollama 配置不正确,请检查 Ollama 配置后重试',
|
||||
OllamaBizError: '请求 Ollama 服务出错,请根据以下信息排查或重试',
|
||||
|
||||
|
|
@ -90,6 +93,10 @@ export default {
|
|||
},
|
||||
unlock: {
|
||||
apikey: {
|
||||
Anthropic: {
|
||||
description: '输入你的 Anthropic API Key 即可开始会话。应用不会记录你的 API Key',
|
||||
title: '使用自定义 Anthropic API Key',
|
||||
},
|
||||
Bedrock: {
|
||||
customRegion: '自定义服务区域',
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ export default {
|
|||
sessionWithName: '会话设置 · {{name}}',
|
||||
},
|
||||
llm: {
|
||||
Anthropic: {
|
||||
title: 'Anthropic',
|
||||
token: {
|
||||
desc: '填入来自 Anthropic 的 API Key',
|
||||
placeholder: 'Anthropic API Key',
|
||||
title: 'API Key',
|
||||
},
|
||||
},
|
||||
AzureOpenAI: {
|
||||
azureApiVersion: {
|
||||
desc: 'Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查阅[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)',
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ export const getProviderAuthPayload = (provider: string) => {
|
|||
return { apiKey: modelProviderSelectors.perplexityAPIKey(useGlobalStore.getState()) };
|
||||
}
|
||||
|
||||
case ModelProvider.Anthropic: {
|
||||
return { apiKey: modelProviderSelectors.anthropicAPIKey(useGlobalStore.getState()) };
|
||||
}
|
||||
|
||||
default:
|
||||
case ModelProvider.OpenAI: {
|
||||
const openai = modelProviderSelectors.openAIConfig(useGlobalStore.getState());
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ class FileService {
|
|||
}))();
|
||||
|
||||
// 压缩图片
|
||||
const fileType = 'image/webp';
|
||||
const base64String = compressImage({ img, type: fileType });
|
||||
const base64String = compressImage({ img, type: file.fileType });
|
||||
const binaryString = atob(base64String.split('base64,')[1]);
|
||||
const uint8Array = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
|
||||
file.data = uint8Array.buffer;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { produce } from 'immer';
|
||||
|
||||
import {
|
||||
AnthropicProvider,
|
||||
BedrockProvider,
|
||||
GoogleProvider,
|
||||
LOBE_DEFAULT_MODEL_LIST,
|
||||
|
|
@ -52,6 +53,9 @@ const ollamaProxyUrl = (s: GlobalStore) => modelProvider(s).ollama.endpoint;
|
|||
const enablePerplexity = (s: GlobalStore) => modelProvider(s).perplexity.enabled;
|
||||
const perplexityAPIKey = (s: GlobalStore) => modelProvider(s).perplexity.apiKey;
|
||||
|
||||
const enableAnthropic = (s: GlobalStore) => modelProvider(s).anthropic.enabled;
|
||||
const anthropicAPIKey = (s: GlobalStore) => modelProvider(s).anthropic.apiKey;
|
||||
|
||||
// const azureModelList = (s: GlobalStore): ModelProviderCard => {
|
||||
// const azure = azureConfig(s);
|
||||
// return {
|
||||
|
|
@ -138,6 +142,7 @@ const modelSelectList = (s: GlobalStore): ModelProviderCard[] => {
|
|||
{ ...BedrockProvider, enabled: enableBedrock(s) },
|
||||
{ ...OllamaProvider, chatModels: ollamaChatModels, enabled: enableOllama(s) },
|
||||
{ ...PerplexityProvider, enabled: enablePerplexity(s) },
|
||||
{ ...AnthropicProvider, enabled: enableAnthropic(s) },
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -212,4 +217,8 @@ export const modelProviderSelectors = {
|
|||
// Perplexity
|
||||
enablePerplexity,
|
||||
perplexityAPIKey,
|
||||
|
||||
// Anthropic
|
||||
enableAnthropic,
|
||||
anthropicAPIKey,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export interface ChatModelCard {
|
|||
* whether model is legacy (deprecated but not removed yet)
|
||||
*/
|
||||
legacy?: boolean;
|
||||
maxOutput?: number;
|
||||
tokens?: number;
|
||||
/**
|
||||
* whether model supports vision
|
||||
|
|
|
|||
|
|
@ -60,7 +60,13 @@ export interface PerplexityConfig {
|
|||
endpoint?: string;
|
||||
}
|
||||
|
||||
export interface AnthropicConfig {
|
||||
apiKey?: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface GlobalLLMConfig {
|
||||
anthropic: AnthropicConfig;
|
||||
azure: AzureOpenAIConfig;
|
||||
bedrock: AWSBedrockConfig;
|
||||
google: GoogleConfig;
|
||||
|
|
|
|||
Loading…
Reference in a new issue