Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: Support Cloudflare Workers AI #2966

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f2996eb
Delete .nvmrc
sxjeru May 31, 2024
6de6000
Merge branch 'lobehub:main' into cf
sxjeru Jun 21, 2024
4b1d4c6
feat: Add Cloudflare as a model provider
sxjeru Jun 21, 2024
b774549
fix
sxjeru Jun 21, 2024
1336aae
fix
sxjeru Jun 21, 2024
ff5361e
fix
sxjeru Jun 21, 2024
6d658bd
fix
sxjeru Jun 21, 2024
5a0a4da
fix
sxjeru Jun 21, 2024
3608659
fix
sxjeru Jun 21, 2024
161af46
fix
sxjeru Jun 21, 2024
aa609af
fix icon
sxjeru Jun 21, 2024
0972e11
fix
sxjeru Jun 21, 2024
8ad1100
Create .nvmrc
sxjeru Jun 21, 2024
ed2f3c0
Delete src/config/modelProviders/.nvmrc
sxjeru Jun 21, 2024
e47aee5
CF -> CLOUDFLARE
sxjeru Jun 21, 2024
1909a89
Merge branch 'cf' of https://github.com/sxjeru/lobe-chat into cf
sxjeru Jun 21, 2024
5a1180c
revert
sxjeru Jun 21, 2024
7648bde
chore: Update agentRuntime.ts and auth.ts to support Cloudflare accou…
sxjeru Jun 21, 2024
9d036ee
Add provider setting
sxjeru Jun 21, 2024
7fe9401
fix
sxjeru Jun 21, 2024
fa23ba4
Update cloudflare.ts
sxjeru Jun 21, 2024
4414320
fix
sxjeru Jun 24, 2024
8d1f973
Update cloudflare.ts
sxjeru Jun 24, 2024
3b57709
Merge branch 'main' into cf
sxjeru Jun 24, 2024
7efaab9
accountID
sxjeru Jul 1, 2024
87f0721
fix
sxjeru Jul 1, 2024
7844a5b
Merge branch 'main' into cf
sxjeru Jul 1, 2024
26de0f1
i18n
sxjeru Jul 1, 2024
65463e0
Merge branch 'main' into cf
sxjeru Jul 10, 2024
7fe207a
Merge branch 'main' into cf
sxjeru Jul 25, 2024
e0f541a
Update index.ts
sxjeru Jul 27, 2024
bc26fd8
Update baichuan.ts
sxjeru Jul 27, 2024
0f5462f
Merge branch 'main' into cf
sxjeru Jul 27, 2024
bb02954
Update cloudflare.ts
sxjeru Jul 27, 2024
85021aa
save changes
BrandonStudio Jul 31, 2024
cb7dd1c
commit check
BrandonStudio Jul 31, 2024
ac8d4f2
disable function calling for now
BrandonStudio Jul 31, 2024
eefacf5
does not catch errors when fetching models
BrandonStudio Jul 31, 2024
5fc4c81
ready to add base url
BrandonStudio Jul 31, 2024
52ff9d1
commit check
BrandonStudio Jul 31, 2024
b8492e2
revert change
BrandonStudio Aug 1, 2024
b452d30
revert string boolean check
BrandonStudio Aug 1, 2024
b46c642
fix type error on Vercel.
BrandonStudio Aug 1, 2024
2dca07d
i18n by groq/llama-3.1-8b-instant
BrandonStudio Aug 1, 2024
0f40d15
rename env var
BrandonStudio Aug 1, 2024
8469931
Merge branch 'cf' into pr/BrandonStudio/38
sxjeru Aug 1, 2024
b3351d8
Merge branch 'main' into cf
sxjeru Aug 1, 2024
65c0bd2
Merge branch 'main' into cf
sxjeru Aug 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ OPENAI_API_KEY=sk-xxxxxxxxx

# QWEN_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

### Cloudflare Workers AI ####

# CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


########################################
############ Market Service ############
########################################
Expand Down
12 changes: 12 additions & 0 deletions locales/ar/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "استخدام معلومات المصادقة الخاصة بـ Bedrock المخصصة"
}
},
"cloudflare": {
"apiKey": {
"desc": "يرجى ملء Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "أدخل رقم حساب Cloudflare أو عنوان URL API المخصص",
"placeholder": "رقم حساب Cloudflare / عنوان URL API المخصص",
"title": "رقم حساب Cloudflare / عنوان URL API"
}
},
"ollama": {
"checker": {
"desc": "اختبر ما إذا تم إدخال عنوان الوكيل بشكل صحيح",
Expand Down
12 changes: 12 additions & 0 deletions locales/bg-BG/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Използване на персонализирана информация за удостоверяване на Bedrock"
}
},
"cloudflare": {
"apiKey": {
"desc": "Моля, въведете Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Въведете ID на Cloudflare или личен API адрес",
"placeholder": "ID на Cloudflare / личен API адрес",
"title": "ID на Cloudflare / API адрес"
}
},
"ollama": {
"checker": {
"desc": "Тестване дали адресът на прокси е попълнен правилно",
Expand Down
12 changes: 12 additions & 0 deletions locales/de-DE/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Verwenden Sie benutzerdefinierte Bedrock-Authentifizierungsinformationen"
}
},
"cloudflare": {
"apiKey": {
"desc": "Bitte füllen Sie die Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Eingeben Sie die Cloudflare-Kundenkennung oder die benutzerdefinierte API-Adresse",
"placeholder": "Cloudflare-Kundenkennung / benutzerdefinierte API-Adresse",
"title": "Cloudflare-Kundenkennung / API-Adresse"
}
},
"ollama": {
"checker": {
"desc": "Testen Sie, ob die Proxy-Adresse korrekt eingetragen wurde",
Expand Down
12 changes: 12 additions & 0 deletions locales/en-US/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Use Custom Bedrock Authentication Information"
}
},
"cloudflare": {
"apiKey": {
"desc": "Please enter Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Enter your Cloudflare account ID or custom API address",
"placeholder": "Cloudflare Account ID / custom API URL",
"title": "Cloudflare Account ID / API Address"
}
},
"ollama": {
"checker": {
"desc": "Test if the proxy address is correctly filled in",
Expand Down
12 changes: 12 additions & 0 deletions locales/es-ES/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Usar información de autenticación de Bedrock personalizada"
}
},
"cloudflare": {
"apiKey": {
"desc": "Por favor complete la Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Ingrese el ID de cuenta de Cloudflare o la dirección URL personalizada de API",
"placeholder": "ID de cuenta de Cloudflare / URL de API personalizada",
"title": "ID de cuenta de Cloudflare / dirección URL de API"
}
},
"ollama": {
"checker": {
"desc": "Prueba si la dirección del proxy de la interfaz se ha introducido correctamente",
Expand Down
12 changes: 12 additions & 0 deletions locales/fr-FR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Utiliser des informations d'authentification Bedrock personnalisées"
}
},
"cloudflare": {
"apiKey": {
"desc": "Veuillez remplir l'Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Saisir l'ID de compte Cloudflare ou l'adresse API personnalisée",
"placeholder": "ID de compte Cloudflare / URL API personnalisée",
"title": "ID de compte Cloudflare / adresse API"
}
},
"ollama": {
"checker": {
"desc": "Vérifiez si l'adresse du proxy est correctement saisie",
Expand Down
12 changes: 12 additions & 0 deletions locales/it-IT/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Usa le informazioni di autenticazione Bedrock personalizzate"
}
},
"cloudflare": {
"apiKey": {
"desc": "Compila l'Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Inserisci l'ID dell'account Cloudflare o l'indirizzo API personalizzato",
"placeholder": "ID account Cloudflare / URL API personalizzato",
"title": "ID account Cloudflare / indirizzo API"
}
},
"ollama": {
"checker": {
"desc": "Verifica se l'indirizzo del proxy è stato compilato correttamente",
Expand Down
12 changes: 12 additions & 0 deletions locales/ja-JP/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "使用カスタム Bedrock 認証情報"
}
},
"cloudflare": {
"apiKey": {
"desc": "Cloudflare API Key を入力してください",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Cloudflare アカウント ID またはカスタム API アドレスを入力してください。",
"placeholder": "Cloudflare アカウント ID / カスタム API URL",
"title": "Cloudflare アカウント ID / API アドレス"
}
},
"ollama": {
"checker": {
"desc": "プロキシアドレスが正しく入力されているかをテストします",
Expand Down
12 changes: 12 additions & 0 deletions locales/ko-KR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "사용자 정의 Bedrock 인증 정보 사용"
}
},
"cloudflare": {
"apiKey": {
"desc": "Cloudflare API Key 를 작성해 주세요.",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "클라우드 플레어 계정 ID 또는 사용자 지정 API 주소 입력",
"placeholder": "클라우드 플레어 계정 ID / 사용자 지정 API 주소",
"title": "클라우드 플레어 계정 ID / API 주소"
}
},
"ollama": {
"checker": {
"desc": "프록시 주소가 올바르게 입력되었는지 테스트합니다",
Expand Down
12 changes: 12 additions & 0 deletions locales/nl-NL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Gebruik aangepaste Bedrock-verificatiegegevens"
}
},
"cloudflare": {
"apiKey": {
"desc": "Voer Cloudflare API Key in",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Voer uw Cloudflare-account ID of een custom API-URL in",
"placeholder": "Cloudflare-account ID / custom API-URL",
"title": "Cloudflare-account ID / API-URL"
}
},
"ollama": {
"checker": {
"desc": "Test of het proxyadres correct is ingevuld",
Expand Down
12 changes: 12 additions & 0 deletions locales/pl-PL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Użyj niestandardowych informacji uwierzytelniających Bedrock"
}
},
"cloudflare": {
"apiKey": {
"desc": "Wprowadź klucz Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Wprowadź ID konta Cloudflare lub adres API niestandardowy",
"placeholder": "ID konta Cloudflare / adres API niestandardowy",
"title": "ID konta Cloudflare / adres API"
}
},
"ollama": {
"checker": {
"desc": "Test czy adres proxy jest poprawnie wypełniony",
Expand Down
12 changes: 12 additions & 0 deletions locales/pt-BR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Usar informações de autenticação Bedrock personalizadas"
}
},
"cloudflare": {
"apiKey": {
"desc": "Insira o Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Insira o ID da conta do Cloudflare ou o endereço da API personalizado",
"placeholder": "ID da conta do Cloudflare / URL da API personalizada",
"title": "ID da conta do Cloudflare / Endereço da API"
}
},
"ollama": {
"checker": {
"desc": "Teste se o endereço do proxy está corretamente preenchido",
Expand Down
12 changes: 12 additions & 0 deletions locales/ru-RU/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Использовать пользовательскую информацию аутентификации Bedrock"
}
},
"cloudflare": {
"apiKey": {
"desc": "Пожалуйста, заполните Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Введите ID аккаунта Cloudflare или адрес API по умолчанию",
"placeholder": "ID аккаунта Cloudflare / адрес API по умолчанию",
"title": "ID аккаунта Cloudflare / адрес API"
}
},
"ollama": {
"checker": {
"desc": "Проверить правильность адреса прокси",
Expand Down
12 changes: 12 additions & 0 deletions locales/tr-TR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Özel Bedrock Kimlik Bilgilerini Kullan"
}
},
"cloudflare": {
"apiKey": {
"desc": "Lütfen doldurun Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Cloudflare hesabınızın ID'sini veya özel API adresinizi girin",
"placeholder": "Cloudflare Hesap ID / Özel API Adresi",
"title": "Cloudflare Hesap ID / API Adresi"
}
},
"ollama": {
"checker": {
"desc": "Proxy adresinin doğru girilip girilmediğini test edin",
Expand Down
12 changes: 12 additions & 0 deletions locales/vi-VN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "Sử dụng Thông tin Xác thực Bedrock tùy chỉnh"
}
},
"cloudflare": {
"apiKey": {
"desc": "Vui lòng nhập Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "Nhập ID tài khoản Cloudflare hoặc địa chỉ API tùy chỉnh",
"placeholder": "ID tài khoản Cloudflare / địa chỉ API tùy chỉnh",
"title": "ID tài khoản Cloudflare / địa chỉ API"
}
},
"ollama": {
"checker": {
"desc": "Kiểm tra địa chỉ proxy có được nhập chính xác không",
Expand Down
12 changes: 12 additions & 0 deletions locales/zh-CN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "使用自定义 Bedrock 鉴权信息"
}
},
"cloudflare": {
"apiKey": {
"desc": "请填写 Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "填入 Cloudflare 账户 ID 或 自定义 API 地址",
"placeholder": "Cloudflare Account ID / custom API URL",
"title": "Cloudflare 账户 ID / API 地址"
}
},
"ollama": {
"checker": {
"desc": "测试代理地址是否正确填写",
Expand Down
12 changes: 12 additions & 0 deletions locales/zh-TW/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"title": "使用自定義 Bedrock 驗證資訊"
}
},
"cloudflare": {
"apiKey": {
"desc": "請填入 Cloudflare API Key",
"placeholder": "Cloudflare API Key",
"title": "Cloudflare API Key"
},
"baseURLOrAccountID": {
"desc": "填入 Cloudflare 帳戶 ID 或 自定義 API 位址",
"placeholder": "Cloudflare 帳戶 ID / 自定義 API 位址",
"title": "Cloudflare 帳戶 ID / API 位址"
}
},
"ollama": {
"checker": {
"desc": "測試代理地址是否正確填寫",
Expand Down
45 changes: 45 additions & 0 deletions src/app/(main)/settings/llm/ProviderList/Cloudflare/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use client';

import { Input } from 'antd';
import { useTranslation } from 'react-i18next';

import { CloudflareProviderCard } from '@/config/modelProviders';
import { GlobalLLMProviderKey } from '@/types/user/settings';

import { KeyVaultsConfigKey } from '../../const';
import { ProviderItem } from '../../type';
import { CloudflareBrand } from '../providers';

const providerKey: GlobalLLMProviderKey = 'cloudflare';

export const useCloudflareProvider = (): ProviderItem => {
const { t } = useTranslation('modelProvider');

return {
...CloudflareProviderCard,
apiKeyItems: [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`${providerKey}.apiKey.placeholder`)}
/>
),
desc: t(`${providerKey}.apiKey.desc`),
label: t(`${providerKey}.apiKey.title`),
name: [KeyVaultsConfigKey, providerKey, 'apiKey'],
},
{
children: (
<Input
placeholder={t(`${providerKey}.baseURLOrAccountID.placeholder`)}
/>
),
desc: t(`${providerKey}.baseURLOrAccountID.desc`),
label: t(`${providerKey}.baseURLOrAccountID.title`),
name: [KeyVaultsConfigKey, providerKey, 'baseURLOrAccountID'],
},
],
title: <CloudflareBrand />,
};
};
Loading
Loading