mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00

* fix: remove DefaultTeam (#4037) * fix :Get application bound knowledge base information logical rewrite (#4057) * fix :Get application bound knowledge base information logical rewrite * fix :Get application bound knowledge base information logical rewrite * fix :Get application bound knowledge base information logical rewrite * fix :Get application bound knowledge base information logical rewrite * update package * fix: import dataset step error;perf: ai proxy avatar (#4074) * perf: pg config params * perf: ai proxy avatar * fix: import dataset step error * feat: data input ux * perf: app dataset rewite * fix: 文本提取不支持arrayString,arrayNumber等jsonSchema (#4079) * update doc ;perf: model test (#4098) * perf: extract array * update doc * perf: model test * perf: model test * perf: think tag parse (#4102) * chat quote reader (#3912) * init chat quote full text reader * linked structure * dataset data linked * optimize code * fix ts build * test finish * delete log * fix * fix ts * fix ts * remove nextId * initial scroll * fix * fix * perf: chunk read (#4109) * package * perf: chunk read * feat: api dataset support pdf parse;fix: chunk reader auth (#4117) * feat: api dataset support pdf parse * fix: chunk reader auth * feat: invitation link (#3979) * feat: invitation link schema and apis * feat: add invitation link * feat: member status: active, leave, forbidden * fix: expires show hours and minutes * feat: invalid invitation link hint * fix: typo * chore: fix typo & i18n * fix * pref: fe * feat: add ttl index for 30-day-clean-up * perf: invite member code (#4118) * perf: invite member code * fix: ts * fix: model test channel id;fix: quote reader (#4123) * fix: model test channel id * fix: quote reader * fix chat quote reader (#4125) * perf: model test;perf: sidebar trigger (#4127) * fix: import dataset step error;perf: ai proxy avatar (#4074) * perf: pg config params * perf: ai proxy avatar * fix: import dataset step error * feat: data input ux * perf: app dataset rewite * perf: model test * perf: sidebar trigger * lock * update nanoid version * fix: select component ux * fix: ts * fix: vitest * remove test * fix: prompt toolcall ui (#4139) * load log error adapt * fix: prompt toolcall ui * perf: commercial function tip * update package * pref: copy link (#4147) * fix(i18n): namespace (#4143) * hiden dataset source (#4152) * hiden dataset source * perf: reader * chore: move all tests into a single folder (#4160) * fix modal close scroll (#4162) * fix modal close scroll * update refresh * feat: rerank modal select and weight (#4164) * fix loadInitData refresh (#4169) * fix * fix * form input number default & api dataset max token * feat: mix search weight (#4170) * feat: mix search weight * feat: svg render * fix: avatar error remove (#4173) * fix: avatar error remove * fix: index * fix: guide * fix: auth * update package;fix: input data model ui (#4181) * update package * fix: ts * update config * update jieba package * add type sign * fix: input data ui * fix: page title refresh (#4186) * fix: ts * update jieba package * fix: page title refresh * fix: remove member length check when opening invite create modal (#4193) * add env to check internal ip (#4187) * fix: ts * update jieba package * add env to check internal ip * package * fix: jieba * reset package * update config * fix: jieba package * init shell * init version * change team reload * update jieba package (#4200) * update jieba package * package * update package * remove invalid code * action * package (#4201) * package * update package * remove invalid code * package * remove i18n tip (#4202) * doc (#4205) * fix: i18n (#4208) * fix: next config (#4207) * reset package * i18n * update config * i18n * remove log --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com> Co-authored-by: shilin <39396378+shilin66@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io>
132 lines
4.8 KiB
Markdown
132 lines
4.8 KiB
Markdown
---
|
||
title: '通过 OneAPI 接入模型'
|
||
description: '通过 OneAPI 接入模型'
|
||
icon: 'api'
|
||
draft: false
|
||
toc: true
|
||
weight: 745
|
||
---
|
||
|
||
FastGPT 目前采用模型分离的部署方案,FastGPT 中只兼容 OpenAI 的模型规范(OpenAI 不存在的模型采用一个较为通用的规范),并通过 [One API](https://github.com/songquanpeng/one-api) 来实现对不同模型接口的统一。
|
||
|
||
[One API](https://github.com/songquanpeng/one-api) 是一个 OpenAI 接口管理 & 分发系统,可以通过标准的 OpenAI API 格式访问所有的大模型,开箱即用。
|
||
|
||
|
||
## FastGPT 与 One API 关系
|
||
|
||
可以把 One API 当做一个网关,FastGPT 与 One API 关系:
|
||
|
||

|
||
|
||
## 部署
|
||
|
||
### Sealos 版本
|
||
|
||
* 北京区: [点击部署 OneAPI](https://hzh.sealos.run/?openapp=system-template%3FtemplateName%3Done-api)
|
||
* 新加坡区(可用 GPT) [点击部署 OneAPI](https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Done-api&uid=fnWRt09fZP)
|
||
|
||

|
||
|
||
部署完后,可以打开 OneAPI 访问链接,进行下一步操作。
|
||
|
||
## OneAPI 基础教程
|
||
|
||
### 概念
|
||
|
||
1. 渠道:
|
||
1. OneApi 中一个渠道对应一个 `Api Key`,这个 `Api Key` 可以是GPT、微软、ChatGLM、文心一言的。一个`Api Key`通常可以调用同一个厂商的多个模型。
|
||
2. One API 会根据请求传入的`模型`来决定使用哪一个`渠道`,如果一个模型对应了多个`渠道`,则会随机调用。
|
||
2. 令牌:访问 One API 所需的凭证,只需要这`1`个凭证即可访问`One API`上配置的模型。因此`FastGPT`中,只需要配置`One API`的`baseurl`和`令牌`即可。令牌不要设置任何的模型范围权限,否则容易报错。
|
||
|
||

|
||
|
||
### 大致工作流程
|
||
|
||
1. 客户端请求 One API
|
||
2. 根据请求中的 `model` 参数,匹配对应的渠道(根据渠道里的模型进行匹配,必须完全一致)。如果匹配到多个渠道,则随机选择一个(同优先级)。
|
||
3. One API 向真正的地址发出请求。
|
||
4. One API 将结果返回给客户端。
|
||
|
||
### 1. 登录 One API
|
||
|
||

|
||
|
||
### 2. 创建渠道
|
||
|
||
在 One API 中添加对应渠道,直接点击 【添加基础模型】,不要遗漏了向量模型(Embedding)
|
||
|
||

|
||
|
||
### 3. 创建令牌
|
||
|
||
| | |
|
||
| --- | --- |
|
||
|  |  |
|
||
|
||
### 4. 修改账号余额
|
||
|
||
One API 默认 root 用户只有 200刀,可以自行修改编辑。
|
||
|
||

|
||
|
||
### 5. 修改 FastGPT 的环境变量
|
||
|
||
有了 One API 令牌后,FastGPT 可以通过修改 `baseurl` 和 `key` 去请求到 One API,再由 One API 去请求不同的模型。修改下面两个环境变量:
|
||
|
||
```bash
|
||
# 务必写上 v1。如果在同一个网络内,可改成内网地址。
|
||
OPENAI_BASE_URL=https://xxxx.cloud.sealos.io/v1
|
||
# 下面的 key 是由 One API 提供的令牌
|
||
CHAT_API_KEY=sk-xxxxxx
|
||
```
|
||
|
||
## 接入其他模型
|
||
|
||
**以添加文心一言为例:**
|
||
|
||
### 1. OneAPI 新增模型渠道
|
||
|
||
类型选择百度文心千帆。
|
||
|
||

|
||
|
||
### 2. 修改 FastGPT 模型配置
|
||
|
||
打开 FastGPT 模型配置,启动文心千帆模型,如果希望未内置,可以通过新增模型来配置。
|
||
|
||

|
||
|
||
|
||
## 其他服务商接入参考
|
||
|
||
这章介绍一些提供商接入 OneAPI 的教程,配置后不要忘记在 FastGPT 模型配置中启用。
|
||
|
||
### 阿里通义千问
|
||
|
||
千问目前已经兼容 GPT 格式,可以直接选择 OpenAI 类型来接入即可。如下图,选择类型为`OpenAI`,代理填写阿里云的代理地址。
|
||
|
||
目前可以直接使用阿里云的语言模型和 `text-embedding-v3` 向量模型(实测已经归一化,可直接使用)
|
||
|
||

|
||
|
||
### 硅基流动 —— 开源模型大合集
|
||
|
||
[硅基流动](https://cloud.siliconflow.cn/i/TR9Ym0c4) 是一个专门提供开源模型调用平台,并拥有自己的加速引擎。模型覆盖面广,非常适合低成本来测试开源模型。接入教程:
|
||
|
||
1. [点击注册硅基流动账号](https://cloud.siliconflow.cn/i/TR9Ym0c4)
|
||
2. 进入控制台,获取 API key: https://cloud.siliconflow.cn/account/ak
|
||
3. 新增 OneAPI 渠道,选择`OpenAI`类型,代理填写:`https://api.siliconflow.cn`,密钥是第二步创建的密钥。
|
||
|
||

|
||
|
||
由于 OneAPI 未内置 硅基流动 的模型名,可以通过自定义模型名称来填入,下面是获取模型名称的教程:
|
||
|
||
1. 打开[硅基流动模型列表](https://siliconflow.cn/zh-cn/models)
|
||
2. 单击模型后,会打开模型详情。
|
||
3. 复制模型名到 OneAPI 中。
|
||
|
||
| | | |
|
||
| --- | --- | --- |
|
||
|  | |  |
|
||
|