Files
FastGPT/docSite/content/docs/development/one-api.md
Archer 9d27de154b 4.7-alpha2 (#1027)
* feat: stop toolCall and rename some field. (#46)

* perf: node delete tip;pay tip

* fix: toolCall cannot save child answer

* feat: stop tool

* fix: team modal

* fix feckbackMoal  auth bug (#47)

* 简单的支持提示词运行tool。优化workflow模板 (#49)

* remove templates

* fix: request body undefined

* feat: prompt tool run

* feat: workflow tamplates modal

* perf: plugin start

* 4.7 (#50)

* fix docker-compose download url (#994)

original code is a bad url with '404 NOT FOUND' return.
fix docker-compose download url, add 'v' before docker-compose version

* Update ai_settings.md (#1000)

* Update configuration.md

* Update configuration.md

* Fix history in classifyQuestion and extract modules (#1012)

* Fix history in classifyQuestion and extract modules

* Add chatValue2RuntimePrompt import and update text formatting

* flow controller to packages

* fix: rerank select

* modal ui

* perf: modal code path

* point not sufficient

* feat: http url support variable

* fix http key

* perf: prompt

* perf: ai setting modal

* simple edit ui

---------

Co-authored-by: entorick <entorick11@qq.com>
Co-authored-by: liujianglc <liujianglc@163.com>
Co-authored-by: Fengrui Liu <liufengrui.work@bytedance.com>

* fix team share redirect to login (#51)

* feat: support openapi import plugins (#48)

* feat: support openapi import plugins

* feat: import from url

* fix: add body params parse

* fix build

* fix

* fix

* fix

* tool box ui (#52)

* fix: training queue

* feat: simple edit tool select

* perf: simple edit dataset prompt

* fix: chatbox tool ux

* feat: quote prompt module

* perf: plugin tools sign

* perf: model avatar

* tool selector ui

* feat: max histories

* perf: http plugin import (#53)

* perf: plugin http import

* chatBox ui

* perf: name

* fix: Node template card (#54)

* fix: ts

* setting modal

* package

* package

* feat: add plugins search (#57)

* feat: add plugins search

* perf: change http plugin header input

* Yjl (#56)

* perf: prompt tool call

* perf: chat box ux

* doc

* doc

* price tip

* perf: tool selector

* ui'

* fix: vector queue

* fix: empty tool and empty response

* fix: empty msg

* perf: pg index

* perf: ui tip

* doc

* tool tip

---------

Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com>
Co-authored-by: entorick <entorick11@qq.com>
Co-authored-by: liujianglc <liujianglc@163.com>
Co-authored-by: Fengrui Liu <liufengrui.work@bytedance.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-03-21 13:32:31 +08:00

5.1 KiB
Raw Blame History

title, description, icon, draft, toc, weight
title description icon draft toc weight
接入微软、ChatGLM、本地模型等 部署和接入 OneAPI实现对各种大模型的支持 Api false true 708
  • 默认情况下FastGPT 只配置了 GPT 的模型,如果你需要接入其他模型,需要进行一些额外配置。
  • One API 是一个 OpenAI 接口管理 & 分发系统,可以通过标准的 OpenAI API 格式访问所有的大模型,开箱即用。
  • FastGPT 可以通过接入 OneAPI 来实现对不同大模型的支持。OneAPI 的部署方法也很简单。

FastGPT 与 OneAPI 关系

MySQL 版本

MySQL 版本支持多实例,高并发。

直接点击以下按钮即可一键部署 👇

Deploy on Sealos

部署完后会跳转「应用管理」,数据库在另一个应用「数据库」中。需要等待 1~3 分钟数据库运行后才能访问成功。

SqlLite 版本

SqlLite 版本不支持多实例,适合个人小流量使用,但是价格非常便宜。

1. 点击打开 Sealos 公有云

2. 打开 AppLaunchpad(应用管理) 工具

step1

3. 点击创建新应用

4. 填写对应参数

镜像ghcr.io/songquanpeng/one-api:latest

step2 打开外网访问开关后Sealos 会自动分配一个可访问的地址,不需要自己配置。

step3 填写完参数后,点击右上角部署即可。环境变量:

SESSION_SECRET=SESSION_SECRET
POLLING_INTERVAL=60
BATCH_UPDATE_ENABLED=true
BATCH_UPDATE_INTERVAL=60

One API使用教程

概念

  1. 渠道:
    1. OneApi 中一个渠道对应一个 Api Key,这个 Api Key 可以是GPT、微软、ChatGLM、文心一言的。一个Api Key通常可以调用同一个厂商的多个模型。
    2. OneAPI 会根据请求传入的模型来决定使用哪一个Key,如果一个模型对应了多个Key,则会随机调用。
  2. 令牌:访问 OneAPI 所需的凭证,只需要这1个凭证即可访问OneAPI上配置的模型。因此FastGPT中,只需要配置OneAPIbaseurl令牌即可。

1. 登录 One API

打开 【One API 应用详情】,找到访问地址: step4

登录 One API step5

2. 创建渠道和令牌

在 One API 中添加对应渠道,直接点击 【添加基础模型】,不要遗漏了向量模型 step6

创建一个令牌 step7

3. 修改账号余额

OneAPI 默认 root 用户只有 200刀可以自行修改编辑。

4. 修改 FastGPT 的环境变量

有了 One API 令牌后FastGPT 可以通过修改 baseurlkey 去请求到 One API再由 One API 去请求不同的模型。修改下面两个环境变量:

# 下面的地址是 Sealos 提供的,务必写上 v1 两个项目都在 sealos 部署时候https://xxxx.cloud.sealos.io 可以改用内网地址
OPENAI_BASE_URL=https://xxxx.cloud.sealos.io/v1
# 下面的 key 是由 One API 提供的令牌
CHAT_API_KEY=sk-xxxxxx

接入其他模型

以添加文心一言为例:

1. One API 添加对应模型渠道

2. 修改 FastGPT 配置文件

可以在 /projects/app/src/data/config.json 里找到配置文件(本地开发需要复制成 config.local.json配置文件中有一项是对话模型配置

"llmModels": [
    ...
    {
      "model": "ERNIE-Bot", // 这里的模型需要对应 One API 的模型
      "name": "文心一言", // 对外展示的名称
      "avatar": "/imgs/model/openai.svg", // 模型的logo
      "maxContext": 16000, // 最大上下文
      "maxResponse": 4000, // 最大回复
      "quoteMaxToken": 13000, // 最大引用内容
      "maxTemperature": 1.2, // 最大温度
      "charsPointsPrice": 0, 
      "censor": false,
      "vision": false, // 是否支持图片输入
      "datasetProcess": false, // 是否设置为知识库处理模型
      "usedInClassify": true, // 是否用于问题分类
      "usedInExtractFields": true, // 是否用于字段提取
      "usedInToolCall": true, // 是否用于工具调用
      "usedInQueryExtension": true, // 是否用于问题优化
      "toolChoice": true, // 是否支持工具选择
      "functionCall": false, // 是否支持函数调用
      "customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
      "customExtractPrompt": "", // 自定义内容提取提示词
      "defaultSystemChatPrompt": "", // 对话默认携带的系统提示词
      "defaultConfig":{}  // 对话默认配置(比如 GLM4 的 top_p
    }
    ...
],

3. 重启 FastGPT

docker-compose down
docker-compose up -d

重启 FastGPT 即可在选择文心一言模型进行对话。添加向量模型也是类似操作,增加到 vectorModels里。