Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f2529182
authored
Feb 05, 2025
by
Archer
Committed by
GitHub
Feb 05, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model config doc (#3689)
parent
5c360b5a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
18 deletions
+51
-18
docSite/content/zh-cn/docs/development/modelConfig/intro.md
+36
-10
packages/web/i18n/en/account.json
+2
-2
packages/web/i18n/zh-CN/account.json
+2
-2
packages/web/i18n/zh-Hant/account.json
+2
-2
projects/app/src/pageComponents/account/model/ModelConfigTable.tsx
+9
-2
No files found.
docSite/content/zh-cn/docs/development/modelConfig/intro.md
View file @
f2529182
...
...
@@ -11,7 +11,9 @@ weight: 744
从 4.8.20 版本开始,你可以直接在 FastGPT 页面中进行模型配置,并且系统内置了大量模型,无需从 0 开始配置。下面介绍模型配置的基本流程:
## 1. 使用 OneAPI 对接模型提供商
## 配置模型
### 1. 使用 OneAPI 对接模型提供商
可以使用
[
OneAPI 接入教程
](
/docs/development/modelconfig/one-api
)
来进行模型聚合,从而可以对接更多模型提供商。你需要先在各服务商申请好 API 接入 OneAPI 后,才能在 FastGPT 中使用这些模型。示例流程如下:
...
...
@@ -26,28 +28,28 @@ weight: 744
在 OneAPI 配置好模型后,你就可以打开 FastGPT 页面,启用对应模型了。
## 2. 登录 root 用户
##
#
2. 登录 root 用户
仅 root 用户可以进行模型配置。
## 3. 进入模型配置页面
##
#
3. 进入模型配置页面
登录 root 用户后,在
`账号-模型提供商-模型配置`
中,你可以看到所有内置的模型和自定义模型,以及哪些模型启用了。

## 4. 配置介绍
##
#
4. 配置介绍
{{% alert icon="🤖 " context="success" %}}
注意:目前语音识别模型和重排模型仅会生效一个,所以配置时候,只需要配置一个即可。
{{% /alert %}}
### 核心配置
###
#
核心配置
-
模型 ID:接口请求时候,Body 中
`model`
字段的值,全局唯一。
-
自定义请求地址/Key:如果需要绕过
`OneAPI`
,可以设置自定义请求地址和 Token。一般情况下不需要,如果 OneAPI 不支持某些模型,可以使用该特性。
### 模型类型
###
#
模型类型
1.
语言模型 - 进行文本对话,多模态模型支持图片识别。
2.
索引模型 - 对文本块进行索引,用于相关文本检索。
...
...
@@ -55,7 +57,7 @@ weight: 744
4.
语音识别 - 将语音转换为文本。
5.
重排模型 - 对文本进行重排,用于优化文本质量。
### 启用模型
###
#
启用模型
系统内置了目前主流厂商的模型,如果你不熟悉配置,直接点击
`启用`
即可,需要注意到是,模型 ID 需要和 OneAPI 中渠道的
`模型`
一致。
...
...
@@ -63,7 +65,7 @@ weight: 744
| --- | --- |
| !
[
alt text
](
/imgs/image-91.png
)
| !
[
alt text
](
/imgs/image-92.png
)
|
### 修改模型配置
###
#
修改模型配置
点击模型右侧的齿轮即可进行模型配置,不同类型模型的配置有区别。
...
...
@@ -71,7 +73,7 @@ weight: 744
| --- | --- |
| !
[
alt text
](
/imgs/image-93.png
)
| !
[
alt text
](
/imgs/image-94.png
)
|
##
#
新增自定义模型
## 新增自定义模型
如果系统内置的模型无法满足你的需求,你可以添加自定义模型。自定义模型中,如果
`模型 ID`
与系统内置的模型 ID 一致,则会被认为是修改系统模型。
...
...
@@ -79,7 +81,7 @@ weight: 744
| --- | --- |
| !
[
alt text
](
/imgs/image-96.png
)
| !
[
alt text
](
/imgs/image-97.png
)
|
### 通过配置文件配置
###
#
通过配置文件配置
如果你觉得通过页面配置模型比较麻烦,你也可以通过配置文件来配置模型。或者希望快速将一个系统的配置,复制到另一个系统,也可以通过配置文件来实现。
...
...
@@ -258,6 +260,30 @@ OneAPI 的语言识别接口,无法正确的识别其他模型(会始终识
由于 OpenAI 没有提供 ReRank 模型,遵循的是 Cohere 的格式。
[
点击查看接口请求示例
](
/docs/development/faq/#如何检查模型问题
)
### 模型价格配置
商业版用户可以通过配置模型价格,来进行账号计费。系统包含两种计费模式:按总 tokens 计费和输入输出 Tokens 分开计费。
如果需要配置
`输入输出 Tokens 分开计费模式`
,则填写
`模型输入价格`
和
`模型输出价格`
两个值。
如果需要配置
`按总 tokens 计费模式`
,则填写
`模型综合价格`
一个值。
## 如何提交内置模型
由于模型更新非常频繁,官方不一定及时更新,如果未能找到你期望的内置模型,你可以
[
提交 Issue
](
https://github.com/labring/FastGPT/issues
)
,提供模型的名字和对应官网。或者直接
[
提交 PR
](
https://github.com/labring/FastGPT/pulls
)
,提供模型配置。
### 添加模型提供商
如果你需要添加模型提供商,需要修改以下代码:
1.
FastGPT/packages/web/components/common/Icon/icons/model - 在此目录下,添加模型提供商的 svg 头像地址。
2.
在 FastGPT 根目录下,运行
`pnpm initIcon`
,将图片加载到配置文件中。
3.
FastGPT/packages/global/core/ai/provider.ts - 在此文件中,追加模型提供商的配置。
### 添加模型
你可以在
`FastGPT/packages/service/core/ai/config/provider`
目录下,找对应模型提供商的配置文件,并追加模型配置。请自行全文检查,
`model`
字段,必须在所有模型中唯一。具体配置字段说明,参考
[
模型配置字段说明
](
/docs/development/modelconfig/intro/#通过配置文件配置
)
## 旧版模型配置说明
配置好 OneAPI 后,需要在
`config.json`
文件中,手动的增加模型配置,并重启。
...
...
packages/web/i18n/en/account.json
View file @
f2529182
...
...
@@ -20,9 +20,9 @@
"model.charsPointsPrice"
:
"Chars Price"
,
"model.charsPointsPrice_tip"
:
"Combine the model input and output for Token billing. If the language model is configured with input and output billing separately, the input and output will be calculated separately."
,
"model.custom_cq_prompt"
:
"Custom question classification prompt words"
,
"model.custom_cq_prompt_tip"
:
"Override the system's default question classification prompt words, which default to:
\n\"\"\"\n
请帮我执行一个“问题分类”任务,将问题分类为以下几种类型之一:
\n\n\"\"\"\n
{{typeList}}
\n\"\"\"\n\n
## 背景知识
\n
{{systemPrompt}}
\n\n
## 对话记录
\n
{{history}}
\n\n
## 开始任务
\n\n
现在,我们开始分类,我会给你一个
\"
问题
\"
,请结合背景知识和对话记录,将问题分类到对应的类型中,并返回类型ID。
\n\n
问题:
\"
{{question}}
\"\n
类型ID=
\n\"\"\"
"
,
"model.custom_cq_prompt_tip"
:
"Override the system's default question classification prompt words, which default to:
\n\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.custom_extract_prompt"
:
"Custom content extraction prompt words"
,
"model.custom_extract_prompt_tip"
:
"
Override system prompt word, default is:
\n\"\"\"\n
你可以从 <对话记录></对话记录> 中提取指定 Json 信息,你仅需返回 Json 字符串,无需回答问题。
\n
<提取要求>
\n
{{description}}
\n
</提取要求>
\n\n
<提取规则>
\n
- 本次需提取的 json 字符串,需符合 JsonSchema 的规则。
\n
- type 代表数据类型; key 代表字段名; description 代表字段的描述; enum 是枚举值,代表可选的 value。
\n
- 如果没有可提取的内容,忽略该字段。
\n
</提取规则>
\n\n
<JsonSchema>
\n
{{json}}
\n
</JsonSchema>
\n\n
<对话记录>
\n
{{text}}
\n
</对话记录>
\n\n
提取的 json 字符串:
\n\"\"\"
"
,
"model.custom_extract_prompt_tip"
:
"
The reminder word of the coverage of the system, the default:
\n\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.dataset_process"
:
"Dataset file parse"
,
"model.defaultConfig"
:
"Additional Body parameters"
,
"model.defaultConfig_tip"
:
"Each request will carry this additional Body parameter."
,
...
...
packages/web/i18n/zh-CN/account.json
View file @
f2529182
...
...
@@ -20,9 +20,9 @@
"model.charsPointsPrice"
:
"模型综合价格"
,
"model.charsPointsPrice_tip"
:
"将模型输入和输出合并起来进行 Token 计费,语言模型如果单独配置了输入和输出计费,则按输入和输出分别计算"
,
"model.custom_cq_prompt"
:
"自定义问题分类提示词"
,
"model.custom_cq_prompt_tip"
:
"覆盖系统默认的问题分类提示词,默认为:
\n
"
,
"model.custom_cq_prompt_tip"
:
"覆盖系统默认的问题分类提示词,默认为:
\n
\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.custom_extract_prompt"
:
"自定义内容提取提示词"
,
"model.custom_extract_prompt_tip"
:
"覆盖系统的提示词,默认为:
\n\"\"\"\n
你可以从 <对话记录></对话记录> 中提取指定 Json 信息,你仅需返回 Json 字符串,无需回答问题。
\n
<提取要求>
\n
{{description}}
\n
</提取要求>
\n\n
<提取规则>
\n
- 本次需提取的 json 字符串,需符合 JsonSchema 的规则。
\n
- type 代表数据类型; key 代表字段名; description 代表字段的描述; enum 是枚举值,代表可选的 value。
\n
- 如果没有可提取的内容,忽略该字段。
\n
</提取规则>
\n\n
<JsonSchema>
\n
{{json}}
\n
</JsonSchema>
\n\n
<对话记录>
\n
{{text}}
\n
</对话记录>
\n\n
提取的 json 字符串:
\n\"\"\"
"
,
"model.custom_extract_prompt_tip"
:
"覆盖系统的提示词,默认为:
\n\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.dataset_process"
:
"用于知识库文件处理"
,
"model.defaultConfig"
:
"额外 Body 参数"
,
"model.defaultConfig_tip"
:
"每次请求时候,都会携带该额外 Body 参数"
,
...
...
packages/web/i18n/zh-Hant/account.json
View file @
f2529182
...
...
@@ -19,9 +19,9 @@
"model.charsPointsPrice"
:
"模型綜合價格"
,
"model.charsPointsPrice_tip"
:
"將模型輸入和輸出合併起來進行 Token 計費,語言模型如果單獨配置了輸入和輸出計費,則按輸入和輸出分別計算"
,
"model.custom_cq_prompt"
:
"自訂問題分類提示詞"
,
"model.custom_cq_prompt_tip"
:
"覆蓋系統預設的問題分類提示詞,預設為:
\n\"\"\"\n
请帮我执行一个“问题分类”任务,将问题分类为以下几种类型之一:
\n\n\"\"\"\n
{{typeList}}
\n\"\"\"\n\n
## 背景知识
\n
{{systemPrompt}}
\n\n
## 对话记录
\n
{{history}}
\n\n
## 开始任务
\n\n
现在,我们开始分类,我会给你一个
\"
问题
\"
,请结合背景知识和对话记录,将问题分类到对应的类型中,并返回类型ID。
\n\n
问题:
\"
{{question}}
\"\n
类型ID=
\n\"\"\"
"
,
"model.custom_cq_prompt_tip"
:
"覆蓋系統預設的問題分類提示詞,預設為:
\n\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.custom_extract_prompt"
:
"自訂內容提取提示詞"
,
"model.custom_extract_prompt_tip"
:
"覆蓋系統的提示詞,
預設為:
\n\"\"\"\n
你可以从 <对话记录></对话记录> 中提取指定 Json 信息,你仅需返回 Json 字符串,无需回答问题。
\n
<提取要求>
\n
{{description}}
\n
</提取要求>
\n\n
<提取规则>
\n
- 本次需提取的 json 字符串,需符合 JsonSchema 的规则。
\n
- type 代表数据类型; key 代表字段名; description 代表字段的描述; enum 是枚举值,代表可选的 value。
\n
- 如果没有可提取的内容,忽略该字段。
\n
</提取规则>
\n\n
<JsonSchema>
\n
{{json}}
\n
</JsonSchema>
\n\n
<对话记录>
\n
{{text}}
\n
</对话记录>
\n\n
提取的 json 字符串:
\n\"\"\"
"
,
"model.custom_extract_prompt_tip"
:
"覆蓋系統的提示詞,
默認為:
\n\"\"\"\n
{{prompt}}
\n\"\"\"
"
,
"model.dataset_process"
:
"用於知識庫文件處理"
,
"model.defaultConfig"
:
"額外 Body 參數"
,
"model.defaultConfig_tip"
:
"每次請求時候,都會攜帶該額外 Body 參數"
,
...
...
projects/app/src/pageComponents/account/model/ModelConfigTable.tsx
View file @
f2529182
...
...
@@ -58,6 +58,7 @@ import CopyBox from '@fastgpt/web/components/common/String/CopyBox';
import
MyIcon
from
'@fastgpt/web/components/common/Icon'
;
import
AIModelSelector
from
'@/components/Select/AIModelSelector'
;
import
{
useRefresh
}
from
'../../../../../../packages/web/hooks/useRefresh'
;
import
{
Prompt_CQJson
,
Prompt_ExtractJson
}
from
'@fastgpt/global/core/ai/prompt/agent'
;
const
MyModal
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/MyModal'
));
...
...
@@ -983,7 +984,9 @@ const ModelEditModal = ({
<
Td
>
<
HStack
spacing=
{
1
}
>
<
Box
>
{
t
(
'account:model.custom_cq_prompt'
)
}
</
Box
>
<
QuestionTip
label=
{
t
(
'account:model.custom_cq_prompt_tip'
)
}
/>
<
QuestionTip
label=
{
t
(
'account:model.custom_cq_prompt_tip'
,
{
prompt
:
Prompt_CQJson
})
}
/>
</
HStack
>
</
Td
>
<
Td
textAlign=
{
'right'
}
>
...
...
@@ -994,7 +997,11 @@ const ModelEditModal = ({
<
Td
>
<
HStack
spacing=
{
1
}
>
<
Box
>
{
t
(
'account:model.custom_extract_prompt'
)
}
</
Box
>
<
QuestionTip
label=
{
t
(
'account:model.custom_extract_prompt_tip'
)
}
/>
<
QuestionTip
label=
{
t
(
'account:model.custom_extract_prompt_tip'
,
{
prompt
:
Prompt_ExtractJson
})
}
/>
</
HStack
>
</
Td
>
<
Td
textAlign=
{
'right'
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment