Update laf module document (#1154)

* Yjl (#74)

* FIX: Query Extension 历史记录拼接不正确 (#1144)

* FIX: Query Extension 历史记录拼接不正确

* add .text

* fix: tts modal close and rerank doc

* laf doc

---------

Co-authored-by: Hexiao Zhang <731931282qq@gmail.com>

* update emb script

* feat: add route push to laf params

* perf: logo size

* README

* README

* laf doc icon

---------

Co-authored-by: Hexiao Zhang <731931282qq@gmail.com>
This commit is contained in:
Archer
2024-04-09 00:15:04 +08:00
committed by GitHub
parent 1fbc407ecf
commit adfad8ff7f
11 changed files with 91 additions and 67 deletions

34
.github/imgs/logo.svg vendored
View File

@@ -1,14 +1,20 @@
<svg width="32" height="32" viewBox="0 0 1041 1348" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M340.837 0.33933L681.068 0.338989V0.455643C684.032 0.378397 686.999 0.339702 689.967 0.339702C735.961 0.3397 781.504 9.62899 823.997 27.6772C866.49 45.7254 905.099 72.1791 937.622 105.528C970.144 138.877 995.942 178.467 1013.54 222.04C1031.14 265.612 1040.2 312.312 1040.2 359.474L340.836 359.474L340.836 1347.84C296.157 1347.84 251.914 1338.55 210.636 1320.49C169.357 1302.43 131.85 1275.95 100.257 1242.58C68.6636 1209.21 43.6023 1169.59 26.5041 1125.99C11.3834 1087.43 2.75216 1046.42 0.957956 1004.81H0.605869L0.605897 368.098H0.70363C0.105752 341.831 2.23741 315.443 7.14306 289.411C20.2709 219.745 52.6748 155.754 100.257 105.528C147.839 55.3017 208.462 21.0975 274.461 7.24017C296.426 2.62833 318.657 0.339101 340.837 0.33933Z" fill="url(#paint0_linear_1172_228)"/>
<path d="M633.639 904.645H513.029V576.37H635.422V576.377C678.161 576.607 720.454 585.093 759.951 601.37C799.997 617.874 836.384 642.064 867.033 672.559C897.683 703.054 921.996 739.257 938.583 779.101C955.171 818.944 963.709 861.648 963.709 904.775H633.639V904.645Z" fill="url(#paint1_linear_1172_228)"/>
<defs>
<linearGradient id="paint0_linear_1172_228" x1="520.404" y1="0.338989" x2="520.404" y2="1347.84" gradientUnits="userSpaceOnUse">
<stop stop-color="#326DFF"/>
<stop offset="1" stop-color="#8EAEFF"/>
</linearGradient>
<linearGradient id="paint1_linear_1172_228" x1="738.369" y1="576.37" x2="738.369" y2="904.775" gradientUnits="userSpaceOnUse">
<stop stop-color="#326DFF"/>
<stop offset="1" stop-color="#8EAEFF"/>
</linearGradient>
</defs>
</svg>
<svg width="49" height="48" viewBox="0 0 49 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M20.3692 7.00001L28.9536 7V7.00294C29.0284 7.00099 29.1033 7.00002 29.1782 7.00002C30.3387 7.00002 31.4878 7.2344 32.5599 7.68979C33.6321 8.14518 34.6062 8.81265 35.4268 9.6541C36.2474 10.4956 36.8983 11.4945 37.3424 12.5939C37.7865 13.6933 38.0151 14.8716 38.0151 16.0616L20.3691 16.0616L20.3691 41C19.2418 41 18.1255 40.7655 17.084 40.3097C16.0425 39.854 15.0961 39.1861 14.299 38.344C13.5018 37.502 12.8695 36.5024 12.4381 35.4022C12.0566 34.4292 11.8388 33.3945 11.7935 32.3446H11.7846L11.7846 16.2792H11.7871C11.772 15.6165 11.8258 14.9506 11.9496 14.2938C12.2808 12.536 13.0984 10.9214 14.299 9.6541C15.4995 8.38681 17.0291 7.52377 18.6944 7.17413C19.2486 7.05776 19.8095 7 20.3692 7.00001Z"
fill="url(#paint0_linear_1008_3495)" />
<path
d="M27.7569 29.8173H24.7138V21.5343H27.8019V21.5345C28.8803 21.5403 29.9474 21.7544 30.944 22.1651C31.9544 22.5815 32.8725 23.1919 33.6458 23.9613C34.4191 24.7308 35.0326 25.6442 35.4511 26.6496C35.8696 27.6549 36.085 28.7324 36.085 29.8205H27.7569V29.8173Z"
fill="url(#paint1_linear_1008_3495)" />
<defs>
<linearGradient id="paint0_linear_1008_3495" x1="24.8999" y1="7" x2="24.8999" y2="41"
gradientUnits="userSpaceOnUse">
<stop stop-color="#326DFF" />
<stop offset="1" stop-color="#8EAEFF" />
</linearGradient>
<linearGradient id="paint1_linear_1008_3495" x1="30.3994" y1="21.5343" x2="30.3994" y2="29.8205"
gradientUnits="userSpaceOnUse">
<stop stop-color="#326DFF" />
<stop offset="1" stop-color="#8EAEFF" />
</linearGradient>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -38,8 +38,6 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
- 🌍 海外版:[fastgpt.in](https://fastgpt.in/)
fastgpt.run 域名会弃用。
| | |
| ---------------------------------- | ---------------------------------- |
| ![Demo](./.github/imgs/intro1.png) | ![Demo](./.github/imgs/intro2.png) |
@@ -53,23 +51,21 @@ fastgpt.run 域名会弃用。
`1` 应用编排能力
- [x] 提供简易模式,无需操作编排
- [x] 对话下一步指引
- [x] 工作流编排
- [x] 源文件引用追踪
- [x] 模块封装,实现多级复用
- [x] 混合检索 & 重排
- [x] Tool 模块
- [ ] 嵌入 [Laf](https://github.com/labring/laf),实现在线编写 HTTP 模块
- [ ] 嵌入 [Laf](https://github.com/labring/laf),实现在线编写 HTTP 模块。初版已完成。
- [ ] 插件封装功能,支持低代码渲染
`2` 知识库能力
- [x] 多库复用,混用
- [x] chunk 记录修改和删除
- [x] 支持知识库单独设置向量模型
- [x] 源文件存储
- [x] 支持手动输入直接分段QA 拆分导入
- [x] 支持txtmdhtmlpdfdocxpptxcsvxlsx (有需要更多可 PR file loader)
- [x] 支持 txtmdhtmlpdfdocxpptxcsvxlsx (有需要更多可 PR file loader)
- [x] 支持 url 读取、CSV 批量导入
- [x] 混合检索 & 重排
- [ ] 支持文件阅读器
- [ ] 更多的数据预处理方案
@@ -90,6 +86,8 @@ fastgpt.run 域名会弃用。
- [x] Iframe 一键嵌入
- [x] 聊天窗口嵌入支持自定义 Icon默认打开拖拽等功能
- [x] 统一查阅对话记录,并对数据进行标注
`6` 其他
- [x] 支持语音输入和输出 (可配置语音输入语音回答)
<a href="#readme">
<img src="https://img.shields.io/badge/-返回顶部-7d09f1.svg" alt="#" align="right">

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -31,9 +31,9 @@ weight: 910
3 个模型代码分别为:
1. [https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-base](https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-base)
2. [https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-large](https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-large)
3. [https://github.com/labring/FastGPT/tree/main/python/reranker/bge-rerank-v2-m3](https://github.com/labring/FastGPT/tree/main/python/reranker/bge-rerank-v2-m3)
1. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-base](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-base)
2. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-large](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-large)
3. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-rerank-v2-m3](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-rerank-v2-m3)
### 3. 安装依赖

View File

@@ -1,59 +1,53 @@
---
title: "Laf 函数调用"
description: "FastGPT Laf 函数调用模块介绍"
icon: "Laf"
icon: "code"
draft: false
toc: true
weight: 355
---
## 特点
- 可重复添加
- 有外部输入
- 手动配置
- 触发执行
- 核中核模块
![](/imgs/laf1.webp)
## 介绍
Laf 函数调用模块可以调用 Laf 账号下的云函数,其操作与 HTTP 模块相同,可以理解为封装了请求 Laf 云函数的 http 模块,值得注意的不同之处为
`Laf 函数调用`模块可以调用 Laf 账号下的云函数,其工作原理与 HTTP 模块相同,有以下特殊特征
- 只能使用 POST 请求
- 请求自带系统参数 systemParams
- 请求自带系统参数 systemParams,无需通过变量传递。
## 具体使用
## 绑定 Laf 账号
调用 Laf 云函数,首先需要绑定 Laf 账号和应用,并且在应用中创建云函数。
要调用 Laf 云函数,首先需要绑定 Laf 账号和应用,并且在应用中创建云函数。
Laf 提供了 PAT(访问凭证) 来实现 Laf 平台外的快捷登录,可以访问 [Laf 文档](https://doc.Laf.run/zh/cli/#%E7%99%BB%E5%BD%95)查看详细如何获取 PAT。
在获取到 PAT 后,我们可以进入 fastgpt 的账号页或是直接在高级编排中使用 Laf 模块,填入 PAT 验证后,选择需要绑定的应用(应用需要是 Running 状态),即可调用 Laf 云函数
在获取到 PAT 后,我们可以进入 FastGPT 的`账号页`或是在高级编排中`Laf模块` 对 Laf 账号进行绑定。Laf 账号是团队共享的,仅团队管理员可配置
填入 PAT 验证后,选择需要绑定的应用(应用需要是 Running 状态),即可调用该应用下的云函数。
> 如果需要解绑则取消绑定后,点击“更新”即可
![](/imgs/laf2.webp)
为了更便捷地调用 Laf 云函数,可以参照下面的代码编写云函数,以便 openAPI 识别
## 编写云函数
Laf 云函数拥有根据 interface 自动生成 OpenAPI 的能力,可以参照下面的代码编写云函数,以便自动生成 OpenAPI 文档。
`Laf模块`可以根据 OpenAPI 文档,自动识别出入参,无需手动添加数据类型。如果不会写 TS可忽略手动在 FastGPT 中添加参数即可。
```ts
import cloud from '@Lafjs/cloud'
import cloud from '@lafjs/cloud'
interface IRequestBody {
username: string // 用户名
passwd?: string // 密码
interface IRequestBody { // 自定义入参FastGPT 传入的均为POST请求。
data1: string // 必填参数
data2?: string // 可选参数
}
interface IResponse {
message: string // 返回信息
data: any // 返回数据
}
type extendedBody = IRequestBody & {
systemParams?: {
appId: string,
interface RequestProps extends IRequestBody { // 完整入参,这个无需改动。
systemParams: { // 这是FastGPT默认会传递过来的参数
appId: string,
variables: string,
histories: string,
cTime: string,
@@ -62,27 +56,45 @@ type extendedBody = IRequestBody & {
}
}
interface IResponse { // 响应内容
message: string // 必返回的参数
msg?: string; // 可选的返回参数
}
export default async function (ctx: FunctionContext): Promise<IResponse> {
const body: extendedBody = ctx.body;
const {
data1,
data2,
systemParams
}: RequestProps = ctx.body;
console.log(body.systemParams.chatId);
console.log({
data1,
data2,
systemParams
});
return {
message: 'ok',
data: '查找到用户名为' + body.username + '的用户'
msg: 'msg'
};
}
```
当然,你也可以在 Laf 平台上选择 fastgpt_template快速生成该函数模板。
具体操作可以是,进入 Laf 的函数页面,新建函数(注意 fastgpt 只会调用 post 请求的函数然后复制上面的代码或者点击更多模板搜索“fastgpt”使用下面的模板
![](/imgs/laf3.webp)
这样就能直接通过点击“同步参数”,一键填写输入输出
## FastGPT 中使用
![](/imgs/laf4.webp)
在选择函数后,可以通过点击“同步参数”,自动同步云函数的参数到 FastGPT 中。当然也可以手动添加,手动修改后的参数不会被“同步参数”修改。
当然也可以手动添加,手动修改后的参数不会被“同步参数”修改
![](/imgs/laf4.png)
## 作用
Laf 账号是绑定在团队上的,团队的成员可以轻松调用已经编写好的云函数
## 使用注意事项
### 调用报错
先在 laf 中调试函数,看是否正常调用。可以通过 console.log打印入参将入参放在 Laf 测试页面的 Body 中进行测试。

View File

@@ -72,6 +72,11 @@ const TTSSelect = ({
[audioSpeechModelList, onChange, value]
);
const onCloseTTSModal = useCallback(() => {
cancelAudio();
onClose();
}, [cancelAudio, onClose]);
return (
<Flex alignItems={'center'}>
<MyIcon name={'core/app/simpleMode/tts'} mr={2} w={'20px'} />
@@ -100,7 +105,7 @@ const TTSSelect = ({
</>
}
isOpen={isOpen}
onClose={onClose}
onClose={onCloseTTSModal}
w={'500px'}
>
<ModalBody px={[5, 16]} py={[4, 8]}>

View File

@@ -232,7 +232,7 @@ const NodeLaf = (props: NodeProps<FlowModuleItemType>) => {
);
if (!lafFunction) return;
const url = `${feConfigs.lafEnv}/app/${lafData?.lafApp?.appid}/function${lafFunction?.path}`;
const url = `${feConfigs.lafEnv}/app/${lafData?.lafApp?.appid}/function${lafFunction?.path}?templateid=fastgptflow`;
window.open(url, '_blank');
}}
>

View File

@@ -13,6 +13,7 @@ import { useUserStore } from '@/web/support/user/useUserStore';
import type { LafAccountType } from '@fastgpt/global/support/user/team/type.d';
import { postLafPat2Token, getLafApplications } from '@/web/support/laf/api';
import { getErrText } from '@fastgpt/global/common/error/utils';
import { getDocPath } from '@/web/common/system/doc';
const LafAccountModal = ({
defaultData = {
@@ -100,7 +101,7 @@ const LafAccountModal = ({
<Box fontSize={'sm'} color={'myGray.500'}>
<Box>{t('support.user.Laf account intro')}</Box>
<Box textDecoration={'underline'}>
<Link href={`https://doc.laf.run/zh/`} isExternal>
<Link href={getDocPath('/docs/workflow/modules/laf/')} isExternal>
{t('support.user.Laf account course')}
</Link>
</Box>
@@ -171,12 +172,14 @@ const LafAccountModal = ({
)}
</ModalBody>
<ModalFooter>
<Button mr={3} variant={'whiteBase'} onClick={onClose}>
<Button variant={'whiteBase'} onClick={onClose}>
{t('common.Close')}
</Button>
<Button isLoading={isUpdating} onClick={handleSubmit((data) => onSubmit(data))}>
{t('common.Update')}
</Button>
{appid && (
<Button ml={3} isLoading={isUpdating} onClick={handleSubmit((data) => onSubmit(data))}>
{t('common.Update')}
</Button>
)}
</ModalFooter>
</MyModal>
);

View File

@@ -102,7 +102,7 @@ const SelectUsingWayModal = ({ share, onClose }: { share: OutLinkSchema; onClose
data-open-icon="${getValues('scriptOpenIcon')}"
data-close-icon="${getValues('scriptCloseIcon')}"
defer
/>
></script>
<script>
console.log("Chat box loaded")
</script>`

View File

@@ -80,7 +80,7 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
alignItems={'center'}
justifyContent={'center'}
>
<Image src={LOGO_ICON} w={'24px'} alt={'icon'} />
<Image src={LOGO_ICON} w={['24px', '28px']} alt={'icon'} />
</Flex>
<Box ml={3} fontSize={['2xl', '3xl']} fontWeight={'bold'}>
{feConfigs?.systemTitle}