Compare commits

...

14 Commits

Author SHA1 Message Date
Archer
af581bc903 Global variables support external variable; Extract module support default value (#921) 2024-03-05 14:13:22 +08:00
Archer
42a8184ea0 v4.6.9-alpha (#918)
Co-authored-by: Mufei <327958099@qq.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-03-04 00:05:25 +08:00
Mufei
f9f0b4bffd Update http468.ts (#903)
修复HTTP模块,http请求错误的stack堆栈信息长度冗余导致超过MongoDB数据库限制从而导致聊天对话插入数据库失败,修复方法为修改为如果http请求错误只返回几项重要信息而不是整个堆栈数据
2024-03-03 22:21:30 +08:00
Archer
064c64e74c V4.6.9-first commit (#899)
* perf: insert mongo dataset data session

* perf: dataset data index

* remove delay

* rename bill schema

* rename bill record

* perf: bill table

* perf: prompt

* perf: sub plan

* change the usage count

* feat: usage bill

* publish usages

* doc

* 新增团队聊天功能 (#20)

* perf: doc

* feat 添加标签部分

feat 信息团队标签配置

feat 新增团队同步管理

feat team分享页面

feat 完成team分享页面

feat 实现模糊搜索

style 格式化

fix 修复迷糊匹配

style 样式修改

fix 团队标签功能修复

* fix 修复鉴权功能

* merge 合并代码

* fix 修复引用错误

* fix 修复pr问题

* fix 修复ts格式问题

---------

Co-authored-by: archer <545436317@qq.com>
Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>

* update extra plan

* fix: ts

* format

* perf: bill field

* feat: standard plan

* fix: ts

* feat 个人账号页面修改 (#22)

* feat 添加标签部分

feat 信息团队标签配置

feat 新增团队同步管理

feat team分享页面

feat 完成team分享页面

feat 实现模糊搜索

style 格式化

fix 修复迷糊匹配

style 样式修改

fix 团队标签功能修复

* fix 修复鉴权功能

* merge 合并代码

* fix 修复引用错误

* fix 修复pr问题

* fix 修复ts格式问题

* feat 修改个人账号页

---------

Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>

* sub plan page (#23)

* fix chunk index; error page text

* feat: dataset process Integral prediction

* feat: stand plan field

* feat: sub plan limit

* perf: index

* query extension

* perf: share link push app name

* perf: plan point unit

* perf: get sub plan

* perf: account page

* feat 新增套餐详情弹窗代码 (#24)

* merge 合并代码

* fix 新增套餐详情弹框

* fix 修复pr问题

* feat: change http node input to prompt editor (#21)

* feat: change http node input to prompt editor

* fix

* split PromptEditor to HttpInput

* Team plans (#25)

* perf: pay check

* perf: team plan test

* plan limit check

* replace sensitive text

* perf: fix some null

* collection null check

* perf: plans modal

* perf: http module

* pacakge (#26)

* individuation page and pay modal amount (#27)

* feat: individuation page

* team chat config

* pay modal

* plan count and replace invalid chars (#29)

* fix: user oneapi

* fix: training queue

* fix: qa queue

* perf: remove space chars

* replace invalid chars

* change httpinput dropdown menu (#28)

* perf: http

* reseet free plan

* perf: plan code to packages

* remove llm config to package

* perf: code

* perf: faq

* fix: get team plan

---------

Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com>
Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-02-28 13:19:15 +08:00
Holata Seminole
32686f9e3e docs: fix typos (#898) 2024-02-27 18:53:17 +08:00
Archer
fd9b6291af Revert "sub plan page (#885)" (#886)
This reverts commit 443ad37b6a.
2024-02-23 17:48:15 +08:00
Archer
443ad37b6a sub plan page (#885)
* perf: insert mongo dataset data session

* perf: dataset data index

* remove delay

* rename bill schema

* rename bill record

* perf: bill table

* perf: prompt

* perf: sub plan

* change the usage count

* feat: usage bill

* publish usages

* doc

* 新增团队聊天功能 (#20)

* perf: doc

* feat 添加标签部分

feat 信息团队标签配置

feat 新增团队同步管理

feat team分享页面

feat 完成team分享页面

feat 实现模糊搜索

style 格式化

fix 修复迷糊匹配

style 样式修改

fix 团队标签功能修复

* fix 修复鉴权功能

* merge 合并代码

* fix 修复引用错误

* fix 修复pr问题

* fix 修复ts格式问题

---------

Co-authored-by: archer <545436317@qq.com>
Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>

* update extra plan

* fix: ts

* format

* perf: bill field

* feat: standard plan

* fix: ts

* feat 个人账号页面修改 (#22)

* feat 添加标签部分

feat 信息团队标签配置

feat 新增团队同步管理

feat team分享页面

feat 完成team分享页面

feat 实现模糊搜索

style 格式化

fix 修复迷糊匹配

style 样式修改

fix 团队标签功能修复

* fix 修复鉴权功能

* merge 合并代码

* fix 修复引用错误

* fix 修复pr问题

* fix 修复ts格式问题

* feat 修改个人账号页

---------

Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>

* fix chunk index; error page text

* feat: dataset process Integral prediction

* feat: stand plan field

* feat: sub plan limit

* perf: index

* query extension

* perf: share link push app name

* perf: plan point unit

* perf: get sub plan

* perf: account page

---------

Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com>
Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>
2024-02-23 17:47:34 +08:00
Kenith-Zhang
7a87f13aa8 docs:Update chatglm2.md and reranker.md the 'requirements' the word error (#866)
* Update chatglm2.md

docs:chatglm2.md the 'requirements' the word error

* docs reranker.md  the 'requirements' the word error
2024-02-22 09:48:45 +08:00
imgbot[bot]
d4aa19d8f2 [ImgBot] Optimize images (#859)
*Total -- 1,066.38kb -> 626.26kb (41.27%)

/docSite/assets/imgs/dataset_search_process.png -- 427.67kb -> 91.64kb (78.57%)
/docSite/assets/imgs/dataset_tree.png -- 100.17kb -> 24.38kb (75.66%)
/docSite/assets/imgs/http1.jpg -- 30.60kb -> 26.77kb (12.54%)
/docSite/static/android-chrome-256x256.png -- 5.57kb -> 4.93kb (11.41%)
/docSite/assets/imgs/sealos_price.jpg -- 148.36kb -> 135.89kb (8.41%)
/docSite/static/android-chrome-512x512.png -- 11.31kb -> 10.37kb (8.3%)
/docSite/static/android-chrome-192x192.png -- 4.11kb -> 3.77kb (8.15%)
/docSite/static/apple-touch-icon.png -- 3.87kb -> 3.55kb (8.08%)
/docSite/static/docs/mstile-150x150.png -- 3.01kb -> 2.77kb (8%)
/docSite/static/mstile-150x150.png -- 3.01kb -> 2.77kb (8%)
/docSite/assets/imgs/demo-appointment5.jpg -- 160.47kb -> 154.53kb (3.7%)
/docSite/assets/imgs/1.png -- 108.90kb -> 106.11kb (2.56%)
/docSite/static/favicon-32x32.png -- 1.01kb -> 0.99kb (2.13%)
/docSite/assets/imgs/2.png -- 32.49kb -> 31.97kb (1.6%)
/docSite/assets/imgs/versatile_assistant_5.png -- 25.81kb -> 25.80kb (0.06%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2024-02-18 20:07:44 +08:00
Archer
0c439c7827 perf: mongo doc (#855) 2024-02-17 10:57:39 +08:00
Archer
bf7ee919b6 Fix: pdf version (#853)
* doc

* perf: mongo index

* perf: chat item index

* fix: packages
2024-02-16 12:19:05 +08:00
Archer
91bcf8c53e 4.6.8 supplement (#831)
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-02-15 12:26:02 +08:00
Archer
51bbdf26a3 4.6.8-production (#822)
* Json completion (#16)

* json-completion

* fix duplicate

* fix

* fix: config json

* feat: query extension

* perf: i18n

* 468 doc

* json editor

* perf: doc

* perf: default extension model

* docker file

* doc

* perf: token count

* perf: search extension

* format

* perf: some constants data

---------

Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-02-05 00:51:46 +08:00
Robin Wang
ec8e2512bc change gpt-4-turbo maxResponse configuration template (#814)
用最新的配置文件4.6.8 ,对话选gpt-4-turbo 报错:
null max_tokens is too large: 62500. This model supports at most 4096 completion tokens, whereas you provided 62500. (request id: 20240202110253407344738SmDnkwX1)
原因是官方gpt-4-turbo 最大的返回token 4096.
2024-02-02 12:20:16 +08:00
552 changed files with 15912 additions and 10687 deletions

View File

@@ -1,19 +0,0 @@
name: 'Github Rebot for issues-translator'
on:
issues:
types: [ opened ]
issue_comment:
types: [ created ]
jobs:
translate:
permissions:
issues: write
discussions: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: usthe/issues-translate-action@v2.7
with:
IS_MODIFY_TITLE: true
BOT_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

View File

@@ -1,4 +1,4 @@
name: Build FastGPT docs images and copy image to docker hub
name: Build docs images and copy image to docker hub
on:
workflow_dispatch:
push:
@@ -95,4 +95,4 @@ jobs:
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: rollout restart deployment fastgpt-docs
args: rollout restart deployment fastgpt-docs

View File

@@ -1,4 +1,4 @@
name: deploy-docs-preview
name: preview-docs
on:
pull_request_target:
@@ -74,7 +74,7 @@ jobs:
alias-domains: | #Optional
fastgpt-staging.vercel.app
docsOutput:
needs: [ deploy-preview ]
needs: [deploy-preview]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@@ -92,7 +92,7 @@ jobs:
with:
version: v0.0.6
env:
GH_TOKEN: "${{ secrets.GH_PAT }}"
SEALOS_TYPE: "pr_comment"
SEALOS_FILENAME: "report.md"
SEALOS_REPLACE_TAG: "DEFAULT_REPLACE_DEPLOY"
GH_TOKEN: '${{ secrets.GH_PAT }}'
SEALOS_TYPE: 'pr_comment'
SEALOS_FILENAME: 'report.md'
SEALOS_REPLACE_TAG: 'DEFAULT_REPLACE_DEPLOY'

View File

@@ -2,7 +2,7 @@
"editor.formatOnSave": true,
"editor.mouseWheelZoom": true,
"typescript.tsdk": "node_modules/typescript/lib",
"prettier.prettierPath": "./node_modules/prettier",
"prettier.prettierPath": "",
"i18n-ally.localesPaths": [
"projects/app/public/locales",
],
@@ -11,5 +11,5 @@
"i18n-ally.sortKeys": true,
"i18n-ally.keepFulfilled": true,
"i18n-ally.sourceLanguage": "zh", // 根据此语言文件翻译其他语言文件的变量和内容
"i18n-ally.displayLanguage": "en", // 显示语言
"i18n-ally.displayLanguage": "zh", // 显示语言
}

View File

@@ -8,7 +8,7 @@ ARG proxy
RUN [ -z "$proxy" ] || sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache libc6-compat && npm install -g pnpm@8.6.0
# if proxy exists, set proxy
RUN [ -z "$proxy" ] || pnpm config set registry https://registry.npm.taobao.org
RUN [ -z "$proxy" ] || pnpm config set registry https://registry.npmmirror.com
# copy packages and one project
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
@@ -28,7 +28,7 @@ ARG proxy
RUN [ -z "$proxy" ] || sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache libc6-compat && npm install -g pnpm@8.6.0
# if proxy exists, set proxy
RUN [ -z "$proxy" ] || pnpm config set registry https://registry.npm.taobao.org
RUN [ -z "$proxy" ] || pnpm config set registry https://registry.npmmirror.com
COPY ./worker /app/worker
RUN cd /app/worker && pnpm i --production --ignore-workspace

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 KiB

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 KiB

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 KiB

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -1,38 +0,0 @@
---
title: '免责声明'
description: ' FastGPT 免责声明'
icon: 'gavel'
draft: false
toc: true
weight: 1220
---
由于生成式 AI 的特性,其在不同国家的管控措施也会有所不同。请所有使用者务必遵守所在地的相关法律。
免责声明:以任何违反 FastGPT 可接受使用政策的方式使用,包括但不限于法律、法规、政府命令或法令禁止的任何用途,或任何侵犯他人权利的使用;由使用者自行承担。我们对由客户使用产生的问题概不负责。
下面是各国对生成式AI的管控条例的链接
[中国生成式人工智能服务管理办法(征求意见稿)](http://www.cac.gov.cn/2023-04/11/c_1682854275475410.htm)
## 内容要求
我们禁止使用我们对接的模型服务生成可能对个人或社会造成伤害的内容。保障平台的安全性,是长期稳定运营的关键。如发现任何利用平台接入模型能力进行违规内容生成和使用,将立即封号,账号余额不退。
- 剥削和虐待
- 禁止描述、展示或宣扬儿童性剥削或性虐待的内容,无论法律是否禁止。这包括涉及儿童或使儿童色情的内容。
- 禁止描述或用于培养儿童的内容。修饰是成年人以剥削,特别是性剥削为目的与儿童建立关系的行为。这包括以性剥削、贩运或其他形式剥削为目的与儿童交流。
- 未经同意的私密内容
- 服务禁止描述、提供或宣传未经同意的亲密活动的内容。
- 禁止描述、提供特征或宣传或用于招揽商业性活动和性服务的内容。这包括鼓励和协调真正的性活动。
- 禁止描述或用于人口贩运目的的内容。这包括招募人员、便利交通、支付和助长对人的剥削,如强迫劳动、家庭奴役、役、强迫婚姻和强迫医疗程序。
- 自杀和自残,禁止描述、赞美、支持、促进、美化、鼓励和/或指导个人自残或自杀的内容。
- 暴力内容和行为
- 禁止描述、展示或宣扬血腥暴力或血腥的内容。
- 禁止描绘恐怖主义行为的内容;赞扬或支持恐怖组织、恐怖行为者或暴力恐怖意识形态;鼓励恐怖活动;向恐怖组织或恐怖事业提供援助;或协助恐怖组织招募成员。
- 禁止通过暴力威胁或煽动来鼓吹或宣扬对他人的暴力行为的内容。
- 仇恨言论和歧视
- 禁止基于实际或感知的种族、民族、国籍、性别、性别认同、性取向、宗教信仰、年龄、残疾状况、种姓或与系统性偏见或边缘化相关的任何其他特征等特征攻击、诋毁、恐吓、降级、针对或排斥个人或群体的内容。
- 禁止针对个人或群体进行威胁、恐吓、侮辱、贬低或贬低的语言或图像、宣扬身体伤害或其他虐待行为(如跟踪)的内容。
- 禁止故意欺骗并可能对公共利益产生不利影响的内容,包括与健康、安全、选举诚信或公民参与相关的欺骗性或不真实内容。
- 直接支持非法主动攻击或造成技术危害的恶意软件活动的内容,例如提供恶意可执行文件、组织拒绝服务攻击或管理命令和控制服务器。

View File

@@ -11,7 +11,7 @@ FastGPT 项目在 Apache License 2.0 许可下开源,同时包含以下附加
+ FastGPT 允许被用于商业化,例如作为其他应用的“后端即服务”使用,或者作为应用开发平台提供给企业。然而,当满足以下条件时,必须联系作者获得商业许可:
+ 多租户 SaaS 服务:除非获得 FastGPT 的明确书面授权,否则不得使用 fastgpt.in 的源码来运营与 fastgpt.in 服务类似的多租户 SaaS 服务。
+ 多租户 SaaS 服务:除非获得 FastGPT 的明确书面授权,否则不得使用 fastgpt.in 的源码来运营与 fastgpt.in 服务类似的多租户 SaaS 服务。
+ LOGO 及版权信息:在使用 FastGPT 的过程中,不得移除或修改 FastGPT 控制台内的 LOGO 或版权信息。
请通过电子邮件 yujinlong@sealos.io 联系我们咨询许可事宜。

View File

@@ -0,0 +1,66 @@
---
title: '隐私政策'
description: ' FastGPT 隐私政策'
icon: 'gavel'
draft: false
toc: true
weight: 1221
---
最后更新时间2024年3月3日
我们非常重视您的隐私保护在您使用FastGPT云服务时(以下简称为“本服务”),我们将按照以下政策收集、使用、披露和保护您的个人信息。请您仔细阅读并充分理解本隐私政策。
**我们可能需要收集的信息**
1. 在您注册或使用本服务时,我们可能收集您的姓名、电话号码、电子邮件地址、地址等个人信息。
2. 在您使用本服务过程中产生的信息如操作日志、访问IP地址、设备型号等。
3. 我们可能会通过 Cookies 或其他技术收集和存储您访问本服务的相关信息,以便为您提供更好的用户体验。
**我们如何使用收集的信息?**
1. 我们会根据法律法规规定以及与用户之间的约定来处理用户的个人信息。
2. 我们可能会将收集到的信息用于改进服务质量、开发新产品或功能等目的。
3. 我们可能会将收集到的信息用于向您推送与本服务相关的通知或广告。
**信息披露**
1. 我们不会向任何第三方披露您的个人信息,除非:
1. 您事先同意;
2. 法律法规要求;
3. 为维护我们或其他用户的合法权益。
2. 我们可能与关联公司、合作伙伴分享您的个人信息,但我们会采取相应的保密措施,确保信息安全。
**信息保护**
1. 我们采取各种安全措施,包括加密、访问控制等技术手段,以保护您的个人信息免受未经授权的访问、使用或泄露。
2. 我们会定期对收集、存储和处理的个人信息进行安全评估,以确保个人信息安全。
3. 在发生个人信息泄露等安全事件时,我们会立即启动应急预案,并在法律法规规定的范围内向您及时告知。
4. 我们不会使用您的数据进行额外的备份存储或用于模型训练。
5. 您在本服务进行的数据删除均为物理删除,不可恢复。如有非物理删除的操作,我们会在服务中特别指出。
**用户权利**
1. 您有权随时查阅、更正或删除您的个人信息。
2. 您有权拒绝我们收集您的个人信息,但这可能导致您无法使用本服务的部分功能。
3. 您有权要求我们停止处理您的个人信息,但这可能导致您无法继续使用本服务。
**隐私政策更新**
1. 我们可能会对本隐私政策进行修改。如本隐私政策发生变更,我们将在本服务页面上发布修改后的隐私政策。如您继续使用本服务,则视为同意修改后的隐私政策。
2. 我们鼓励您定期查阅本隐私政策,以了解我们如何保护您的个人信息。
**未成年人保护**
我们非常重视对未成年人个人信息的保护,如您为未成年人,请在监护人指导下使用本服务,并请监护人帮助您在使用本服务过程中正确处理个人信息。
**跨境数据传输**
由于我们的服务器可能位于不同国家或地区,您同意我们可能需要将您的个人信息传输至其他国家或地区,并在该等国家或地区存储和处理以向您提供服务。我们会采取适当措施确保跨境传输的数据仍然受到适当保护。
**联系我们**
1. 如您对本隐私政策有任何疑问、建议或投诉请通过以下方式与我们联系yujinlong@sealos.io。
2. 我们将尽快回复并解决您提出的问题。

View File

@@ -0,0 +1,75 @@
---
title: '服务协议'
description: ' FastGPT 服务协议'
icon: 'gavel'
draft: false
toc: true
weight: 1220
---
最后更新时间2024年3月3日
FastGPT 服务协议是您与珠海环界云计算有限公司以下简称“我们”或“本公司”之间就FastGPT云服务以下简称“本服务”的使用等相关事项所订立的协议。请您仔细阅读并充分理解本协议各条款特别是免除或者限制我们责任的条款、对您权益的限制条款、争议解决和法律适用条款等。如您不同意本协议任一内容请勿注册或使用本服务。
**第1条 服务内容**
1. 我们将向您提供存储、计算、网络传输等基于互联网的信息技术服务。
2. 我们将不定期向您通过站内信、电子邮件或短信等形式向您推送最新的动态。
3. 我们将为您提供相关技术支持和客户服务,帮助您更好地使用本服务。
4. 我们将为您提供稳定的在线服务保证每月服务可用性不低于99%。
**第2条 用户注册与账户管理**
1. 您在使用本服务前需要注册一个账户。您保证在注册时提供的信息真实、准确、完整,并及时更新。
2. 您应妥善保管账户名和密码,对由此产生的全部行为负责。如发现他人使用您的账户,请及时修改账号密码或与我们进行联系。
3. 我们有权对您的账户进行审查,如发现您的账户存在异常或违法情况,我们有权暂停或终止向您提供服务。
**第3条 使用规则**
1. 您不得利用本服务从事任何违法活动或侵犯他人合法权益的行为,包括但不限于侵犯知识产权、泄露他人商业机密等。
2. 您不得通过任何手段恶意注册账户,包括但不限于以牟利、炒作、套现等目的。
3. 您不得利用本服务传播任何违法、有害、恶意软件等信息。
4. 您应遵守相关法律法规及本协议的规定,对在本服务中发布的信息及使用本服务所产生的结果承担全部责任。
5. 我们禁止使用我们对接的模型服务生成可能对个人或社会造成伤害的内容。保障平台的安全性,是长期稳定运营的关键。如发现任何利用平台接入模型能力进行违规内容生成和使用,将立即封号,账号余额不退。违规内容包括但不限于:
- 剥削和虐待
- 禁止描述、展示或宣扬儿童性剥削或性虐待的内容,无论法律是否禁止。这包括涉及儿童或使儿童色情的内容。
- 禁止描述或用于培养儿童的内容。修饰是成年人以剥削,特别是性剥削为目的与儿童建立关系的行为。这包括以性剥削、贩运或其他形式剥削为目的与儿童交流。
- 未经同意的私密内容
- 服务禁止描述、提供或宣传未经同意的亲密活动的内容。
- 禁止描述、提供特征或宣传或用于招揽商业性活动和性服务的内容。这包括鼓励和协调真正的性活动。
- 禁止描述或用于人口贩运目的的内容。这包括招募人员、便利交通、支付和助长对人的剥削,如强迫劳动、家庭奴役、役、强迫婚姻和强迫医疗程序。
- 自杀和自残,禁止描述、赞美、支持、促进、美化、鼓励和/或指导个人自残或自杀的内容。
- 暴力内容和行为
- 禁止描述、展示或宣扬血腥暴力或血腥的内容。
- 禁止描绘恐怖主义行为的内容;赞扬或支持恐怖组织、恐怖行为者或暴力恐怖意识形态;鼓励恐怖活动;向恐怖组织或恐怖事业提供援助;或协助恐怖组织招募成员。
- 禁止通过暴力威胁或煽动来鼓吹或宣扬对他人的暴力行为的内容。
- 仇恨言论和歧视
- 禁止基于实际或感知的种族、民族、国籍、性别、性别认同、性取向、宗教信仰、年龄、残疾状况、种姓或与系统性偏见或边缘化相关的任何其他特征等特征攻击、诋毁、恐吓、降级、针对或排斥个人或群体的内容。
- 禁止针对个人或群体进行威胁、恐吓、侮辱、贬低或贬低的语言或图像、宣扬身体伤害或其他虐待行为(如跟踪)的内容。
- 禁止故意欺骗并可能对公共利益产生不利影响的内容,包括与健康、安全、选举诚信或公民参与相关的欺骗性或不真实内容。
- 直接支持非法主动攻击或造成技术危害的恶意软件活动的内容,例如提供恶意可执行文件、组织拒绝服务攻击或管理命令和控制服务器。
**第4条 费用及支付**
1. 您同意支付与本服务相关的费用,具体费用标准以我们公布的价格为准。
2. 我们可能会根据运营成本和市场情况调整费用标准。最新价格以您付款时刻的价格为准。
**第5条 服务免责与责任限制**
1. 本服务按照现有技术和条件所能达到的水平提供。我们不能保证本服务完全无故障或满足您的所有需求。
2. 对于因您自身误操作导致的数据丢失、损坏等情况,我们不承担责任。
3. 由于生成式 AI 的特性,其在不同国家的管控措施也会有所不同,请所有使用者务必遵守所在地的相关法律。如果您以任何违反 FastGPT 可接受使用政策的方式使用包括但不限于法律、法规、政府命令或法令禁止的任何用途或任何侵犯他人权利的使用由使用者自行承担。我们对由客户使用产生的问题概不负责。下面是各国对生成式AI的管控条例的链接
[中国生成式人工智能服务管理办法(征求意见稿)](http://www.cac.gov.cn/2023-04/11/c_1682854275475410.htm)
**第6条 知识产权**
1. 我们对本服务及相关软件、技术、文档等拥有全部知识产权,除非经我们明确许可,您不得进行复制、分发、出租、反向工程等行为。
2. 您在使用本服务过程中产生的所有数据和内容(包括但不限于文件、图片等)的知识产权归您所有。我们不会对您的数据和内容进行使用、复制、修改等行为。
3. 在线服务中其他用户的数据和内容的知识产权归原用户所有,未经原用户许可,您不得进行使用、复制、修改等行为。
**第7条 其他条款**
1. 如本协议中部分条款因违反法律法规而被视为无效,不影响其他条款的效力。
2. 本公司保留对本协议及隐私政策的最终解释权。如您对本协议或隐私政策有任何疑问请联系我们yujinlong@sealos.io。

View File

@@ -1,19 +1,77 @@
---
title: '知识库搜索参数'
description: '知识库搜索原理'
title: '知识库搜索介绍'
description: '本节会详细介绍 FastGPT 知识库结构设计,理解其 QA 的存储格式和多向量映射,以便更好的构建知识库。同时会介绍每个搜索参数的功能。这篇介绍主要以使用为主,详细原理不多介绍。'
icon: 'language'
draft: false
toc: true
weight: 106
---
在知识库搜索的方式上FastGPT提供了三种方式分别为“语义检索”“增强语义检索”“混合检索”。
## 理解向量
![](/imgs/dataset_search_params1.png)
FastGPT 采用了 RAG 中的 Embedding 方案构建知识库,要使用好 FastGPT 需要简单的理解`Embedding`向量是如何工作的及其特点。
## 搜索模式
人类的文字、图片、视频等媒介是无法直接被计算机理解的,要想让计算机理解两段文字是否有相似性、相关性,通常需要将它们转成计算机可以理解的语言,向量是其中的一种方式。
### 语义检索
向量可以简单理解为一个数字数组,两个向量之间可以通过数学公式得出一个`距离`,距离越小代表两个向量的相似度越大。从而映射到文字、图片、视频等媒介上,可以用来判断两个媒介之间的相似度。向量搜索便是利用了这个原理。
而由于文字是有多种类型,并且拥有成千上万种组合方式,因此在转成向量进行相似度匹配时,很难保障其精确性。在向量方案构建的知识库中,通常使用`topk`召回的方式,也就是查找前`k`个最相似的内容,丢给大模型去做更进一步的`语义判断``逻辑推理``归纳总结`,从而实现知识库问答。因此,在知识库问答中,向量搜索的环节是最为重要的。
影响向量搜索精度的因素非常多,主要包括:向量模型的质量、数据的质量(长度,完整性,多样性)、检索器的精度(速度与精度之间的取舍)。与数据质量对应的就是检索词的质量。
检索器的精度比较容易解决,向量模型的训练略复杂,因此数据和检索词质量优化成了一个重要的环节。
### 提高向量搜索精度的方法
1. 更好分词分段:当一段话的结构和语义是完整的,并且是单一的,精度也会提高。因此,许多系统都会优化分词器,尽可能的保障每组数据的完整性。
2. 精简`index`的内容,减少向量内容的长度:当`index`的内容更少,更准确时,检索精度自然会提高。但与此同时,会牺牲一定的检索范围,适合答案较为严格的场景。
3. 丰富`index`的数量,可以为同一个`chunk`内容增加多组`index`
4. 优化检索词:在实际使用过程中,用户的问题通常是模糊的或是缺失的,并不一定是完整清晰的问题。因此优化用户的问题(检索词)很大程度上也可以提高精度。
5. 微调向量模型:由于市面上直接使用的向量模型都是通用型模型,在特定领域的检索精度并不高,因此微调向量模型可以很大程度上提高专业领域的检索效果。
## FastGPT 构建知识库方案
### 数据存储结构
在 FastGPT 中,整个知识库由库、集合和数据 3 部分组成。集合可以简单理解为一个`文件`。一个`库`中可以包含多个`集合`,一个`集合`中可以包含多组`数据`。最小的搜索单位是`库`,也就是说,知识库搜索时,是对整个`库`进行搜索,而集合仅是为了对数据进行分类管理,与搜索效果无关。(起码目前还是)
![](/imgs/dataset_tree.png)
### 向量存储结构
FastGPT 采用了`PostgresSQL``PG Vector`插件作为向量检索器,索引为`HNSW`。且`PostgresSQL`仅用于向量检索(该引擎可以替换成其它数据库),`MongoDB`用于其他数据的存取。
`MongoDB``dataset.datas`表中,会存储向量原数据的信息,同时有一个`indexes`字段会记录其对应的向量ID这是一个数组也就是说一组向量可以对应多组数据。
`PostgresSQL`的表中,设置一个`vector`字段用于存储向量。在检索时会先召回向量再根据向量的ID`MongoDB`中寻找原数据内容,如果对应了同一组原数据,则进行合并,向量得分取最高得分。
![](/imgs/datasetSetting1.png)
### 多向量的目的和使用方式
在一组向量中内容的长度和语义的丰富度通常是矛盾的无法兼得。因此FastGPT 采用了多向量映射的方式,将一组数据映射到多组向量中,从而保障数据的完整性和语义的丰富度。
你可以为一组较长的文本,添加多组向量,从而在检索时,只要其中一组向量被检索到,该数据也将被召回。
### 检索方案
1. 通过`问题优化`实现指代消除和问题扩展,从而增加连续对话的检索能力以及语义丰富度。
2. 通过`Concat query`来增加`Rerank`连续对话的时,排序的准确性。
3. 通过`RRF`合并方式,综合多个渠道的检索效果。
4. 通过`Rerank`来二次排序,提高精度。
![](/imgs/dataset_search_process.png)
## 搜索参数
| | | |
| --- |---| --- |
|![](/imgs/dataset_search_params1.png)| ![](/imgs/dataset_search_params2.png) | ![](/imgs/dataset_search_params3.png) |
### 搜索模式
#### 语义检索
语义检索是通过向量距离,计算用户问题与知识库内容的距离,从而得出“相似度”,当然这并不是语文上的相似度,而是数学上的。
@@ -27,32 +85,50 @@ weight: 106
- 精度不稳定
- 受关键词和句子完整度影响
### 全文检索
#### 全文检索
采用传统的全文检索方式。适合查找关键的主谓语等。
### 混合检索
#### 混合检索
同时使用向量检索和全文检索,并通过 RRF 公式进行两个搜索结果合并,一般情况下搜索结果会更加丰富准确。
由于混合检索后的查找范围很大,并且无法直接进行相似度过滤,通常需要进行利用重排模型进行一次结果重新排序,并利用重排的得分进行过滤。
#### 结果重排
## 结果重排
利用`ReRank`模型对搜索结果进行重排,绝大多数情况下,可以有效提高搜索结果的准确率。不过,重排模型与问题的完整度(主谓语齐全)有一些关系,通常会先走问题补全后再进行搜索-重排。重排后可以得到一个`0-1`的得分,代表着搜索内容与问题的相关度,该分数通常比向量的得分更加精确,可以根据得分进行过滤。
利用`ReRank`模型对搜索结果进行重排,绝大多数情况下,可以有效提高搜索结果的准确率。不过,重排模型与问题的完整度(主谓语齐全)有一些关系,通常会先走问题优化后再进行搜索-重排。重排后可以得到一个`0-1`的得分,代表着搜索内容与问题的相关度,该分数通常比向量的得分更加精确,可以根据得分进行过滤。
FastGPT 会使用 `RRF` 对重排结果、向量搜索结果、全文检索结果进行合并,得到最终的搜索结果。
## 引用上限
### 搜索过滤
#### 引用上限
每次搜索最多引用`n``tokens`的内容。
之所以不采用`top k`,是发现在混合知识库(问答库、文档库)时,不同`chunk`的长度差距很大,会导致`top k`的结果不稳定,因此采用了`tokens`的方式进行引用上限的控制。
## 最低相关度
#### 最低相关度
一个`0-1`的数值,会过滤掉一些低相关度的搜索结果。
该值仅在`语义检索`或使用`结果重排`时生效。
### 问题优化
#### 背景
在 RAG 中,我们需要根据输入的问题去数据库里执行 embedding 搜索,查找相关的内容,从而查找到相似的内容(简称知识库搜索)。
在搜索的过程中,尤其是连续对话的搜索,我们通常会发现后续的问题难以搜索到合适的内容,其中一个原因是知识库搜索只会使用“当前”的问题去执行。看下面的例子:
![](/imgs/coreferenceResolution2.jpg)
用户在提问“第二点是什么”的时候只会去知识库里查找“第二点是什么”压根查不到内容。实际上需要查询的是“QA结构是什么”。因此我们需要引入一个【问题优化】模块来对用户当前的问题进行补全从而使得知识库搜索能够搜索到合适的内容。使用补全后效果如下
![](/imgs/coreferenceResolution3.jpg)
#### 实现方式
在进行`数据检索`前,会先让模型进行`指代消除``问题扩展`,一方面可以可以解决指代对象不明确问题,同时可以扩展问题的语义丰富度。

View File

@@ -13,163 +13,7 @@ weight: 708
这个配置文件中包含了系统级参数、AI 对话的模型、function 模型等……
## 4.6.8 以前版本完整配置参数
**使用时,请务必去除注释!**
以下配置适用于V4.6.6-alpha版本以后
```json
{
"systemEnv": {
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
"pgHNSWEfSearch": 100 // pg vector 索引参数,越大精度高但速度慢
},
"chatModels": [ // 对话模型
{
"model": "gpt-3.5-turbo-1106",
"name": "GPT35-1106",
"inputPrice": 0, // 输入价格。 xx元/1k tokens
"outputPrice": 0, // 输出价格。 xx元/1k tokens
"maxContext": 16000, // 最大上下文长度
"maxResponse": 4000, // 最大回复长度
"quoteMaxToken": 2000, // 最大引用内容长度
"maxTemperature": 1.2, // 最大温度值
"censor": false, // 是否开启敏感词过滤(商业版)
"vision": false, // 支持图片输入
"defaultSystemChatPrompt": ""
},
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxContext": 16000,
"maxResponse": 16000,
"inputPrice": 0,
"outputPrice": 0,
"quoteMaxToken": 8000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
},
{
"model": "gpt-4",
"name": "GPT4-8k",
"maxContext": 8000,
"maxResponse": 8000,
"inputPrice": 0,
"outputPrice": 0,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
},
{
"model": "gpt-4-vision-preview",
"name": "GPT4-Vision",
"maxContext": 128000,
"maxResponse": 4000,
"inputPrice": 0,
"outputPrice": 0,
"quoteMaxToken": 100000,
"maxTemperature": 1.2,
"censor": false,
"vision": true,
"defaultSystemChatPrompt": ""
}
],
"qaModels": [ // QA 生成模型
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxContext": 16000,
"maxResponse": 16000,
"inputPrice": 0,
"outputPrice": 0
}
],
"cqModels": [ // 问题分类模型
{
"model": "gpt-3.5-turbo-1106",
"name": "GPT35-1106",
"maxContext": 16000,
"maxResponse": 4000,
"inputPrice": 0,
"outputPrice": 0,
"toolChoice": true, // 是否支持openai的 toolChoice 不支持的模型需要设置为 false会走提示词生成
"functionPrompt": ""
},
{
"model": "gpt-4",
"name": "GPT4-8k",
"maxContext": 8000,
"maxResponse": 8000,
"inputPrice": 0,
"outputPrice": 0,
"toolChoice": true,
"functionPrompt": ""
}
],
"extractModels": [ // 内容提取模型
{
"model": "gpt-3.5-turbo-1106",
"name": "GPT35-1106",
"maxContext": 16000,
"maxResponse": 4000,
"inputPrice": 0,
"outputPrice": 0,
"toolChoice": true,
"functionPrompt": ""
}
],
"qgModels": [ // 生成下一步指引
{
"model": "gpt-3.5-turbo-1106",
"name": "GPT35-1106",
"maxContext": 1600,
"maxResponse": 4000,
"inputPrice": 0,
"outputPrice": 0
}
],
"vectorModels": [ // 向量模型
{
"model": "text-embedding-ada-002",
"name": "Embedding-2",
"inputPrice": 0,
"defaultToken": 700,
"maxToken": 3000
}
],
"reRankModels": [], // 重排模型,暂时填空数组
"audioSpeechModels": [
{
"model": "tts-1",
"name": "OpenAI TTS1",
"inputPrice": 0,
"baseUrl": "",
"key": "",
"voices": [
{ "label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy" },
{ "label": "Echo", "value": "echo", "bufferId": "openai-Echo" },
{ "label": "Fable", "value": "fable", "bufferId": "openai-Fable" },
{ "label": "Onyx", "value": "onyx", "bufferId": "openai-Onyx" },
{ "label": "Nova", "value": "nova", "bufferId": "openai-Nova" },
{ "label": "Shimmer", "value": "shimmer", "bufferId": "openai-Shimmer" }
]
}
],
"whisperModel": {
"model": "whisper-1",
"name": "Whisper1",
"inputPrice": 0
}
}
```
## 4.6.8 新配置文件
## 4.6.8+ 版本新配置文件
llm模型全部合并
@@ -189,11 +33,10 @@ llm模型全部合并
"maxResponse": 4000, // 最大回复
"quoteMaxToken": 13000, // 最大引用内容
"maxTemperature": 1.2, // 最大温度
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"censor": false,
"vision": false, // 是否支持图片输入
"datasetProcess": false, // 是否设置为知识库处理模型
"datasetProcess": false, // 是否设置为知识库处理模型QA务必保证至少有一个为true否则知识库会报错
"toolChoice": true, // 是否支持工具选择
"functionCall": false, // 是否支持函数调用
"customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
@@ -208,8 +51,7 @@ llm模型全部合并
"maxResponse": 16000,
"quoteMaxToken": 13000,
"maxTemperature": 1.2,
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"censor": false,
"vision": false,
"datasetProcess": true,
@@ -224,11 +66,10 @@ llm模型全部合并
"model": "gpt-4-0125-preview",
"name": "gpt-4-turbo",
"maxContext": 125000,
"maxResponse": 125000,
"maxResponse": 4000,
"quoteMaxToken": 100000,
"maxTemperature": 1.2,
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"censor": false,
"vision": false,
"datasetProcess": false,
@@ -246,10 +87,9 @@ llm模型全部合并
"maxResponse": 4000,
"quoteMaxToken": 100000,
"maxTemperature": 1.2,
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"censor": false,
"vision": false,
"vision": true,
"datasetProcess": false,
"toolChoice": true,
"functionCall": false,
@@ -263,8 +103,7 @@ llm模型全部合并
{
"model": "text-embedding-ada-002",
"name": "Embedding-2",
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"defaultToken": 700,
"maxToken": 3000,
"weight": 100,
@@ -276,8 +115,7 @@ llm模型全部合并
{
"model": "tts-1",
"name": "OpenAI TTS1",
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"voices": [
{ "label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy" },
{ "label": "Echo", "value": "echo", "bufferId": "openai-Echo" },
@@ -291,8 +129,7 @@ llm模型全部合并
"whisperModel": {
"model": "whisper-1",
"name": "Whisper1",
"inputPrice": 0,
"outputPrice": 0
"charsPointsPrice": 0
}
}
```
@@ -313,7 +150,7 @@ llm模型全部合并
{
"model": "bge-reranker-base", // 随意
"name": "检索重排-base", // 随意
"inputPrice": 0,
"charsPointsPrice": 0,
"requestUrl": "{{host}}/api/v1/rerank",
"requestAuth": "安全凭证,已自动补 Bearer"
}

View File

@@ -47,7 +47,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,
1. 根据上面的环境配置配置好环境,具体教程自行 GPT
2. 下载 [python 文件](https://github.com/labring/FastGPT/blob/main/files/models/ChatGLM2/openai_api.py)
3. 在命令行输入命令 `pip install -r requirments.txt`
3. 在命令行输入命令 `pip install -r requirements.txt`
4. 打开你需要启动的 py 文件,在代码的 `verify_token` 方法中配置 token这里的 token 只是加一层验证,防止接口被人盗用;
5. 执行命令 `python openai_api.py --model_name 16`。这里的数字根据上面的配置进行选择。

View File

@@ -48,10 +48,10 @@ Authorization 为 sk-key。model 为刚刚在 One API 填写的自定义模型
## 接入 FastGPT
修改 config.json 配置文件,在 VectorModels 中加入 M3E 模型:
修改 config.json 配置文件,在 vectorModels 中加入 M3E 模型:
```json
"VectorModels": [
"vectorModels": [
{
"model": "text-embedding-ada-002",
"name": "Embedding-2",

View File

@@ -29,7 +29,7 @@ weight: 910
1. 根据上面的环境配置配置好环境,具体教程自行 GPT
2. 下载 [python 文件](https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-base)
3. 在命令行输入命令 `pip install -r requirments.txt`
3. 在命令行输入命令 `pip install -r requirements.txt`
4. 按照[https://huggingface.co/BAAI/bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base)下载模型仓库到app.py同级目录
5. 添加环境变量 `export ACCESS_TOKEN=XXXXXX` 配置 token这里的 token 只是加一层验证,防止接口被人盗用,默认值为 `ACCESS_TOKEN`
6. 执行命令 `python app.py`
@@ -61,4 +61,4 @@ docker run -d --name reranker -p 6006:6006 -e ACCESS_TOKEN=mytoken luanshaotong/
## 接入 FastGPT
参考 [ReRank模型接入](/docs/development/configuration/#rerank-接入)host 变量为部署的域名。
参考 [ReRank模型接入](/docs/development/configuration/#rerank-接入)host 变量为部署的域名。

View File

@@ -103,13 +103,22 @@ curl -O https://raw.githubusercontent.com/labring/FastGPT/main/projects/app/data
## 四、启动容器
在 docker-compose.yml 同级目录下执行
```bash
# 在 docker-compose.yml 同级目录下执行
# 进入项目目录
cd 项目目录
# 创建 mongo 密钥
openssl rand -base64 756 > ./mongodb.key
# 600不行可以用chmod 999
chmod 600 ./mongodb.key
chown 999:root ./mongodb.key
# 启动容器
docker-compose pull
docker-compose up -d
```
## 、初始化 Mongo 副本集(4.6.8以前可忽略)
## 、初始化 Mongo 副本集(4.6.8以前可忽略)
FastGPT 4.6.8 后使用了 MongoDB 的事务,需要运行在副本集上。副本集没法自动化初始化,需手动操作。
@@ -120,9 +129,9 @@ docker ps
docker exec -it mongo bash
# 连接数据库
mongo
mongo -u myname -p mypassword --authenticationDatabase admin
# 初始化副本集。
# 初始化副本集。如果需要外网访问mongo:27017 可以改成 ip:27017。但是需要同时修改 FastGPT 连接的参数MONGODB_URI=mongodb://myname:mypassword@mongo:27017/fastgpt?authSource=admin => MONGODB_URI=mongodb://myname:mypassword@ip:27017/fastgpt?authSource=admin
rs.initiate({
_id: "rs0",
members: [
@@ -131,14 +140,6 @@ rs.initiate({
})
# 检查状态。如果提示 rs0 状态,则代表运行成功
rs.status()
# 初始化用户
use admin
db.createUser({
user: "admin",
pwd: "password",
roles: [{ role: "root", db: "admin" }]
});
```
## 五、访问 FastGPT

View File

@@ -19,7 +19,7 @@ images: []
## 通用问题
### 能否纯本地允许
### 能否纯本地运行
可以。需要准备好向量模型和LLM模型。
@@ -37,7 +37,7 @@ OneAPI 中没有配置该模型渠道。或者是修改了配置文件中一部
### Incorrect API key provided: sk-xxxx.You can find your api Key at xxx
OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并重启容器(先 stop 然后 rm 掉,最后再 up -d 运行一次)。可以`exec`进入容器,`env`查看环境变量是否生效。
OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并重启容器(先 docker-compose down 然后再 docker-compose up -d 运行一次)。可以`exec`进入容器,`env`查看环境变量是否生效。
### 其他模型没法进行问题分类/内容提取
@@ -46,7 +46,8 @@ OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并
### 页面崩溃
1. 关闭翻译
2. 检查配置文件是否正常加载,如果没有正常加载会导致缺失系统信息,在某些操作下会导致空指针。
2. 检查配置文件是否正常加载,如果没有正常加载会导致缺失系统信息,在某些操作下会导致空指针。95%
3. 某些api不兼容问题较少
## 私有部署问题
@@ -55,11 +56,15 @@ OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并
先看日志报错信息。
1. 可以对话但是索引没有进度没有配置向量模型vectorModels
2. 不能对话也不能索引API调用失败。可能是没连上OneAPI或OenAI
2. 不能对话也不能索引API调用失败。可能是没连上OneAPI或OpenAI
3. 有进度但是非常慢api key不行OpenAI的免费号一分钟只有3次还是60次。一天上限200次。
## Docker 部署常见问题
### 首次部署root用户提示未注册
没有启动 Mongo 副本集模式。
### 如何更新?
1. 查看[更新文档](/docs/development/upgrading/intro/),确认要升级的版本,避免跨版本升级。
@@ -86,6 +91,7 @@ OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并
1. 挂载目录不正确
2. 配置文件不正确,日志中会提示`invalid json`,配置文件需要是标准的 JSON 文件。
3. 修改后,没有`docker-compose down`再`docker-compose up -d`restart是不会重新挂载文件的。
### 为什么无法连接`本地模型`镜像。
@@ -112,8 +118,9 @@ PG 数据库没有连接上/初始化失败可以查看日志。FastGPT 会
### Operation `auth_codes.findOne()` buffering timed out after 10000ms
mongo连接失败检查
1. mongo 服务有没有起来(有些 cpu 不支持 AVX无法用 mongo5需要换成 mongo4.x可以dockerhub找个最新的4.x修改镜像版本重新运行
1. mongo 服务有没有起来有些 cpu 不支持 AVX无法用 mongo5需要换成 mongo4.x可以dockerhub找个最新的4.x修改镜像版本重新运行
2. 环境变量账号密码注意host和port
3. 副本集启动失败一直在重启没挂载mongo keykey没有权限
## 本地开发问题
@@ -125,4 +132,4 @@ mongo连接失败检查
2. 复制 `config.json` -> `config.local.json`
3. 复制 `.env.template` -> `.env.local`
4. `cd projects/app`
5. `pnpm dev`
5. `pnpm dev`

View File

@@ -116,8 +116,7 @@ CHAT_API_KEY=sk-xxxxxx
"maxResponse": 4000, // 最大回复
"quoteMaxToken": 13000, // 最大引用内容
"maxTemperature": 1.2, // 最大温度
"inputPrice": 0,
"outputPrice": 0,
"charsPointsPrice": 0,
"censor": false,
"vision": false, // 是否支持图片输入
"datasetProcess": false, // 是否设置为知识库处理模型

View File

@@ -13,12 +13,25 @@ weight: 853
## 创建训练订单
## 创建训练订单(4.6.9地址发生改动)
{{< tabs tabTotal="2" >}}
{{< tab tabName="请求示例" >}}
{{< markdownify >}}
**新例子**
```bash
curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/usage/createTrainingUsage' \
--header 'Authorization: Bearer {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "可选,自定义订单名称,例如:文档训练-fastgpt.docx"
}'
```
**x例子**
```bash
curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/bill/createTrainingBill' \
--header 'Authorization: Bearer {{apikey}}' \
@@ -154,7 +167,7 @@ curl --location --request GET 'http://localhost:3000/api/core/dataset/list?paren
"vectorModel": {
"model": "text-embedding-ada-002",
"name": "Embedding-2",
"inputPrice": 0,
"charsPointsPrice": 0,
"defaultToken": 512,
"maxToken": 8000,
"weight": 100
@@ -213,7 +226,7 @@ curl --location --request GET 'http://localhost:3000/api/core/dataset/detail?id=
"vectorModel": {
"model": "text-embedding-ada-002",
"name": "Embedding-2",
"inputPrice": 0,
"charsPointsPrice": 0,
"defaultToken": 512,
"maxToken": 8000,
"weight": 100
@@ -223,8 +236,7 @@ curl --location --request GET 'http://localhost:3000/api/core/dataset/detail?id=
"name": "FastAI-16k",
"maxContext": 16000,
"maxResponse": 16000,
"inputPrice": 0,
"outputPrice": 0
"charsPointsPrice": 0
},
"intro": "",
"permission": "private",
@@ -800,6 +812,33 @@ curl --location --request DELETE 'http://localhost:3000/api/core/dataset/collect
## 数据
### 数据的结构
**Data结构**
| 字段 | 类型 | 说明 | 必填 |
| --- | --- | --- | --- |
| teamId | String | 团队ID | ✅ |
| tmbId | String | 成员ID | ✅ |
| datasetId | String | 知识库ID | ✅ |
| collectionId | String | 集合ID | ✅ |
| q | String | 主要数据 | ✅ |
| a | String | 辅助数据 | ✖ |
| fullTextToken | String | 分词 | ✖ |
| indexes | Index[] | 向量索引 | ✅ |
| updateTime | Date | 更新时间 | ✅ |
| chunkIndex | Number | 分块下表 | ✖ |
**Index结构**
每组数据的自定义索引最多5个
| 字段 | 类型 | 说明 | 必填 |
| --- | --- | --- | --- |
| defaultIndex | Boolean | 是否为默认索引 | ✅ |
| dataId | String | 关联的向量ID | ✅ |
| text | String | 文本内容 | ✅ |
### 为集合批量添加添加数据
注意,每次最多推送 200 组数据。
@@ -825,11 +864,14 @@ curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/data/pus
{
"q": "你会什么?",
"a": "我什么都会",
"indexes": [{
"defaultIndex": false,
"type":"custom",
"text":"自定义索引,不使用默认索引"
}]
"indexes": [
{
"text":"自定义索引1"
},
{
"text":"自定义索引2"
}
]
}
]
}'
@@ -850,7 +892,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/data/pus
- data具体数据
- q: 主要数据(必填)
- a: 辅助数据(选填)
- indexes: 自定义索引(选填)不传入则默认使用q和a构建索引。也可以传入
- indexes: 自定义索引(选填)。可以不传或者传空数组默认都会使用q和a组成一个索引。
{{% /alert %}}
{{< /markdownify >}}
@@ -866,7 +908,6 @@ curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/data/pus
"data": {
"insertLen": 1, // 最终插入成功的数量
"overToken": [], // 超出 token 的
"repeat": [], // 重复的数量
"error": [] // 其他错误
}
@@ -1050,7 +1091,16 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
"id":"65abd4b29d1448617cba61db",
"q":"测试111",
"a":"sss",
"indexes":[]
"indexes":[
{
"dataId": "xxx",
"defaultIndex":false,
"text":"自定义索引1"
},
{
"text":"修改后的自定义索引2。会删除原来的自定义索引2并插入新的自定义索引2"
}
]
}'
```
@@ -1064,7 +1114,7 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
- id: 数据的id
- q: 主要数据(选填)
- a: 辅助数据(选填)
- indexes: 自定义索引(选填),类型参考`为集合批量添加添加数据`建议直接不传。更新q,a后如果有默认索引则会直接更新默认索引。
- indexes: 自定义索引(选填),类型参考`为集合批量添加添加数据`。如果创建时候有自定义索引,
{{% /alert %}}
{{< /markdownify >}}

View File

@@ -169,7 +169,7 @@ curl --location --request POST '{{host}}/shareAuth/start' \
响应值与[chat 接口格式相同](/docs/development/openapi/chat/#响应),仅多了一个`token`
可以重点关注`responseData`里的`price`值,`price`与实际价格的倍率为`100000`,即 100000=1元。
重点关注`totalPoints`(总消耗AI积分)`token`(Token消耗总数)
```bash
curl --location --request POST '{{host}}/shareAuth/finish' \
@@ -178,72 +178,117 @@ curl --location --request POST '{{host}}/shareAuth/finish' \
"token": "{{authToken}}",
"responseData": [
{
"moduleName": "KB Search",
"price": 1.2000000000000002,
"model": "Embedding-2",
"tokens": 6,
"similarity": 0.61,
"limit": 3
"moduleName": "core.module.template.Dataset search",
"moduleType": "datasetSearchNode",
"totalPoints": 1.5278,
"query": "导演是谁\n《铃芽之旅》的导演是谁\n这部电影的导演是谁\n谁是《铃芽之旅》的导演",
"model": "Embedding-2(旧版,不推荐使用)",
"tokens": 1524,
"similarity": 0.83,
"limit": 400,
"searchMode": "embedding",
"searchUsingReRank": false,
"extensionModel": "FastAI-4k",
"extensionResult": "《铃芽之旅》的导演是谁?\n这部电影的导演是谁\n谁是《铃芽之旅》的导演",
"runningTime": 2.15
},
{
"moduleName": "AI Chat",
"price": 454.5,
"moduleName": "AI 对话",
"moduleType": "chatNode",
"totalPoints": 0.593,
"model": "FastAI-4k",
"tokens": 303,
"question": "导演是谁",
"answer": "电影《铃芽之旅》的导演是新海诚。",
"maxToken": 2050,
"tokens": 593,
"query": "导演是谁",
"maxToken": 2000,
"quoteList": [
{
"dataset_id": "646627f4f7b896cfd8910e38",
"id": "8099",
"q": "本作的主人公是谁?",
"a": "本作的主人公是名叫铃芽的少女。",
"source": "手动修改"
},
{
"dataset_id": "646627f4f7b896cfd8910e38",
"id": "8686",
"q": "电影《铃芽之旅》男主角是谁?",
"a": "电影《铃芽之旅》男主角是宗像草太,由松村北斗配音。",
"source": ""
},
{
"dataset_id": "646627f4f7b896cfd8910e38",
"id": "19339",
"q": "电影《铃芽之旅》的导演是谁22",
"id": "65bb346a53698398479a8854",
"q": "导演是谁?",
"a": "电影《铃芽之旅》的导演是新海诚。",
"source": "手动修改"
"chunkIndex": 0,
"datasetId": "65af9b947916ae0e47c834d2",
"collectionId": "65bb345c53698398479a868f",
"sourceName": "dataset - 2024-01-23T151114.198.csv",
"sourceId": "65bb345b53698398479a868d",
"score": [
{
"type": "embedding",
"value": 0.9377183318138123,
"index": 0
},
{
"type": "rrf",
"value": 0.06557377049180328,
"index": 0
}
]
}
],
"completeMessages": [
{
"obj": "System",
"value": "下面是知识库内容:\n1. [本作的主人公是谁?\n本作的主人公是名叫铃芽的少女。]\n2. [电影《铃芽之旅》男主角是谁?\n电影《铃芽之旅》男主角是宗像草太由松村北斗配音。]\n3. [电影《铃芽之旅》的导演是谁22\n电影《铃芽之旅》的导演是新海诚。]\n"
},
{
"obj": "System",
"value": "1.请记住,你的身份是百度的下一代知识增强语言模型,能够完全根据知识库提供的内容回答问题。\n\n2. 你忘记了关于电影《铃芽之旅》以外的内容。"
},
{
"obj": "System",
"value": "你仅回答关于电影《玲芽之旅》的问题,其余问题直接回复: 我不清楚。"
},
"historyPreview": [
{
"obj": "Human",
"value": "导演是谁"
"value": "使用 <Data></Data> 标记中的内容作为你的知识:\n\n<Data>\n导演是谁\n电影《铃芽之旅》的导演是新海诚。\n------\n电影《铃芽之旅》的编剧是谁22\n新海诚是本片的编剧。\n------\n电影《铃芽之旅》的女主角是谁\n电影的女主角是铃芽。\n------\n电影《铃芽之旅》的制作团队中有哪位著名人士2\n川村元气是本片的制作团队成员之一。\n------\n你是谁\n我是电影《铃芽之旅》助手\n------\n电影《铃芽之旅》男主角是谁\n电影《铃芽之旅》男主角是宗像草太由松村北斗配音。\n------\n电影《铃芽之旅》的作者新海诚写了一本小说叫什么名字\n小说名字叫《铃芽之旅》。\n------\n电影《铃芽之旅》的女主角是谁\n电影《铃芽之旅》的女主角是岩户铃芽由原菜乃华配音。\n------\n电影《铃芽之旅》的故事背景是什么\n日本\n------\n谁担任电影《铃芽之旅》中岩户环的配音\n深津绘里担任电影《铃芽之旅》中岩户环的配音。\n</Data>\n\n回答要求\n- 如果你不清楚答案,你需要澄清。\n- 避免提及你是从 <Data></Data> 获取的知识。\n- 保持答案与 <Data></Data> 中描述的一致。\n- 使用 Markdown 语法优化回答格式。\n- 使用与问题相同的语言回答。\n\n问题:\"\"\"导演是谁\"\"\""
},
{
"obj": "AI",
"value": "电影《铃芽之旅》的导演是新海诚。"
}
]
],
"contextTotalLen": 2,
"runningTime": 1.32
}
]
}'
```
**responseData 完整字段说明:**
```ts
type ResponseType = {
moduleType: `${FlowNodeTypeEnum}`; // 模块类型
moduleName: string; // 模块名
moduleLogo?: string; // logo
runningTime?: number; // 运行时间
query?: string; // 用户问题/检索词
textOutput?: string; // 文本输出
tokens?: number; // 上下文总Tokens
model?: string; // 使用到的模型
contextTotalLen?: number; // 上下文总长度
totalPoints?: number; // 总消耗AI积分
temperature?: number; // 温度
maxToken?: number; // 模型的最大token
quoteList?: SearchDataResponseItemType[]; // 引用列表
historyPreview?: ChatItemType[]; // 上下文预览(历史记录会被裁剪)
similarity?: number; // 最低相关度
limit?: number; // 引用上限token
searchMode?: `${DatasetSearchModeEnum}`; // 搜索模式
searchUsingReRank?: boolean; // 是否使用rerank
extensionModel?: string; // 问题扩展模型
extensionResult?: string; // 问题扩展结果
extensionTokens?: number; // 问题扩展总字符长度
cqList?: ClassifyQuestionAgentItemType[]; // 分类问题列表
cqResult?: string; // 分类问题结果
extractDescription?: string; // 内容提取描述
extractResult?: Record<string, any>; // 内容提取结果
params?: Record<string, any>; // HTTP模块params
body?: Record<string, any>; // HTTP模块body
headers?: Record<string, any>; // HTTP模块headers
httpResult?: Record<string, any>; // HTTP模块结果
pluginOutput?: Record<string, any>; // 插件输出
pluginDetail?: ChatHistoryItemResType[]; // 插件详情
tfSwitchResult?: boolean; // 判断器结果
}
```
## 实践案例

View File

@@ -57,7 +57,7 @@ Sealos 的服务器在国外,不需要额外处理网络问题,无需服务
### 简介
FastGPT 商业版共包含了3个应用fastgpt, fastgpt-plus, fastgpt-admin和2个数据库使用多 Api Key 时候需要安装 OneAPI一个应用和一个数据库总计4个应用和3个数据库。
FastGPT 商业版共包含了2个应用fastgpt, fastgpt-plus和2个数据库使用多 Api Key 时候需要安装 OneAPI一个应用和一个数据库总计3个应用和3个数据库。
![](/imgs/onSealos1.png)
@@ -122,10 +122,7 @@ SYSTEM_FAVICON 可以是一个网络地址
![](/imgs/onsealos8.png)
### 管理后台
![](/imgs/onsealos9.png)
### 管理后台(已合并到plus)
### 商业版镜像配置文件

View File

@@ -15,13 +15,13 @@ weight: 831
1. 主要是修改模型的`functionCall`字段,改成`toolChoice`即可。设置为`true`的模型,会默认走 openai 的 tools 模式;未设置或设置为`false`的,会走提示词生成模式。
问题补全模型与内容提取模型使用同一组配置。
问题优化模型与内容提取模型使用同一组配置。
2. 增加 `"ReRankModels": []`
## V4.6.5 功能介绍
1. 新增 - [问题补全模块](/docs/workflow/modules/coreferenceresolution/)
1. 新增 - [问题优化模块](/docs/workflow/modules/coreferenceresolution/)
2. 新增 - [文本编辑模块](/docs/workflow/modules/text_editor/)
3. 新增 - [判断器模块](/docs/workflow/modules/tfswitch/)
4. 新增 - [自定义反馈模块](/docs/workflow/modules/custom_feedback/)

View File

@@ -11,7 +11,7 @@ weight: 829
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`{{host}} 替换成自己域名)
1. https://xxxxx/api/admin/initv464
1. https://xxxxx/api/admin/initv467
```bash
curl --location --request POST 'https://{{host}}/api/admin/initv467' \

View File

@@ -1,15 +1,64 @@
---
title: 'V4.6.8进行中'
description: 'FastGPT V4.6.7'
title: 'V4.6.8需要初始化'
description: 'FastGPT V4.6.8更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 828
---
## docker 部署 - 更新 Mongo
## docker 部署 - 手动更新 Mongo
开启 Mongo 副本集模式。需要进入 mongo 执行一次 init参考[初始化Mongo副本集](/docs/development/docker/#四初始化-mongo-副本集),这个比较麻烦,初始化后可以用 mongoshell 之类的连接试试,看能不能连接上。
1. 修改 docker-compose.yml 的mongo部分补上`command``mongodb.key`
```yml
mongo:
image: mongo:5.0.18
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
container_name: mongo
ports:
- 27017:27017
networks:
- fastgpt
command: mongod --keyFile /data/mongodb.key --replSet rs0
environment:
# 这里密码不用变。
- MONGO_INITDB_ROOT_USERNAME=myname
- MONGO_INITDB_ROOT_PASSWORD=mypassword
volumes:
- ./mongo/data:/data/db
- ./mongodb.key:/data/mongodb.key
```
2. 创建 mongo 密钥
```bash
cd 项目目录
# 创建 mongo 密钥
openssl rand -base64 756 > ./mongodb.key
# 600不行可以用chmod 999
chmod 600 ./mongodb.key
chown 999:root ./mongodb.key
# 重启 Mongo
docker-compose down
docker-compose up -d
```
3. 进入容器初始化部分集合
```bash
docker exec -it mongo bash
mongo -u myname -p mypassword --authenticationDatabase admin
# 初始化副本集。如果需要外网访问mongo:27017 可以改成 ip:27017。但是需要同时修改 FastGPT 连接的参数MONGODB_URI=mongodb://myname:mypassword@mongo:27017/fastgpt?authSource=admin => MONGODB_URI=mongodb://myname:mypassword@ip:27017/fastgpt?authSource=admin
rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "mongo:27017" }
]
})
# 检查状态。如果提示 rs0 状态,则代表运行成功
rs.status()
```
## Sealos 部署 - 无需更新 Mongo
@@ -17,11 +66,26 @@ weight: 828
去除了重复的模型配置LLM模型都合并到一个属性中[点击查看最新的配置文件](/docs/development/configuration/)
## 商业版初始化
商业版用户需要执行一个初始化,格式化团队信息。
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`{{host}} 替换成自己域名)
```bash
curl --location --request POST 'https://{{host}}/api/init/v468' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```
会初始化计费系统,内部使用可把免费的存储拉大。
## V4.6.8 更新说明
1. 新增 - 知识库搜索合并模块。
1. 优化 - LLM 模型配置,不再区分对话、分类、提取模型。同时支持模型的默认参数,避免不同模型参数冲突,可通过`defaultConfig`传入默认的配置
2. 优化 - HTTP 模块支持输出字符串自动序列化JSON可自动转成字符串
3. 优化 - 流响应,参考了`ChatNextWeb`的流,更加丝滑。此外,之前提到的乱码、中断,刷新后又正常了,可能会修复)
4. 修复 - 语音输入文件无法上传。
5. 修复 - 对话框重新生成无法使用。
2. 新增 - 新的 Http 模块,支持更加灵活的参数传入。同时支持了输入输出自动数据类型转化,例如:接口输出的 JSON 类型会自动转成字符串类型,直接给其他模块使用。此外,还补充了一些例子,可在文档中查看
3. 优化 - 内容补全。将内容补全内置到【知识库搜索】中并实现了一次内容补全即可完成“指代消除”和“问题扩展”。FastGPT知识库搜索详细流程可查看[知识库搜索介绍](/docs/course/data_search/)
4. 优化 - LLM 模型配置,不再区分对话、分类、提取模型。同时支持模型的默认参数,避免不同模型参数冲突,可通过`defaultConfig`传入默认的配置。
5. 优化 - 流响应,参考了`ChatNextWeb`的流,更加丝滑。此外,之前提到的乱码、中断,刷新后又正常了,可能会修复)
6. 修复 - 语音输入文件无法上传。
7. 修复 - 对话框重新生成无法使用。

View File

@@ -0,0 +1,40 @@
---
title: 'V4.6.9(进行中)'
description: 'FastGPT V4.6.9更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 827
---
## 初始化脚本
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`{{host}} 替换成自己域名
```bash
curl --location --request POST 'https://{{host}}/api/init/v469' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```
1. 重置计量表。
2. 执行脏数据清理(清理无效的文件、清理无效的图片、清理无效的知识库集合、清理无效的向量)
## 外部接口更新
1. 由于计费系统变更,[分享链接对话上报接口](/docs/development/openapi/share/#5-编写对话结果上报接口可选)需要做一些调整price字段被totalPoints字段取代。inputToken和outputToken不再提供只提供`token`字段总token数量
## V4.6.9 更新说明
1. 商业版新增 - 知识库新增“增强处理”训练模式,可生成更多类型索引。
2. 新增 - 完善了HTTP模块的变量提示。
3. 新增 - HTTP模块支持OpenAI单接口导入。
4. 新增 - 全局变量支持增加外部变量。可通过分享链接的Query或 API 的 variables 参数传入。
5. 新增 - 内容提取模块增加默认值。
6. 优化 - 问题补全。增加英文类型。同时可以设置为单独模块,方便复用。
7. 优化 - 重写了计量模式
8. 优化 - Token 过滤历史记录,保持偶数条,防止部分模型报错。
9. 优化 - 分享链接SEO可直接展示应用名和头像。
10. 修复 - 标注功能。
11. 修复 - qa生成线程计数错误。
12. 修复 - 问题分类连线类型错误

View File

@@ -7,14 +7,4 @@ toc: true
weight: 1200
---
## Tokens 说明
[OpenAI 的 API 官方计费模式](https://openai.com/pricing#language-models)为:按每次 API 请求内容和返回内容 tokens 长度来定价。每个模型具有不同的计价方式,以每 1,000 个 tokens 消耗为单位定价。其中 1,000 个 tokens 约为 900 个英文,约 600 个中文(不是很准确,与上下长度有关,相同的词出现越多,词:Tokens 的比例越大)。平台的 tokens 数量计算算法与 OpenAI 一致,您可以随时通过「使用记录」来查看余额消耗明细的说明,来对比计算是否一致。
![](/imgs/fastgpt-price.png)
## FastGPT 线上计费
[https://fastgpt.in](https://fastgpt.in) 采用按量计费的模式,最新计费标准可在 `账号-计费标准` 查看。同时可以在 `账号-使用记录` 中查看具体使用情况,
![](/imgs/cloud_price1.jpg)
线上版价格请查看https://cloud.fastgpt.in/price

View File

@@ -0,0 +1,517 @@
---
title: 'Dalle3 绘图'
description: '使用 HTTP 模块绘制图片'
icon: 'image'
draft: false
toc: true
weight: 404
---
| | |
| --------------------- | --------------------- |
| ![](/imgs/demo-dalle1.png) | ![](/imgs/demo-dalle2.png) |
## OpenAI Dalle3 接口
先来看下官方接口的参数和响应值:
Body
```json
{
"model": "dall-e-3",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}
```
Response
```json
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
```
## 编排思路
1. 通过 AI 来优化图片绘制的提示词(这部省略了,自己找提示词即可)
2. 通过`HTTP 模块`调用 Dalle3 接口,获取图片的 URL。
3. 通过`文本加工`来构建`Markdown`的图片格式。
4. 通过`指定回复`来直接输出图片链接。
### 1. 构建 HTTP 模块
请求参数直接复制 Dalle3 接口的即可,并求改 prompt 为变量。需要增加一个`Headers.Authorization`
Body:
```json
{
"model": "dall-e-3",
"prompt": "{{prompt}}",
"n": 1,
"size": "1024x1024"
}
```
Headers:
`Authorization: Bearer sk-xxx`
Response:
响应值需要根据Dalle3接口的返回值进行获取我们只绘制了1张图片所以只需要取第一张图片的URL即可。给 HTTP 模块增加一个`key``data[0].url`的输出值。
### 2. 文本加工 - 构建图片链接
`Markdown`语法中`![图片描述](图片链接)`表示插入图片,图片链接由`HTTP模块`输出。
因此可以增加一个输入来接收`HTTP模块`的图片链接输出,并在`文本内容`中通过变量来引用图片链接,从而得到一个完整的`Markdown`图片格式。
### 3. 指定回复
指定回复可以直接输出传入的内容到客户端,因此可以直接输出加工好的`Markdown`图片格式即可。
## 编排代码
```json
[
{
"moduleId": "userGuide",
"name": "core.module.template.User guide",
"flowType": "userGuide",
"position": {
"x": 454.98510354678695,
"y": 721.4016845336229
},
"inputs": [
{
"key": "welcomeText",
"type": "hidden",
"valueType": "string",
"label": "core.app.Welcome Text",
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "variables",
"type": "hidden",
"valueType": "any",
"label": "core.module.Variable",
"value": [],
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "questionGuide",
"valueType": "boolean",
"type": "switch",
"label": "",
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "tts",
"type": "hidden",
"valueType": "any",
"label": "",
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
}
],
"outputs": []
},
{
"moduleId": "userChatInput",
"name": "core.module.template.Chat entrance",
"flowType": "questionInput",
"position": {
"x": 597.8136543694757,
"y": 1709.9244174501202
},
"inputs": [
{
"key": "userChatInput",
"type": "systemInput",
"valueType": "string",
"label": "core.module.input.label.user question",
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
}
],
"outputs": [
{
"key": "userChatInput",
"label": "core.module.input.label.user question",
"type": "source",
"valueType": "string",
"targets": [
{
"moduleId": "mqgfub",
"key": "prompt"
}
]
}
]
},
{
"moduleId": "mqgfub",
"name": "Dalle3绘图",
"flowType": "httpRequest468",
"showStatus": true,
"position": {
"x": 1071.8956245626034,
"y": 1236.690825267034
},
"inputs": [
{
"key": "switch",
"type": "target",
"label": "core.module.input.label.switch",
"description": "core.module.input.description.Trigger",
"valueType": "any",
"showTargetInApp": true,
"showTargetInPlugin": true,
"connected": false
},
{
"key": "system_httpMethod",
"type": "custom",
"valueType": "string",
"label": "",
"value": "POST",
"required": true,
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "system_httpReqUrl",
"type": "hidden",
"valueType": "string",
"label": "",
"description": "core.module.input.description.Http Request Url",
"placeholder": "https://api.ai.com/getInventory",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": false,
"value": "https://api.openai.com/v1/images/generations",
"connected": false
},
{
"key": "system_httpHeader",
"type": "custom",
"valueType": "any",
"value": [
{
"key": "Authorization",
"type": "string",
"value": "sk-xxx"
}
],
"label": "",
"description": "core.module.input.description.Http Request Header",
"placeholder": "core.module.input.description.Http Request Header",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "system_httpParams",
"type": "hidden",
"valueType": "any",
"value": [],
"label": "",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "system_httpJsonBody",
"type": "hidden",
"valueType": "any",
"value": "{\r\n \"model\": \"dall-e-3\",\r\n \"prompt\": \"{{prompt}}\",\r\n \"n\": 1,\r\n \"size\": \"1024x1024\"\r\n }",
"label": "",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": false,
"connected": false
},
{
"key": "DYNAMIC_INPUT_KEY",
"type": "target",
"valueType": "any",
"label": "core.module.inputType.dynamicTargetInput",
"description": "core.module.input.description.dynamic input",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": true,
"hideInApp": true,
"connected": false
},
{
"key": "prompt",
"valueType": "string",
"label": "prompt",
"type": "target",
"required": true,
"description": "",
"edit": true,
"editField": {
"key": true,
"name": true,
"description": true,
"required": true,
"dataType": true
},
"connected": true
},
{
"key": "system_addInputParam",
"type": "addInputParam",
"valueType": "any",
"label": "",
"required": false,
"showTargetInApp": false,
"showTargetInPlugin": false,
"editField": {
"key": true,
"name": true,
"description": true,
"required": true,
"dataType": true
},
"defaultEditField": {
"label": "",
"key": "",
"description": "",
"inputType": "target",
"valueType": "string",
"required": true
},
"connected": false
}
],
"outputs": [
{
"key": "finish",
"label": "core.module.output.label.running done",
"description": "core.module.output.description.running done",
"valueType": "boolean",
"type": "source",
"targets": []
},
{
"key": "system_addOutputParam",
"type": "addOutputParam",
"valueType": "any",
"label": "",
"targets": [],
"editField": {
"key": true,
"name": true,
"description": true,
"dataType": true
},
"defaultEditField": {
"label": "",
"key": "",
"description": "",
"outputType": "source",
"valueType": "string"
}
},
{
"type": "source",
"valueType": "string",
"key": "data[0].url",
"label": "url",
"description": "",
"edit": true,
"editField": {
"key": true,
"name": true,
"description": true,
"dataType": true
},
"targets": [
{
"moduleId": "nl6mr9",
"key": "url"
}
]
}
]
},
{
"moduleId": "xy76o2",
"name": "core.module.template.Assigned reply",
"flowType": "answerNode",
"position": {
"x": 2204.027057268489,
"y": 1256.786345213533
},
"inputs": [
{
"key": "switch",
"type": "target",
"label": "core.module.input.label.switch",
"description": "core.module.input.description.Trigger",
"valueType": "any",
"showTargetInApp": true,
"showTargetInPlugin": true,
"connected": false
},
{
"key": "text",
"type": "textarea",
"valueType": "any",
"label": "core.module.input.label.Response content",
"description": "core.module.input.description.Response content",
"placeholder": "core.module.input.description.Response content",
"showTargetInApp": true,
"showTargetInPlugin": true,
"connected": true
}
],
"outputs": [
{
"key": "finish",
"label": "core.module.output.label.running done",
"description": "core.module.output.description.running done",
"valueType": "boolean",
"type": "source",
"targets": []
}
]
},
{
"moduleId": "nl6mr9",
"name": "core.module.template.textEditor",
"flowType": "pluginModule",
"showStatus": false,
"position": {
"x": 1690.1826860670342,
"y": 1262.3858719789062
},
"inputs": [
{
"key": "pluginId",
"type": "hidden",
"label": "",
"value": "community-textEditor",
"valueType": "string",
"connected": false,
"showTargetInApp": false,
"showTargetInPlugin": false
},
{
"key": "switch",
"type": "target",
"label": "core.module.input.label.switch",
"description": "core.module.input.description.Trigger",
"valueType": "any",
"showTargetInApp": true,
"showTargetInPlugin": true,
"connected": false
},
{
"key": "textarea",
"valueType": "string",
"label": "文本内容",
"type": "textarea",
"required": true,
"description": "可以通过 {{key}} 的方式引用传入的变量。变量仅支持字符串或数字。",
"edit": false,
"editField": {
"key": true,
"name": true,
"description": true,
"required": true,
"dataType": true,
"inputType": true
},
"connected": false,
"placeholder": "可以通过 {{key}} 的方式引用传入的变量。变量仅支持字符串或数字。",
"value": "![]({{url}})"
},
{
"key": "url",
"valueType": "string",
"label": "url",
"type": "target",
"required": true,
"description": "",
"edit": true,
"editField": {
"key": true,
"name": true,
"description": true,
"required": true,
"dataType": true,
"inputType": false
},
"connected": true
},
{
"key": "DYNAMIC_INPUT_KEY",
"valueType": "any",
"label": "需要加工的输入",
"type": "addInputParam",
"required": false,
"description": "可动态的添加字符串类型变量,在文本编辑中通过 {{key}} 使用变量。非字符串类型,会自动转成字符串类型。",
"edit": false,
"editField": {
"key": true,
"name": true,
"description": true,
"required": true,
"dataType": true,
"inputType": false
},
"defaultEditField": {
"label": "",
"key": "",
"description": "",
"inputType": "target",
"valueType": "string",
"required": true
},
"connected": false
}
],
"outputs": [
{
"key": "text",
"valueType": "string",
"label": "core.module.output.label.text",
"type": "source",
"edit": false,
"targets": [
{
"moduleId": "xy76o2",
"key": "text"
}
]
}
]
}
]
```

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,8 @@ toc: true
weight: 406
---
**该教程由社区提供,部分模块已经过期,需调整后才能使用。**
![](/imgs/versatile_assistant_1.png)
众所周知 GPT 只是一个语言模型,功能上有很多局限,但只要综合利用高级编排各模块功能,就可以轻松突破原有 GPT 的局限,实现更多功能。

View File

@@ -1,6 +1,6 @@
---
title: "问题补全"
description: "问题补全模块介绍和使用"
title: "问题优化(已合并到知识库搜索)"
description: "问题优化模块介绍和使用"
icon: "input"
draft: false
toc: true
@@ -23,7 +23,7 @@ weight: 364
![](/imgs/coreferenceResolution2.jpg)
用户在提问“第二点是什么”的时候只会去知识库里查找“第二点是什么”压根查不到内容。实际上需要查询的是“QA结构是什么”。因此我们需要引入一个【问题补全】模块,来对用户当前的问题进行补全,从而使得知识库搜索能够搜索到合适的内容。使用补全后效果如下:
用户在提问“第二点是什么”的时候只会去知识库里查找“第二点是什么”压根查不到内容。实际上需要查询的是“QA结构是什么”。因此我们需要引入一个【问题优化】模块,来对用户当前的问题进行补全,从而使得知识库搜索能够搜索到合适的内容。使用补全后效果如下:
![](/imgs/coreferenceResolution3.jpg)

View File

@@ -7,6 +7,8 @@ toc: true
weight: 357
---
知识库搜索具体参数说明,以及内部逻辑请移步:[FastGPT知识库搜索方案](/docs/course/data_search/)
## 特点
- 可重复添加(复杂编排时防止线太乱,可以更美观)

View File

@@ -1,5 +1,5 @@
---
title: "HTTP 模块"
title: "HTTP 模块"
description: "FastGPT HTTP 模块介绍"
icon: "http"
draft: false
@@ -21,46 +21,109 @@ weight: 355
HTTP 模块会向对应的地址发送一个 `POST/GET` 请求,携带部分`系统参数``自定义参数`,并接收一个 JSON 响应值,字段也是自定义。
- 你还可以通过 JSON 传入自定义的请求头
- POST 请求中,数据会被放置在 `body`
- GET 请求中,数据会被放置在 `query`
- 在出入参数中,你都可以通过 xxx.xxx 来代表嵌套的对象
- Params 为路径请求参数GET请求中用的居多
- Body 为请求体,POST请求中用的居多
- Headers 为请求头,用于传递一些特殊的信息
- 3 种数据中均可以通过 `{{}}` 来引用变量
- 变量来自于`全局变量``系统变量``局部传入`
## 参数结构
### 系统参数说明
### 系统变量说明
你可以将鼠标放置在`请求参数`旁边的问号中,里面会提示你可用的变量。
- appId: 应用的ID
- chatId: 当前对话的ID测试模式下不存在。
- responseChatItemId: 当前对话中响应的消息ID测试模式下不存在。
- variables: 当前对话的全局变量。
- data: 自定义传递的参数
- cTime: 当前时间
- histories: 历史记录默认最多取10条无法修改长度
### 嵌套对象使用
### Params, Headers
#### 入参
不多描述使用方法和Postman, ApiFox 基本一致,目前 Params 和 Headers 未提供语法提示,后续会加入。
假设我们设计了`3个`输入。
可通过 {{key}} 来引入变量。例如:
- user.name (string)
- user.age (number)
- type (string)
| key | value |
| --- | --- |
| appId | {{appId}} |
| Authorization | Bearer {{token}} |
最终组成的对象为:
### Body
只有`POST`模式下会生效。
可以写一个`自定义的 Json`,并通过 {{key}} 来引入变量。例如:
{{< tabs tabTotal="3" >}}
{{< tab tabName="假设有一组变量" >}}
{{< markdownify >}}
```json
{
"user": {
"name": "",
"age": ""
},
"type": ""
"string": "字符串",
"number": 123,
"boolean": true,
"array": [1, 2, 3],
"obj": {
"name": "FastGPT",
"url": "https://fastgpt.in"
}
}
```
#### 出参
{{< /markdownify >}}
{{< /tab >}}
{{< tab tabName="Http 模块中的Body声明" >}}
{{< markdownify >}}
假设接口的输出结构为:
注意,在 Body 中,你如果引用`字符串`,则需要加上`""`,例如:`"{{string}}"`
```json
{
"string": "{{string}}",
"token": "Bearer {{string}}",
"number": {{number}},
"boolean": {{boolean}},
"array": [{{number}}, "{{string}}"],
"array2": {{array}},
"object": {{obj}}
}
```
{{< /markdownify >}}
{{< /tab >}}
{{< tab tabName="最终得到的解析" >}}
{{< markdownify >}}
```json
{
"string": "字符串",
"token": "Bearer 字符串",
"number": 123,
"boolean": true,
"array": [123, "字符串"],
"array2": [1, 2, 3],
"object": {
"name": "FastGPT",
"url": "https://fastgpt.in"
}
}
```
{{< /markdownify >}}
{{< /tab >}}
{{< /tabs >}}
### 如何获取返回值
从图中可以看出FastGPT可以添加多个返回值这个返回值并不代表接口的返回值而是代表`如何解析接口返回值`,可以通过 key 来`提取`接口响应的值。例如:
{{< tabs tabTotal="2" >}}
{{< tab tabName="接口响应格式" >}}
{{< markdownify >}}
```json
{
@@ -82,135 +145,48 @@ HTTP 模块会向对应的地址发送一个 `POST/GET` 请求,携带部分`
}
```
最终得到的解析为:
{{< /markdownify >}}
{{< /tab >}}
{{< tab tabName="FastGPT 转化后的格式" >}}
{{< markdownify >}}
```json
{
"user": { "name": "xxx", "age": 12 },
"user.name": "xxx",
"user.age": 12,
"list": [ { "name": "xxx", "age": 50 }, [{ "test": 22 }] ],
"list[0]": { "name": "xxx", "age": 50 },
"list[0].name": "xxx",
"list[0].age": 50,
"list[1]": [ { "test": 22 } ],
"list[1][0]": { "test": 22 },
"list[1][0].test": 22,
"psw": "xxx"
"message": "测试",
"data.user": { "name": "xxx", "age": 12 },
"data.user.name": "xxx",
"data.user.age": 12,
"data.list": [ { "name": "xxx", "age": 50 }, [{ "test": 22 }] ],
"data.list[0]": { "name": "xxx", "age": 50 },
"data.list[0].name": "xxx",
"data.list[0].age": 50,
"data.list[1]": [ { "test": 22 } ],
"data.list[1][0]": { "test": 22 },
"data.list[1][0].test": 22,
"data.psw": "xxx"
}
```
你可以使用`json`里对应的`key`来获取值。
{{< /markdownify >}}
{{< /tab >}}
{{< /tabs >}}
### 格式化输出
你可以配置对应的`key`来从`FastGPT 转化后的格式`获取需要的值,该规则遵守 JS 的对象取值规则。例如:
1. 获取`message`的内容,那么你可以配置`message``key``message`,这样就可以获取到`message`的内容。
2. 获取`user的name`,则`key`可以为:`data.user.name`
3. 获取list中第二个元素`key`可以为:`data.list[1]`,然后输出类型选择字符串,则获自动获取到`[ { "test": 22 } ]``json`字符串。
### 自动格式化输出
FastGPT v4.6.8 后,加入了出参格式化功能,主要以`json`格式化成`字符串`为主。如果你的输出类型选择了`字符串`,则会将`HTTP`对应`key`的值,转成`json`字符串进行输出。因此,未来你可以直接从`HTTP`接口输出内容至`文本加工`中,然后拼接适当的提示词,最终输入给`AI对话`
## POST 示例
### 动态外部数据
**自定义入参**
- user.name (string)
- user.age (number)
- type (string)
**自定义出参**
- message (string)
- data.name (string)
- data.age (number)
那么,这个模块发出的请求则是:
{{< tabs tabTotal="2" >}}
{{< tab tabName="POST 请求示例" >}}
{{< markdownify >}}
```bash
curl --location --request POST 'http://xxxx.com' \
--header 'Content-Type: application/json' \
--data-raw '{
"appId": "65782f7ffae5f7854ed4498b",
"chatId": "xxxx",
"responseChatItemId": "xxxx",
"variables": {
"cTime": "2023-12-18 13:45:46"
},
"data": {
"user": {
"name": "",
"age": ""
},
"type": ""
}
}'
```
{{< /markdownify >}}
{{< /tab >}}
{{< tab tabName="POST响应" >}}
{{< markdownify >}}
```json
{
"message": "message",
"data": {
"name": "name",
"age": 10
}
}
```
{{< /markdownify >}}
{{< /tab >}}
{{< /tabs >}}
## GET 示例
GET 中不推荐使用嵌套参数否则会出现奇怪的问题。此外GET 请求中FastGPT 会将参数扁平化,不会将自定义参单独抽到 data 中,同时全局变量也会扁平化,因此需要注意字段 key 是否冲突。
**自定义入参**
- name (string)
- age (number)
- type (string)
**自定义出参**
- message (string)
- name (string)
- age (number)
那么,这个模块发出的请求则是:
{{< tabs tabTotal="2" >}}
{{< tab tabName="GET 请求示例" >}}
{{< markdownify >}}
```bash
curl --location --request GET 'http://xxx.com/test?name&age&type&appId=65782f7ffae5f7854ed4498b&chatId=xxxx&responseChatItemId=xxxx&cTime=2023-12-18 13:45:46'
```
{{< /markdownify >}}
{{< /tab >}}
{{< tab tabName="GET 响应" >}}
{{< markdownify >}}
```json
{
"message": "message",
"data": {
"name": "name",
"age": 10
}
}
```
{{< /markdownify >}}
{{< /tab >}}
{{< /tabs >}}
在插件中的`HTTP模块`有一个属性叫`动态外部数据`,这个属性是与`插件输入`中,数据类型为`动态外部数据`的值搭配使用。
类似于文本加工模块会有一个不确定长度不确定key的用户输入因此这部分数据会被`动态外部数据`接收,它们是一个对象。在 HTTP 模块中,你可以在`Body`中接收到一个`key``DYNAMIC_INPUT_KEY`的对象。
## laf 对接 HTTP 示例
@@ -226,16 +202,14 @@ const db = cloud.database()
type RequestType = {
appId: string;
data: {
appointment: string;
action: 'post' | 'delete' | 'put' | 'get'
}
appointment: string;
action: 'post' | 'delete' | 'put' | 'get'
}
export default async function (ctx: FunctionContext) {
try {
// 从 body 中获取参数
const { appId, data: { appointment, action } } = ctx.body as RequestType
const { appId, appointment, action } = ctx.body as RequestType
const parseBody = JSON.parse(appointment)
if (action === 'get') {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -22,14 +22,18 @@ services:
image: mongo:5.0.18
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
container_name: mongo
restart: always
ports: # 生产环境建议不要暴露
ports:
- 27017:27017
networks:
- fastgpt
command: --replSet rs0
command: mongod --keyFile /data/mongodb.key --replSet rs0
environment:
# 默认的用户名和密码,只有首次允许有效
- MONGO_INITDB_ROOT_USERNAME=myname
- MONGO_INITDB_ROOT_PASSWORD=mypassword
volumes:
- ./mongo/data:/data/db
- ./mongodb.key:/data/mongodb.key
fastgpt:
container_name: fastgpt
image: ghcr.io/labring/fastgpt:latest # git
@@ -52,8 +56,8 @@ services:
- TOKEN_KEY=any
- ROOT_KEY=root_key
- FILE_TOKEN_KEY=filetoken
# mongo 配置,不需要改. 用户名admin,密码password,是执行 db.createUser 时的账号和密码
- MONGODB_URI=mongodb://admin:password@mongo:27017/fastgpt?authSource=admin
# mongo 配置,不需要改. 用户名myname,密码mypassword。
- MONGODB_URI=mongodb://myname:mypassword@mongo:27017/fastgpt?authSource=admin
# pg配置. 不需要改
- PG_URL=postgresql://username:password@pg:5432/postgres
volumes:

View File

@@ -14,11 +14,11 @@
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"husky": "^8.0.3",
"i18next": "^22.5.1",
"i18next": "23.10.0",
"lint-staged": "^13.2.1",
"next-i18next": "^13.3.0",
"prettier": "^3.0.3",
"react-i18next": "^12.3.1",
"next-i18next": "15.2.0",
"prettier": "3.2.4",
"react-i18next": "13.5.0",
"zhlint": "^0.7.1"
},
"lint-staged": {

View File

@@ -3,11 +3,25 @@ import { ErrType } from '../errorCode';
/* team: 500000 */
export enum TeamErrEnum {
teamOverSize = 'teamOverSize',
unAuthTeam = 'unAuthTeam'
unAuthTeam = 'unAuthTeam',
aiPointsNotEnough = 'aiPointsNotEnough',
datasetSizeNotEnough = 'datasetSizeNotEnough',
datasetAmountNotEnough = 'datasetAmountNotEnough',
appAmountNotEnough = 'appAmountNotEnough',
pluginAmountNotEnough = 'pluginAmountNotEnough',
websiteSyncNotEnough = 'websiteSyncNotEnough',
reRankNotEnough = 'reRankNotEnough'
}
const teamErr = [
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' }
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' },
{ statusText: TeamErrEnum.aiPointsNotEnough, message: 'AI积分已用完~' },
{ statusText: TeamErrEnum.datasetSizeNotEnough, message: '知识库容量不足,请先扩容~' },
{ statusText: TeamErrEnum.datasetAmountNotEnough, message: '知识库数量已达上限~' },
{ statusText: TeamErrEnum.appAmountNotEnough, message: '应用数量已达上限~' },
{ statusText: TeamErrEnum.pluginAmountNotEnough, message: '插件数量已达上限~' },
{ statusText: TeamErrEnum.websiteSyncNotEnough, message: '无权使用Web站点同步~' },
{ statusText: TeamErrEnum.reRankNotEnough, message: '无权使用检索重排~' }
];
export default teamErr.reduce((acc, cur, index) => {
return {

View File

@@ -1,7 +1,7 @@
import { replaceSensitiveLink } from '../string/tools';
import { replaceSensitiveText } from '../string/tools';
export const getErrText = (err: any, def = '') => {
const msg: string = typeof err === 'string' ? err : err?.message || def || '';
msg && console.log('error =>', msg);
return replaceSensitiveLink(msg);
return replaceSensitiveText(msg);
};

View File

@@ -1,11 +1,11 @@
import { MongoImageTypeEnum } from './image/constants';
import { OutLinkChatAuthProps } from '../../support/permission/chat.d';
export type preUploadImgProps = {
export type preUploadImgProps = OutLinkChatAuthProps & {
type: `${MongoImageTypeEnum}`;
expiredTime?: Date;
metadata?: Record<string, any>;
shareId?: string;
};
export type UploadImgProps = preUploadImgProps & {
base64Img: string;

View File

@@ -0,0 +1,4 @@
export const formatNumber = (num: number, digit = 1e4) => Math.round(num * digit) / digit;
export const formatNumber2Million = (num: number) => Math.round(num / 1000000);
export const formatNumber2Thousand = (num: number) => Math.round(num / 1000);

View File

@@ -4,6 +4,7 @@ import { Tiktoken } from 'js-tiktoken/lite';
import { adaptChat2GptMessages } from '../../../core/chat/adapt';
import { ChatCompletionRequestMessageRoleEnum } from '../../../core/ai/constant';
import encodingJson from './cl100k_base.json';
import { ChatMessageItemType } from '../../../core/ai/type';
/* init tikToken obj */
export function getTikTokenEnc() {
@@ -29,37 +30,35 @@ export function getTikTokenEnc() {
/* count one prompt tokens */
export function countPromptTokens(
prompt = '',
role: '' | `${ChatCompletionRequestMessageRoleEnum}` = ''
role: '' | `${ChatCompletionRequestMessageRoleEnum}` = '',
tools?: any
) {
const enc = getTikTokenEnc();
const text = `${role}\n${prompt}`;
// too large a text will block the thread
if (text.length > 15000) {
return text.length * 1.7;
}
const toolText = tools
? JSON.stringify(tools)
.replace('"', '')
.replace('\n', '')
.replace(/( ){2,}/g, ' ')
: '';
const text = `${role}\n${prompt}\n${toolText}`.trim();
try {
const encodeText = enc.encode(text);
return encodeText.length + role.length; // 补充 role 估算值
const supplementaryToken = role ? 4 : 0;
return encodeText.length + supplementaryToken;
} catch (error) {
return text.length;
}
}
/* count messages tokens */
export function countMessagesTokens({ messages }: { messages: ChatItemType[] }) {
export const countMessagesTokens = (messages: ChatItemType[], tools?: any) => {
const adaptMessages = adaptChat2GptMessages({ messages, reserveId: true });
let totalTokens = 0;
for (let i = 0; i < adaptMessages.length; i++) {
const item = adaptMessages[i];
const tokens = countPromptTokens(item.content, item.role);
totalTokens += tokens;
}
return totalTokens;
}
return countGptMessagesTokens(adaptMessages, tools);
};
export const countGptMessagesTokens = (messages: ChatMessageItemType[], tools?: any) =>
messages.reduce((sum, item) => sum + countPromptTokens(item.content, item.role, tools), 0);
/* slice messages from top to bottom by maxTokens */
export function sliceMessagesTB({

View File

@@ -2,3 +2,4 @@ import dayjs from 'dayjs';
export const formatTime2YMDHM = (time?: Date) =>
time ? dayjs(time).format('YYYY-MM-DD HH:mm') : '';
export const formatTime2YMD = (time?: Date) => (time ? dayjs(time).format('YYYY-MM-DD') : '');

View File

@@ -38,10 +38,14 @@ export function replaceVariable(text: string, obj: Record<string, string | numbe
return text || '';
}
/* replace sensitive link */
export const replaceSensitiveLink = (text: string) => {
const urlRegex = /(?<=https?:\/\/)[^\s]+/g;
return text.replace(urlRegex, 'xxx');
/* replace sensitive text */
export const replaceSensitiveText = (text: string) => {
// 1. http link
text = text.replace(/(?<=https?:\/\/)[^\s]+/g, 'xxx');
// 2. nx-xxx 全部替换成xxx
text = text.replace(/ns-[\w-]+/g, 'xxx');
return text;
};
export const getNanoid = (size = 12) => {

View File

@@ -30,6 +30,7 @@ export type FastGPTFeConfigsType = {
show_pay?: boolean;
show_openai_account?: boolean;
show_promotion?: boolean;
show_team_chat?: boolean;
hide_app_flow?: boolean;
concatMd?: string;
docUrl?: string;
@@ -38,9 +39,12 @@ export type FastGPTFeConfigsType = {
systemTitle?: string;
googleClientVerKey?: string;
isPlus?: boolean;
show_phoneLogin?: boolean;
show_emailLogin?: boolean;
oauth?: {
github?: string;
google?: string;
wechat?: string;
};
limit?: {
exportDatasetLimitMinutes?: number;

View File

@@ -6,8 +6,7 @@ export type LLMModelItemType = {
quoteMaxToken: number;
maxTemperature: number;
inputPrice: number;
outputPrice: number;
charsPointsPrice: number; // 1k chars=n points
censor?: boolean;
vision?: boolean;
@@ -27,8 +26,7 @@ export type VectorModelItemType = {
model: string;
name: string;
defaultToken: number;
inputPrice: number;
outputPrice: number;
charsPointsPrice: number;
maxToken: number;
weight: number;
hidden?: boolean;
@@ -38,8 +36,7 @@ export type VectorModelItemType = {
export type ReRankModelItemType = {
model: string;
name: string;
inputPrice: number;
outputPrice?: number;
charsPointsPrice: number;
requestUrl?: string;
requestAuth?: string;
};
@@ -47,14 +44,12 @@ export type ReRankModelItemType = {
export type AudioSpeechModelType = {
model: string;
name: string;
inputPrice: number;
outputPrice?: number;
charsPointsPrice: number;
voices: { label: string; value: string; bufferId: string }[];
};
export type WhisperModelType = {
model: string;
name: string;
inputPrice: number;
outputPrice?: number;
charsPointsPrice: number; // 60s = n points
};

View File

@@ -2,14 +2,13 @@ import type { LLMModelItemType, VectorModelItemType } from './model.d';
export const defaultQAModels: LLMModelItemType[] = [
{
model: 'gpt-3.5-turbo-16k',
name: 'gpt-3.5-turbo-16k',
model: 'gpt-3.5-turbo',
name: 'gpt-3.5-turbo',
maxContext: 16000,
maxResponse: 16000,
quoteMaxToken: 13000,
maxTemperature: 1.2,
inputPrice: 0,
outputPrice: 0,
charsPointsPrice: 0,
censor: false,
vision: false,
datasetProcess: true,
@@ -26,8 +25,7 @@ export const defaultVectorModels: VectorModelItemType[] = [
{
model: 'text-embedding-ada-002',
name: 'Embedding-2',
inputPrice: 0,
outputPrice: 0,
charsPointsPrice: 0,
defaultToken: 500,
maxToken: 3000,
weight: 100

View File

@@ -17,6 +17,7 @@ export interface AppUpdateParams {
intro?: string;
modules?: AppSchema['modules'];
permission?: AppSchema['permission'];
teamTags?: AppSchema['teamTags'];
}
export type FormatForm2ModulesProps = {

View File

@@ -5,7 +5,7 @@ import type { AIChatModuleProps, DatasetModuleProps } from '../module/node/type.
import { VariableInputEnum } from '../module/constants';
import { SelectedDatasetType } from '../module/api';
import { DatasetSearchModeEnum } from '../dataset/constants';
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
export interface AppSchema {
_id: string;
userId: string;
@@ -20,6 +20,7 @@ export interface AppSchema {
modules: ModuleItemType[];
permission: `${PermissionTypeEnum}`;
inited?: boolean;
teamTags: string[];
}
export type AppListItemType = {
@@ -50,7 +51,7 @@ export type AppDetailType = AppSchema & {
// };
// Since useform cannot infer enumeration types, all enumeration keys can only be undone manually
export type AppSimpleEditFormType = {
templateId: string;
// templateId: string;
aiSettings: {
model: string;
systemPrompt?: string | undefined;
@@ -62,14 +63,14 @@ export type AppSimpleEditFormType = {
};
dataset: {
datasets: SelectedDatasetType;
similarity: number;
limit: number;
searchMode: `${DatasetSearchModeEnum}`;
usingReRank: boolean;
searchEmptyText: string;
};
cfr: {
background: string;
similarity?: number;
limit?: number;
usingReRank?: boolean;
searchEmptyText?: string;
datasetSearchUsingExtensionQuery?: boolean;
datasetSearchExtensionModel?: string;
datasetSearchExtensionBg?: string;
};
userGuide: {
welcomeText: string;
@@ -116,9 +117,6 @@ export type AppSimpleEditConfigTemplateType = {
usingReRank: boolean;
searchEmptyText?: boolean;
};
cfr?: {
background?: boolean;
};
userGuide?: {
welcomeText?: boolean;
variables?: boolean;

View File

@@ -6,9 +6,8 @@ import { getGuideModule, splitGuideModule } from '../module/utils';
import { ModuleItemType } from '../module/type.d';
import { DatasetSearchModeEnum } from '../dataset/constants';
export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEditFormType => {
export const getDefaultAppForm = (): AppSimpleEditFormType => {
return {
templateId,
aiSettings: {
model: 'gpt-3.5-turbo',
systemPrompt: '',
@@ -18,16 +17,15 @@ export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEd
quoteTemplate: '',
maxToken: 4000
},
cfr: {
background: ''
},
dataset: {
datasets: [],
similarity: 0.4,
limit: 1500,
searchEmptyText: '',
searchMode: DatasetSearchModeEnum.embedding,
usingReRank: false
usingReRank: false,
datasetSearchUsingExtensionQuery: true,
datasetSearchExtensionBg: ''
},
userGuide: {
welcomeText: '',
@@ -41,14 +39,8 @@ export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEd
};
/* format app modules to edit form */
export const appModules2Form = ({
templateId,
modules
}: {
modules: ModuleItemType[];
templateId: string;
}) => {
const defaultAppForm = getDefaultAppForm(templateId);
export const appModules2Form = ({ modules }: { modules: ModuleItemType[] }) => {
const defaultAppForm = getDefaultAppForm();
const findInputValueByKey = (inputs: FlowNodeInputItemType[], key: string) => {
return inputs.find((item) => item.key === key)?.value;
@@ -100,6 +92,18 @@ export const appModules2Form = ({
module.inputs,
ModuleInputKeyEnum.datasetSearchUsingReRank
);
defaultAppForm.dataset.datasetSearchUsingExtensionQuery = findInputValueByKey(
module.inputs,
ModuleInputKeyEnum.datasetSearchUsingExtensionQuery
);
defaultAppForm.dataset.datasetSearchExtensionModel = findInputValueByKey(
module.inputs,
ModuleInputKeyEnum.datasetSearchExtensionModel
);
defaultAppForm.dataset.datasetSearchExtensionBg = findInputValueByKey(
module.inputs,
ModuleInputKeyEnum.datasetSearchExtensionBg
);
// empty text
const emptyOutputs =
@@ -121,11 +125,6 @@ export const appModules2Form = ({
questionGuide: questionGuide,
tts: ttsConfig
};
} else if (module.flowType === FlowNodeTypeEnum.cfr) {
const value = module.inputs.find((item) => item.key === ModuleInputKeyEnum.aiSystemPrompt);
if (value) {
defaultAppForm.cfr.background = value.value;
}
}
});

View File

@@ -27,7 +27,8 @@ export enum ChatSourceEnum {
test = 'test',
online = 'online',
share = 'share',
api = 'api'
api = 'api',
team = 'team'
}
export const ChatSourceMap = {
[ChatSourceEnum.test]: {
@@ -41,6 +42,9 @@ export const ChatSourceMap = {
},
[ChatSourceEnum.api]: {
name: 'core.chat.logs.api'
},
[ChatSourceEnum.team]: {
name: 'core.chat.logs.team'
}
};

View File

@@ -4,6 +4,7 @@ import { ChatRoleEnum, ChatSourceEnum, ChatStatusEnum } from './constants';
import { FlowNodeTypeEnum } from '../module/node/constant';
import { ModuleOutputKeyEnum } from '../module/constants';
import { AppSchema } from '../app/type';
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
import { DatasetSearchModeEnum } from '../dataset/constants';
export type ChatSchema = {
@@ -72,6 +73,13 @@ export type ChatSiteItemType = ChatItemType & {
ttsBuffer?: Uint8Array;
};
/* --------- team chat --------- */
export type ChatAppListSchema = {
apps: AppType[];
teamInfo: teamInfoSchema;
uid?: string;
};
/* ---------- history ------------- */
export type HistoryItemType = {
chatId: string;
@@ -88,16 +96,16 @@ export type ChatHistoryItemType = HistoryItemType & {
export type moduleDispatchResType = {
// common
moduleLogo?: string;
price?: number;
runningTime?: number;
inputTokens?: number;
outputTokens?: number;
charsLength?: number;
model?: string;
query?: string;
contextTotalLen?: number;
textOutput?: string;
// bill
tokens?: number;
model?: string;
contextTotalLen?: number;
totalPoints?: number;
// chat
temperature?: number;
maxToken?: number;
@@ -109,6 +117,9 @@ export type moduleDispatchResType = {
limit?: number;
searchMode?: `${DatasetSearchModeEnum}`;
searchUsingReRank?: boolean;
extensionModel?: string;
extensionResult?: string;
extensionTokens?: number;
// cq
cqList?: ClassifyQuestionAgentItemType[];
@@ -119,7 +130,9 @@ export type moduleDispatchResType = {
extractResult?: Record<string, any>;
// http
params?: Record<string, any>;
body?: Record<string, any>;
headers?: Record<string, any>;
httpResult?: Record<string, any>;
// plugin output

View File

@@ -71,45 +71,29 @@ export const DatasetCollectionSyncResultMap = {
};
/* ------------ data -------------- */
export enum DatasetDataIndexTypeEnum {
chunk = 'chunk',
qa = 'qa',
summary = 'summary',
hypothetical = 'hypothetical',
custom = 'custom'
}
export const DatasetDataIndexTypeMap = {
[DatasetDataIndexTypeEnum.chunk]: {
name: 'dataset.data.indexes.chunk'
},
[DatasetDataIndexTypeEnum.summary]: {
name: 'dataset.data.indexes.summary'
},
[DatasetDataIndexTypeEnum.hypothetical]: {
name: 'dataset.data.indexes.hypothetical'
},
[DatasetDataIndexTypeEnum.qa]: {
name: 'dataset.data.indexes.qa'
},
[DatasetDataIndexTypeEnum.custom]: {
name: 'dataset.data.indexes.custom'
}
};
/* ------------ training -------------- */
export enum TrainingModeEnum {
chunk = 'chunk',
auto = 'auto',
qa = 'qa'
}
export const TrainingTypeMap = {
[TrainingModeEnum.chunk]: {
label: 'core.dataset.training.Chunk mode',
tooltip: 'core.dataset.import.Chunk Split Tip'
tooltip: 'core.dataset.import.Chunk Split Tip',
isPlus: true
},
[TrainingModeEnum.auto]: {
label: 'core.dataset.training.Auto mode',
tooltip: 'core.dataset.training.Auto mode Tip',
isPlus: true
},
[TrainingModeEnum.qa]: {
label: 'core.dataset.training.QA mode',
tooltip: 'core.dataset.import.QA Import Tip'
tooltip: 'core.dataset.import.QA Import Tip',
isPlus: true
}
};

View File

@@ -3,7 +3,6 @@ import { PermissionTypeEnum } from '../../support/permission/constant';
import { PushDatasetDataChunkProps } from './api';
import {
DatasetCollectionTypeEnum,
DatasetDataIndexTypeEnum,
DatasetStatusEnum,
DatasetTypeEnum,
SearchScoreTypeEnum,
@@ -64,7 +63,6 @@ export type DatasetCollectionSchemaType = {
export type DatasetDataIndexItemType = {
defaultIndex: boolean;
dataId: string; // pg data id
type: `${DatasetDataIndexTypeEnum}`;
text: string;
};
export type DatasetDataSchemaType = {
@@ -142,6 +140,7 @@ export type DatasetCollectionItemType = CollectionWithDatasetType & {
/* ================= data ===================== */
export type DatasetDataItemType = {
id: string;
teamId: string;
datasetId: string;
collectionId: string;
sourceName: string;
@@ -173,7 +172,7 @@ export type DatasetFileSchema = {
/* ============= search =============== */
export type SearchDataResponseItemType = Omit<
DatasetDataItemType,
'indexes' | 'isOwner' | 'canWrite'
'teamId' | 'indexes' | 'isOwner' | 'canWrite'
> & {
score: { type: `${SearchScoreTypeEnum}`; value: number; index: number }[];
// score: number;

View File

@@ -1,4 +1,4 @@
import { TrainingModeEnum, DatasetCollectionTypeEnum, DatasetDataIndexTypeEnum } from './constants';
import { TrainingModeEnum, DatasetCollectionTypeEnum } from './constants';
import { getFileIcon } from '../../common/file/icon';
import { strIsLink } from '../../common/string/tools';
@@ -41,7 +41,6 @@ export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: strin
const qaStr = `${q}\n${a}`.trim();
return {
defaultIndex: true,
type: a ? DatasetDataIndexTypeEnum.qa : DatasetDataIndexTypeEnum.chunk,
text: a ? qaStr : q,
dataId
};
@@ -49,5 +48,6 @@ export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: strin
export const predictDataLimitLength = (mode: `${TrainingModeEnum}`, data: any[]) => {
if (mode === TrainingModeEnum.qa) return data.length * 20;
if (mode === TrainingModeEnum.auto) return data.length * 5;
return data.length;
};

View File

@@ -1,14 +1,11 @@
import { VectorModelItemType } from '../ai/model.d';
import { DYNAMIC_INPUT_KEY } from './constants';
export type SelectedDatasetType = { datasetId: string; vectorModel: VectorModelItemType }[];
export type HttpBodyType<T = any> = {
appId: string;
chatId?: string;
responseChatItemId?: string;
variables: Record<string, any>;
data: T;
};
[DYNAMIC_INPUT_KEY]: Record<string, any>;
} & T;
export type HttpQueryType = {
appId: string;
chatId?: string;

View File

@@ -64,7 +64,9 @@ export enum ModuleInputKeyEnum {
datasetMaxTokens = 'limit',
datasetSearchMode = 'searchMode',
datasetSearchUsingReRank = 'usingReRank',
datasetParamsModal = 'datasetParamsModal',
datasetSearchUsingExtensionQuery = 'datasetSearchUsingExtensionQuery',
datasetSearchExtensionModel = 'datasetSearchExtensionModel',
datasetSearchExtensionBg = 'datasetSearchExtensionBg',
// context extract
contextExtractInput = 'content',
@@ -72,8 +74,10 @@ export enum ModuleInputKeyEnum {
// http
httpReqUrl = 'system_httpReqUrl',
httpHeader = 'system_httpHeader',
httpHeaders = 'system_httpHeader',
httpMethod = 'system_httpMethod',
httpParams = 'system_httpParams',
httpJsonBody = 'system_httpJsonBody',
abandon_httpUrl = 'url',
// app
@@ -85,9 +89,10 @@ export enum ModuleInputKeyEnum {
export enum ModuleOutputKeyEnum {
// common
responseData = 'responseData',
moduleDispatchBills = 'moduleDispatchBills',
userChatInput = 'userChatInput',
finish = 'finish',
responseData = 'responseData',
history = 'history',
answerText = 'answerText', // answer module text key
success = 'success',
@@ -111,17 +116,29 @@ export enum ModuleOutputKeyEnum {
export enum VariableInputEnum {
input = 'input',
textarea = 'textarea',
select = 'select'
select = 'select',
external = 'external'
}
export const variableMap = {
[VariableInputEnum.input]: {
icon: 'core/app/variable/input'
icon: 'core/app/variable/input',
title: 'core.module.variable.input type',
desc: ''
},
[VariableInputEnum.textarea]: {
icon: 'core/app/variable/textarea'
icon: 'core/app/variable/textarea',
title: 'core.module.variable.textarea type',
desc: '允许用户最多输入4000字的对话框。'
},
[VariableInputEnum.select]: {
icon: 'core/app/variable/select'
icon: 'core/app/variable/select',
title: 'core.module.variable.select type',
desc: ''
},
[VariableInputEnum.external]: {
icon: 'core/app/variable/external',
title: 'core.module.variable.External type',
desc: '可以通过API接口或分享链接的Query传递变量。增加该类型变量的主要目的是用于变量提示。使用例子: 你可以通过分享链接Query中拼接Token来实现内部系统身份鉴权。'
}
};

View File

@@ -20,9 +20,7 @@ export enum FlowNodeInputTypeEnum {
aiSettings = 'aiSettings',
// ai model select
selectChatModel = 'selectChatModel',
selectCQModel = 'selectCQModel',
selectExtractModel = 'selectExtractModel',
selectLLMModel = 'selectLLMModel',
// dataset special input
selectDataset = 'selectDataset',
@@ -53,11 +51,12 @@ export enum FlowNodeTypeEnum {
classifyQuestion = 'classifyQuestion',
contentExtract = 'contentExtract',
httpRequest = 'httpRequest',
httpRequest468 = 'httpRequest468',
runApp = 'app',
pluginModule = 'pluginModule',
pluginInput = 'pluginInput',
pluginOutput = 'pluginOutput',
cfr = 'cfr'
queryExtension = 'cfr'
// abandon
}

View File

@@ -2,15 +2,19 @@ import {
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../node/constant';
import { FlowModuleTemplateType } from '../../type';
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
} from '../../../node/constant';
import { FlowModuleTemplateType } from '../../../type';
import {
ModuleIOValueTypeEnum,
ModuleInputKeyEnum,
ModuleTemplateTypeEnum
} from '../../../constants';
import {
Input_Template_AddInputParam,
Input_Template_DynamicInput,
Input_Template_Switch
} from '../input';
import { Output_Template_AddOutput, Output_Template_Finish } from '../output';
} from '../../input';
import { Output_Template_AddOutput, Output_Template_Finish } from '../../output';
export const HttpModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.httpRequest,
@@ -18,7 +22,8 @@ export const HttpModule: FlowModuleTemplateType = {
flowType: FlowNodeTypeEnum.httpRequest,
avatar: '/imgs/module/http.png',
name: 'core.module.template.Http request',
intro: 'core.module.template.Http request intro',
intro:
'该Http模块已被弃用将于2024/3/31 不再提供服务。请尽快删除该模块并重新添加新的 Http 模块。',
showStatus: true,
inputs: [
Input_Template_Switch,
@@ -54,9 +59,10 @@ export const HttpModule: FlowModuleTemplateType = {
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.httpHeader,
key: ModuleInputKeyEnum.httpHeaders,
type: FlowNodeInputTypeEnum.JSONEditor,
valueType: ModuleIOValueTypeEnum.string,
value: '',
label: 'core.module.input.label.Http Request Header',
description: 'core.module.input.description.Http Request Header',
placeholder: 'core.module.input.description.Http Request Header',

View File

@@ -31,7 +31,7 @@ export const AiChatModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectChatModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
label: 'core.module.input.label.aiModel',
required: true,
valueType: ModuleIOValueTypeEnum.string,

View File

@@ -24,7 +24,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectCQModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
valueType: ModuleIOValueTypeEnum.string,
label: 'core.module.input.label.Classify model',
required: true,

View File

@@ -24,7 +24,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectExtractModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
valueType: ModuleIOValueTypeEnum.string,
label: 'core.module.input.label.LLM',
required: true,
@@ -57,7 +57,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
{
key: ModuleInputKeyEnum.extractKeys,
type: FlowNodeInputTypeEnum.custom,
label: '目标字段',
label: '',
valueType: ModuleIOValueTypeEnum.any,
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
value: [], // {desc: string; key: string; required: boolean; enum: string[]}[]
@@ -76,6 +76,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
{
key: ModuleOutputKeyEnum.failed,
label: '提取字段缺失',
description: '存在一个或多个字段未提取成功。尽管使用了默认值也算缺失。',
valueType: ModuleIOValueTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
targets: []

View File

@@ -37,17 +37,10 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
},
{
key: ModuleInputKeyEnum.datasetSimilarity,
type: FlowNodeInputTypeEnum.hidden,
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
label: '',
value: 0.4,
valueType: ModuleIOValueTypeEnum.number,
min: 0,
max: 1,
step: 0.01,
markList: [
{ label: '0', value: 0 },
{ label: '1', value: 1 }
],
showTargetInApp: false,
showTargetInPlugin: false
},
@@ -79,13 +72,31 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
value: false
},
{
key: ModuleInputKeyEnum.datasetParamsModal,
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
key: ModuleInputKeyEnum.datasetSearchUsingExtensionQuery,
type: FlowNodeInputTypeEnum.hidden,
label: '',
valueType: ModuleIOValueTypeEnum.any,
valueType: ModuleIOValueTypeEnum.boolean,
showTargetInApp: false,
showTargetInPlugin: false,
value: true
},
{
key: ModuleInputKeyEnum.datasetSearchExtensionModel,
type: FlowNodeInputTypeEnum.hidden,
label: '',
valueType: ModuleIOValueTypeEnum.string,
showTargetInApp: false,
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.datasetSearchExtensionBg,
type: FlowNodeInputTypeEnum.hidden,
label: '',
valueType: ModuleIOValueTypeEnum.string,
showTargetInApp: false,
showTargetInPlugin: false,
value: ''
},
Input_Template_UserChatInput
],
outputs: [

View File

@@ -0,0 +1,120 @@
import {
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../node/constant';
import { FlowModuleTemplateType } from '../../type';
import {
DYNAMIC_INPUT_KEY,
ModuleIOValueTypeEnum,
ModuleInputKeyEnum,
ModuleTemplateTypeEnum
} from '../../constants';
import {
Input_Template_AddInputParam,
Input_Template_DynamicInput,
Input_Template_Switch
} from '../input';
import { Output_Template_AddOutput, Output_Template_Finish } from '../output';
export const HttpModule468: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.httpRequest468,
templateType: ModuleTemplateTypeEnum.externalCall,
flowType: FlowNodeTypeEnum.httpRequest468,
avatar: '/imgs/module/http.png',
name: 'core.module.template.Http request',
intro: 'core.module.template.Http request intro',
showStatus: true,
inputs: [
Input_Template_Switch,
{
key: ModuleInputKeyEnum.httpMethod,
type: FlowNodeInputTypeEnum.custom,
valueType: ModuleIOValueTypeEnum.string,
label: '',
value: 'POST',
required: true,
showTargetInApp: false,
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.httpReqUrl,
type: FlowNodeInputTypeEnum.hidden,
valueType: ModuleIOValueTypeEnum.string,
label: '',
description: 'core.module.input.description.Http Request Url',
placeholder: 'https://api.ai.com/getInventory',
required: false,
showTargetInApp: false,
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.httpHeaders,
type: FlowNodeInputTypeEnum.custom,
valueType: ModuleIOValueTypeEnum.any,
value: [],
label: '',
description: 'core.module.input.description.Http Request Header',
placeholder: 'core.module.input.description.Http Request Header',
required: false,
showTargetInApp: false,
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.httpParams,
type: FlowNodeInputTypeEnum.hidden,
valueType: ModuleIOValueTypeEnum.any,
value: [],
label: '',
required: false,
showTargetInApp: false,
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.httpJsonBody,
type: FlowNodeInputTypeEnum.hidden,
valueType: ModuleIOValueTypeEnum.any,
value: '',
label: '',
required: false,
showTargetInApp: false,
showTargetInPlugin: false
},
Input_Template_DynamicInput,
{
...Input_Template_AddInputParam,
editField: {
key: true,
description: true,
required: true,
dataType: true
},
defaultEditField: {
label: '',
key: '',
description: '',
inputType: FlowNodeInputTypeEnum.target,
valueType: ModuleIOValueTypeEnum.string,
required: true
}
}
],
outputs: [
Output_Template_Finish,
{
...Output_Template_AddOutput,
editField: {
key: true,
description: true,
dataType: true
},
defaultEditField: {
label: '',
key: '',
description: '',
outputType: FlowNodeOutputTypeEnum.source,
valueType: ModuleIOValueTypeEnum.string
}
}
]
};

View File

@@ -3,7 +3,7 @@ import {
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../node/constant';
import { FlowModuleTemplateType } from '../../type.d';
import { FlowModuleTemplateType } from '../../type';
import {
ModuleIOValueTypeEnum,
ModuleInputKeyEnum,
@@ -17,19 +17,19 @@ import {
} from '../input';
import { Output_Template_UserChatInput } from '../output';
export const AiCFR: FlowModuleTemplateType = {
export const AiQueryExtension: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.chatNode,
templateType: ModuleTemplateTypeEnum.tools,
flowType: FlowNodeTypeEnum.cfr,
templateType: ModuleTemplateTypeEnum.other,
flowType: FlowNodeTypeEnum.queryExtension,
avatar: '/imgs/module/cfr.svg',
name: 'core.module.template.cfr',
intro: 'core.module.template.cfr intro',
name: 'core.module.template.Query extension',
intro: 'core.module.template.Query extension intro',
showStatus: true,
inputs: [
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectExtractModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
label: 'core.module.input.label.aiModel',
required: true,
valueType: ModuleIOValueTypeEnum.string,
@@ -39,11 +39,11 @@ export const AiCFR: FlowModuleTemplateType = {
{
key: ModuleInputKeyEnum.aiSystemPrompt,
type: FlowNodeInputTypeEnum.textarea,
label: 'core.module.input.label.cfr background',
label: 'core.app.edit.Query extension background prompt',
max: 300,
valueType: ModuleIOValueTypeEnum.string,
description: 'core.app.edit.cfr background tip',
placeholder: 'core.module.input.placeholder.cfr background',
description: 'core.app.edit.Query extension background tip',
placeholder: 'core.module.QueryExtension.placeholder',
showTargetInApp: true,
showTargetInPlugin: true
},
@@ -54,7 +54,8 @@ export const AiCFR: FlowModuleTemplateType = {
Output_Template_UserChatInput,
{
key: ModuleOutputKeyEnum.text,
label: 'core.module.output.label.cfr result',
label: 'core.module.output.label.query extension result',
description: 'core.module.output.description.query extension result',
valueType: ModuleIOValueTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
targets: []

View File

@@ -6,7 +6,6 @@ export const RunPluginModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.pluginModule,
templateType: ModuleTemplateTypeEnum.externalCall,
flowType: FlowNodeTypeEnum.pluginModule,
avatar: '',
intro: '',
name: '',
showStatus: false,

View File

@@ -1,6 +1,14 @@
import { FlowNodeTypeEnum } from './node/constant';
import { ModuleIOValueTypeEnum, ModuleTemplateTypeEnum, VariableInputEnum } from './constants';
import {
ModuleIOValueTypeEnum,
ModuleOutputKeyEnum,
ModuleTemplateTypeEnum,
VariableInputEnum
} from './constants';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
import { UserModelSchema } from 'support/user/type';
import { moduleDispatchResType } from '..//chat/type';
import { ChatModuleUsageType } from '../../support/wallet/bill/type';
export type FlowModuleTemplateType = {
id: string; // module id, unique
@@ -72,6 +80,7 @@ export type ContextExtractAgentItemType = {
desc: string;
key: string;
required: boolean;
defaultValue?: string;
enum?: string;
};
@@ -105,7 +114,7 @@ export type ChatDispatchProps = {
mode: 'test' | 'chat';
teamId: string;
tmbId: string;
user: UserType;
user: UserModelSchema;
appId: string;
chatId?: string;
responseChatItemId?: string;
@@ -116,7 +125,10 @@ export type ChatDispatchProps = {
};
export type ModuleDispatchProps<T> = ChatDispatchProps & {
outputs: RunningModuleItemType['outputs'];
inputs: RunningModuleItemType['inputs'];
module: RunningModuleItemType;
params: T;
};
export type ModuleDispatchResponse<T> = T & {
[ModuleOutputKeyEnum.responseData]?: moduleDispatchResType;
[ModuleOutputKeyEnum.moduleDispatchBills]?: ChatModuleUsageType[];
};

View File

@@ -1,6 +1,5 @@
export type OpenApiSchema = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
@@ -8,9 +7,9 @@ export type OpenApiSchema = {
apiKey: string;
appId?: string;
name: string;
usage: number;
usagePoints: number;
limit?: {
expiredTime?: Date;
credit?: number;
maxUsagePoints: number;
};
};

View File

@@ -1,5 +1,5 @@
import type { HistoryItemType, ChatSiteItemType } from '../../core/chat/type.d';
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
import { OutLinkSchema } from './type.d';
export type AuthOutLinkInitProps = {
outLinkUid: string;

View File

@@ -1,3 +1,4 @@
import { AppSchema } from 'core/app/type';
import { OutLinkTypeEnum } from './constant';
export type OutLinkSchema = {
@@ -7,17 +8,20 @@ export type OutLinkSchema = {
tmbId: string;
appId: string;
name: string;
total: number;
usagePoints: number;
lastTime: Date;
type: `${OutLinkTypeEnum}`;
responseDetail: boolean;
limit?: {
expiredTime?: Date;
QPM: number;
credit: number;
maxUsagePoints: number;
hookUrl?: string;
};
};
export type OutLinkWithAppType = Omit<OutLinkSchema, 'appId'> & {
appId: AppSchema;
};
export type OutLinkEditType = {
_id?: string;

View File

@@ -0,0 +1,9 @@
type ShareChatAuthProps = {
shareId?: string;
outLinkUid?: string;
};
type TeamChatAuthProps = {
teamId?: string;
teamToken?: string;
};
export type OutLinkChatAuthProps = ShareChatAuthProps & TeamChatAuthProps;

View File

@@ -2,7 +2,8 @@ export enum AuthUserTypeEnum {
token = 'token',
root = 'root',
apikey = 'apikey',
outLink = 'outLink'
outLink = 'outLink',
teamDomain = 'teamDomain'
}
export enum PermissionTypeEnum {

View File

@@ -1,7 +1,6 @@
import { AuthUserTypeEnum } from './constant';
export type AuthResponseType = {
userId: string;
teamId: string;
tmbId: string;
isOwner: boolean;

View File

@@ -10,7 +10,11 @@ export type OauthLoginProps = {
code: string;
callbackUrl: string;
inviterId?: string;
tmbId?: string;
};
export type WxLoginProps = {
inviterId?: string;
code: string;
};
export type FastLoginProps = {

View File

@@ -0,0 +1,11 @@
export enum UserAuthTypeEnum {
register = 'register',
findPassword = 'findPassword',
wxLogin = 'wxLogin'
}
export const userAuthTypeMap = {
[UserAuthTypeEnum.register]: 'register',
[UserAuthTypeEnum.findPassword]: 'findPassword',
[UserAuthTypeEnum.wxLogin]: 'wxLogin'
};

Some files were not shown because too many files have changed in this diff Show More