Skip to content

Commit

Permalink
♻️ refactor: refactor Wenxin with LobeOpenAICompatibleFactory (#5729)
Browse files Browse the repository at this point in the history
* ♻️ refactor: refactor Wenxin with LobeOpenAICompatibleFactory

* 💄 style: update model list

* 📝 docs: update docs

* 💄 style: update model list
  • Loading branch information
hezhijie0327 authored Feb 5, 2025
1 parent db4e9c7 commit a90a75e
Show file tree
Hide file tree
Showing 28 changed files with 277 additions and 739 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ENV \
# Upstage
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
# Wenxin
WENXIN_ACCESS_KEY="" WENXIN_SECRET_KEY="" WENXIN_MODEL_LIST="" \
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
# xAI
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
# 01.AI
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ ENV \
# Upstage
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
# Wenxin
WENXIN_ACCESS_KEY="" WENXIN_SECRET_KEY="" WENXIN_MODEL_LIST="" \
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
# xAI
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
# 01.AI
Expand Down
29 changes: 16 additions & 13 deletions docs/usage/providers/wenxin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,30 @@ This article will guide you on how to use Wenxin Qianfan in LobeChat.
<Steps>
### Step 1: Obtain the Wenxin Qianfan API Key

- Register and log in to the [Baidu Intelligent Cloud Console](https://console.bce.baidu.com/)
- Navigate to `Baidu Intelligent Cloud Qianfan ModelBuilder`
- Choose `Application Access` from the left-side menu
- Create an application
- Register and log in to the [Baidu AI Cloud Console](https://console.bce.baidu.com/)
- Navigate to `Baidu AI Cloud Qianfan ModelBuilder`
- Select `API Key` from the left menu

<Image alt={'Create Application'} inStep src={'https://github.com/user-attachments/assets/927b1040-e23f-4919-92e2-80a400db8327'} />
<Image alt={'API Key'} inStep src={'https://github.com/user-attachments/assets/6234428d-5633-4b2f-be22-1a1772a69a55'} />

- Enter the `Security Authentication` -> `Access Key` management page from the user account menu
- Copy the `Access Key` and `Secret Key`, and store them safely
- Click `Create API Key`
- In `Service`, select `Qianfan ModelBuilder`
- In `Resource`, choose `All Resources`
- Click the `Confirm` button
- Copy the `API Key` and keep it safe

<Image alt={'Save Keys'} inStep src={'https://github.com/user-attachments/assets/bb9dadd3-7e9c-45fd-8c56-553ab7287453'} />
<Image alt={'Create API Key'} inStep src={'https://github.com/user-attachments/assets/6d068fe0-8100-4b43-b0c3-7934f54e688f'} />
<Image alt={'Copy API Key'} inStep src={'https://github.com/user-attachments/assets/629adf4e-e9e1-40dc-b9e5-d7b908878170'} />

### Step 2: Configure Wenxin Qianfan in LobeChat

- Go to the `Settings` interface in LobeChat
- Locate the settings for `Wenxin Qianfan` under `Language Model`
- Go to the `Settings` page of LobeChat
- Under `Language Models`, find the `Wenxin Qianfan` settings

<Image alt={'Enter API Keys'} inStep src={'https://github.com/user-attachments/assets/e3995de7-38d9-489b-80a2-434477018469'} />
<Image alt={'Enter API Key'} inStep src={'https://github.com/user-attachments/assets/d7666e2a-0202-4b45-8338-9806ddffa44e'} />

- Enter the obtained `Access Key` and `Secret Key`
- Select a Wenxin Qianfan model for your AI assistant to start interacting
- Enter the obtained `API Key`
- Select a Wenxin Qianfan model for your AI assistant, and you're ready to start chatting!

<Image alt={'Select Wenxin Qianfan Model and Start Chat'} inStep src={'https://github.com/user-attachments/assets/b6e6a3eb-13c6-46f0-9c7c-69a20deae30f'} />

Expand Down
19 changes: 11 additions & 8 deletions docs/usage/providers/wenxin.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@ tags:

- 注册并登录 [百度智能云控制台](https://console.bce.baidu.com/)
- 进入 `百度智能云千帆 ModelBuilder`
- 在左侧菜单中选择`应用接入`
- 创建一个应用
- 在左侧菜单中选择 `API Key`

<Image alt={'创建应用'} inStep src={'https://github.com/user-attachments/assets/927b1040-e23f-4919-92e2-80a400db8327'} />
<Image alt={'API Key'} inStep src={'https://github.com/user-attachments/assets/6234428d-5633-4b2f-be22-1a1772a69a55'} />

- 在用户账号菜单进入 `安全认证` -> `Access Key` 管理页面
- 复制 `Access Key``Secret Key`,并妥善保存
- 点击创建 API Key
-`服务` 中选择 `千帆ModelBuilder`
-`资源` 中选择 `所有资源`
- 点击 `确定` 按钮
- 复制 `API Key` 并妥善保存

<Image alt={'保存密钥'} inStep src={'https://github.com/user-attachments/assets/bb9dadd3-7e9c-45fd-8c56-553ab7287453'} />
<Image alt={'创建密钥'} inStep src={'https://github.com/user-attachments/assets/6d068fe0-8100-4b43-b0c3-7934f54e688f'} />
<Image alt={'复制密钥'} inStep src={'https://github.com/user-attachments/assets/629adf4e-e9e1-40dc-b9e5-d7b908878170'} />

### 步骤二:在 LobeChat 中配置文心千帆

- 访问 LobeChat 的`设置`界面
-`语言模型`下找到 `文心千帆` 的设置项

<Image alt={'填入 API 密钥'} inStep src={'https://github.com/user-attachments/assets/e3995de7-38d9-489b-80a2-434477018469'} />
<Image alt={'填入 API 密钥'} inStep src={'https://github.com/user-attachments/assets/d7666e2a-0202-4b45-8338-9806ddffa44e'} />

- 填入获得的 `Access Key``Secret Key`
- 填入获得的 `API Key`
- 为你的 AI 助手选择一个文心千帆的模型即可开始对话

<Image alt={'选择文心千帆模型并开始对话'} inStep src={'https://github.com/user-attachments/assets/b6e6a3eb-13c6-46f0-9c7c-69a20deae30f'} />
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"@aws-sdk/s3-request-presigner": "^3.723.0",
"@azure/core-rest-pipeline": "1.16.0",
"@azure/openai": "1.0.0-beta.12",
"@baiducloud/qianfan": "^0.1.9",
"@cfworker/json-schema": "^4.1.0",
"@clerk/localizations": "^3.9.6",
"@clerk/nextjs": "^6.10.6",
Expand Down
27 changes: 0 additions & 27 deletions src/app/(backend)/webapi/chat/wenxin/route.test.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/app/(backend)/webapi/chat/wenxin/route.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/app/(main)/settings/llm/ProviderList/Wenxin/index.tsx

This file was deleted.

6 changes: 2 additions & 4 deletions src/app/(main)/settings/llm/ProviderList/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
TaichuProviderCard,
TogetherAIProviderCard,
UpstageProviderCard,
WenxinProviderCard,
XAIProviderCard,
ZeroOneProviderCard,
ZhiPuProviderCard,
Expand All @@ -40,7 +41,6 @@ import { useGithubProvider } from './Github';
import { useHuggingFaceProvider } from './HuggingFace';
import { useOllamaProvider } from './Ollama';
import { useOpenAIProvider } from './OpenAI';
import { useWenxinProvider } from './Wenxin';

export const useProviderList = (): ProviderItem[] => {
const AzureProvider = useAzureProvider();
Expand All @@ -50,7 +50,6 @@ export const useProviderList = (): ProviderItem[] => {
const CloudflareProvider = useCloudflareProvider();
const GithubProvider = useGithubProvider();
const HuggingFaceProvider = useHuggingFaceProvider();
const WenxinProvider = useWenxinProvider();

return useMemo(
() => [
Expand All @@ -75,7 +74,7 @@ export const useProviderList = (): ProviderItem[] => {
UpstageProviderCard,
XAIProviderCard,
QwenProviderCard,
WenxinProvider,
WenxinProviderCard,
HunyuanProviderCard,
SparkProviderCard,
ZhiPuProviderCard,
Expand All @@ -99,7 +98,6 @@ export const useProviderList = (): ProviderItem[] => {
BedrockProvider,
CloudflareProvider,
GithubProvider,
WenxinProvider,
HuggingFaceProvider,
],
);
Expand Down
61 changes: 0 additions & 61 deletions src/app/(main)/settings/provider/(detail)/wenxin/page.tsx

This file was deleted.

Loading

0 comments on commit a90a75e

Please sign in to comment.