Skip to content

Commit

Permalink
🐛 fix: fix custom ai provider sdk type (#6712)
Browse files Browse the repository at this point in the history
* fix issue

* update locale
  • Loading branch information
arvinxx authored Mar 5, 2025
1 parent c814c31 commit 7f8c379
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 27 deletions.
3 changes: 3 additions & 0 deletions locales/ar/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "تحديث التكوين الأساسي للمزود",
"updateSuccess": "تم التحديث بنجاح"
},
"updateCustomAiProvider": {
"title": "تحديث إعدادات مزود الذكاء الاصطناعي المخصص"
},
"vertexai": {
"apiKey": {
"desc": "أدخل مفاتيح Vertex AI الخاصة بك",
Expand Down
3 changes: 3 additions & 0 deletions locales/bg-BG/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Актуализиране на основната конфигурация на доставчика",
"updateSuccess": "Актуализацията е успешна"
},
"updateCustomAiProvider": {
"title": "Актуализиране на конфигурацията на доставчика на персонализирани AI услуги"
},
"vertexai": {
"apiKey": {
"desc": "Въведете вашите ключове за Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/de-DE/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Aktualisieren Sie die grundlegenden Anbieterinformationen",
"updateSuccess": "Aktualisierung erfolgreich"
},
"updateCustomAiProvider": {
"title": "Konfiguration des benutzerdefinierten KI-Anbieters aktualisieren"
},
"vertexai": {
"apiKey": {
"desc": "Geben Sie Ihre Vertex AI-Schlüssel ein",
Expand Down
3 changes: 3 additions & 0 deletions locales/en-US/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Update provider basic configuration",
"updateSuccess": "Update successful"
},
"updateCustomAiProvider": {
"title": "Update Custom AI Provider Configuration"
},
"vertexai": {
"apiKey": {
"desc": "Enter your Vertex AI Keys",
Expand Down
3 changes: 3 additions & 0 deletions locales/es-ES/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Actualizar configuración básica del proveedor",
"updateSuccess": "Actualización exitosa"
},
"updateCustomAiProvider": {
"title": "Actualizar la configuración del proveedor de IA personalizado"
},
"vertexai": {
"apiKey": {
"desc": "Introduce tus claves de Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/fa-IR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "به‌روزرسانی پیکربندی پایه ارائه‌دهنده",
"updateSuccess": "به‌روزرسانی با موفقیت انجام شد"
},
"updateCustomAiProvider": {
"title": "به‌روزرسانی تنظیمات ارائه‌دهنده AI سفارشی"
},
"vertexai": {
"apiKey": {
"desc": "کلیدهای Vertex AI خود را وارد کنید",
Expand Down
3 changes: 3 additions & 0 deletions locales/fr-FR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Mettre à jour la configuration de base du fournisseur",
"updateSuccess": "Mise à jour réussie"
},
"updateCustomAiProvider": {
"title": "Mettre à jour la configuration du fournisseur de services AI personnalisé"
},
"vertexai": {
"apiKey": {
"desc": "Entrez vos clés Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/it-IT/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Aggiorna la configurazione di base del fornitore",
"updateSuccess": "Aggiornamento avvenuto con successo"
},
"updateCustomAiProvider": {
"title": "Aggiorna la configurazione del fornitore di AI personalizzato"
},
"vertexai": {
"apiKey": {
"desc": "Inserisci le tue chiavi Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "サービスプロバイダーの基本設定を更新",
"updateSuccess": "更新に成功しました"
},
"updateCustomAiProvider": {
"title": "カスタム AI プロバイダー設定の更新"
},
"vertexai": {
"apiKey": {
"desc": "あなたの Vertex AI キーを入力してください",
Expand Down
3 changes: 3 additions & 0 deletions locales/ko-KR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "서비스 제공자 기본 설정 업데이트",
"updateSuccess": "업데이트 성공"
},
"updateCustomAiProvider": {
"title": "사용자 정의 AI 서비스 제공자 구성 업데이트"
},
"vertexai": {
"apiKey": {
"desc": "당신의 Vertex AI 키를 입력하세요",
Expand Down
3 changes: 3 additions & 0 deletions locales/nl-NL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Werk basisconfiguratie van provider bij",
"updateSuccess": "Bijwerking geslaagd"
},
"updateCustomAiProvider": {
"title": "Bijwerken van de configuratie van de aangepaste AI-provider"
},
"vertexai": {
"apiKey": {
"desc": "Vul je Vertex AI-sleutels in",
Expand Down
3 changes: 3 additions & 0 deletions locales/pl-PL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Aktualizuj podstawowe ustawienia dostawcy",
"updateSuccess": "Aktualizacja zakończona sukcesem"
},
"updateCustomAiProvider": {
"title": "Aktualizuj konfigurację dostawcy AI"
},
"vertexai": {
"apiKey": {
"desc": "Wprowadź swoje klucze Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/pt-BR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Atualizar configurações básicas do provedor",
"updateSuccess": "Atualização bem-sucedida"
},
"updateCustomAiProvider": {
"title": "Atualizar configuração do provedor de IA personalizado"
},
"vertexai": {
"apiKey": {
"desc": "Insira suas Chaves do Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/ru-RU/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Обновить базовую конфигурацию провайдера",
"updateSuccess": "Обновление успешно"
},
"updateCustomAiProvider": {
"title": "Обновить настройки поставщика пользовательского ИИ"
},
"vertexai": {
"apiKey": {
"desc": "Введите ваши ключи Vertex AI",
Expand Down
3 changes: 3 additions & 0 deletions locales/tr-TR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Hizmet sağlayıcının temel yapılandırmasını güncelle",
"updateSuccess": "Güncelleme başarılı"
},
"updateCustomAiProvider": {
"title": "Özel AI Sağlayıcı Yapılandırmasını Güncelle"
},
"vertexai": {
"apiKey": {
"desc": "Vertex AI Anahtarlarınızı buraya girin",
Expand Down
3 changes: 3 additions & 0 deletions locales/vi-VN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "Cập nhật cấu hình cơ bản của nhà cung cấp",
"updateSuccess": "Cập nhật thành công"
},
"updateCustomAiProvider": {
"title": "Cập nhật cấu hình nhà cung cấp AI tùy chỉnh"
},
"vertexai": {
"apiKey": {
"desc": "Nhập khóa Vertex AI của bạn",
Expand Down
3 changes: 3 additions & 0 deletions locales/zh-CN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "更新服务商基础配置",
"updateSuccess": "更新成功"
},
"updateCustomAiProvider": {
"title": "更新自定义 AI 服务商配置"
},
"vertexai": {
"apiKey": {
"desc": "填入你的 Vertex Ai Keys",
Expand Down
3 changes: 3 additions & 0 deletions locales/zh-TW/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
"tooltip": "更新服務商基礎配置",
"updateSuccess": "更新成功"
},
"updateCustomAiProvider": {
"title": "更新自訂 AI 服務商配置"
},
"vertexai": {
"apiKey": {
"desc": "填入你的 Vertex AI 金鑰",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open }) => {
),
label: t('createNewAiProvider.sdkType.title'),
minWidth: 400,
name: 'sdkType',
name: ['settings', 'sdkType'],
rules: [{ message: t('createNewAiProvider.sdkType.required'), required: true }],
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ProviderIcon } from '@lobehub/icons';
import { FormModal, Icon } from '@lobehub/ui';
import type { FormItemProps } from '@lobehub/ui/es/Form/components/FormItem';
import { App, Button, Input } from 'antd';
import { App, Button, Input, Select } from 'antd';
import { BrainIcon } from 'lucide-react';
import { useRouter } from 'next/navigation';
import { memo, useState } from 'react';
Expand Down Expand Up @@ -78,6 +79,33 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initial
},
];

const configItems: FormItemProps[] = [
{
children: (
<Select
optionRender={({ label, value }) => (
<Flexbox align={'center'} gap={8} horizontal>
<ProviderIcon provider={value as string} size={18} />
{label}
</Flexbox>
)}
options={[
{ label: 'OpenAI', value: 'openai' },
{ label: 'Anthropic', value: 'anthropic' },
{ label: 'Ollama', value: 'ollama' },
// { label: 'Azure AI', value: 'azureai' },
]}
placeholder={t('createNewAiProvider.sdkType.placeholder')}
variant={'filled'}
/>
),
label: t('createNewAiProvider.sdkType.title'),
minWidth: 400,
name: ['settings', 'sdkType'],
rules: [{ message: t('createNewAiProvider.sdkType.required'), required: true }],
},
];

return (
<FormModal
footer={
Expand Down Expand Up @@ -118,6 +146,10 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initial
children: basicItems,
title: t('createNewAiProvider.basicTitle'),
},
{
children: configItems,
title: t('createNewAiProvider.configTitle'),
},
]}
onCancel={onClose}
onFinish={onFinish}
Expand All @@ -127,7 +159,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initial
title={
<Flexbox gap={8} horizontal>
<Icon icon={BrainIcon} />
{t('createNewAiProvider.title')}
{t('updateCustomAiProvider.title')}
</Flexbox>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,21 @@ const ProviderConfig = memo<ProviderConfigProps>(
{name}
</Flexbox>
) : (
<ProviderCombine provider={id} size={24} />
<>
<ProviderCombine provider={id} size={24} />
<Tooltip title={t('providerModels.config.helpDoc')}>
<Link
href={urlJoin(BASE_PROVIDER_DOC_URL, id)}
onClick={(e) => e.stopPropagation()}
target={'_blank'}
>
<Center className={styles.help} height={20} width={20}>
?
</Center>
</Link>
</Tooltip>
</>
)}
<Tooltip title={t('providerModels.config.helpDoc')}>
<Link
href={urlJoin(BASE_PROVIDER_DOC_URL, id)}
onClick={(e) => e.stopPropagation()}
target={'_blank'}
>
<Center className={styles.help} height={20} width={20}>
?
</Center>
</Link>
</Tooltip>
</Flexbox>
),
};
Expand Down
12 changes: 6 additions & 6 deletions src/features/Conversation/Extras/Usage/UsageDetail/ModelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ const ModelCard = memo<ModelCardProps>(({ pricing, id, provider, displayName })
<div />
<Flexbox align={'center'} className={styles.pricing} gap={8} horizontal>
{t('messages.modelCard.creditPricing')}:
<Tooltip title={t('messages.modelCard.pricing.inputTokens', { amount: inputPrice })}>
<Flexbox gap={2} horizontal>
<Icon icon={ArrowUpFromDot} />
{inputPrice}
</Flexbox>
</Tooltip>
{pricing?.cachedInput && (
<Tooltip
title={t('messages.modelCard.pricing.inputCachedTokens', {
Expand All @@ -108,12 +114,6 @@ const ModelCard = memo<ModelCardProps>(({ pricing, id, provider, displayName })
</Flexbox>
</Tooltip>
)}
<Tooltip title={t('messages.modelCard.pricing.inputTokens', { amount: inputPrice })}>
<Flexbox gap={2} horizontal>
<Icon icon={ArrowUpFromDot} />
{inputPrice}
</Flexbox>
</Tooltip>
<Tooltip title={t('messages.modelCard.pricing.outputTokens', { amount: outputPrice })}>
<Flexbox gap={2} horizontal>
<Icon icon={ArrowDownToDot} />
Expand Down
12 changes: 6 additions & 6 deletions src/features/Conversation/Extras/Usage/UsageDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ const TokenDetail = memo<TokenDetailProps>(({ usage, model, provider }) => {
].filter(Boolean) as TokenProgressItem[];

const totalDetail = [
!!detailTokens.cachedInput && {
color: theme.orange,
id: 'cachedInput',
title: t('messages.tokenDetails.inputCached'),
value: isShowCredit ? detailTokens.cachedInput.credit : detailTokens.cachedInput.token,
},
!!detailTokens.uncachedInput && {
color: theme.colorFill,

id: 'uncachedInput',
title: t('messages.tokenDetails.inputUncached'),
value: isShowCredit ? detailTokens.uncachedInput.credit : detailTokens.uncachedInput.token,
},
!!detailTokens.cachedInput && {
color: theme.orange,
id: 'cachedInput',
title: t('messages.tokenDetails.inputCached'),
value: isShowCredit ? detailTokens.cachedInput.credit : detailTokens.cachedInput.token,
},
!!detailTokens.totalOutput && {
color: theme.colorSuccess,
id: 'output',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/default/modelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ export default {
tooltip: '更新服务商基础配置',
updateSuccess: '更新成功',
},
updateCustomAiProvider: {
title: '更新自定义 AI 服务商配置',
},
vertexai: {
apiKey: {
desc: '填入你的 Vertex Ai Keys',
Expand Down

0 comments on commit 7f8c379

Please sign in to comment.