-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Support Cloudflare Workers AI (#3402)
* Delete .nvmrc * feat: Add Cloudflare as a model provider This commit adds support for Cloudflare as a model provider. It includes changes to the `ModelProvider` enum, the `UserKeyVaults` interface, the `getServerGlobalConfig` function, the `DEFAULT_LLM_CONFIG` constant, the `getLLMConfig` function, the `AgentRuntime` class, and the `DEFAULT_MODEL_PROVIDER_LIST` constant. * fix * fix * fix * fix * fix * fix * fix * fix icon * fix * Create .nvmrc * Delete src/config/modelProviders/.nvmrc * CF -> CLOUDFLARE * revert * chore: Update agentRuntime.ts and auth.ts to support Cloudflare account ID in payload * Add provider setting * fix * Update cloudflare.ts * fix * Update cloudflare.ts * accountID * fix * i18n * save changes * commit check * disable function calling for now * does not catch errors when fetching models * ready to add base url * commit check * revert change * revert string boolean check * fix type error on Vercel. refer to vercel/next.js#38736 (comment) * i18n by groq/llama-3.1-8b-instant * rename env var * add test * Revert changes that are not relavant to Cloudflare and result in merge conflicts. * add test for models() * move helper code to standalone file * add test for helper methods * remove encoder * Merge main into cf-chat-m * remove brand * remove template comment * add provider card * Update lobe-icons * Fix setting layout * minor modification of model list --------- Co-authored-by: sxjeru <sxjeru@gmail.com>
- Loading branch information
1 parent
b4514cf
commit efb7adf
Showing
40 changed files
with
1,672 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/app/(main)/settings/llm/ProviderList/Cloudflare/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'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'; | ||
|
||
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'], | ||
}, | ||
], | ||
}; | ||
}; |
Oops, something went wrong.