Skip to content

Commit adfad8f

Browse files
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 <[email protected]> * update emb script * feat: add route push to laf params * perf: logo size * README * README * laf doc icon --------- Co-authored-by: Hexiao Zhang <[email protected]>
1 parent 1fbc407 commit adfad8f

File tree

11 files changed

+91
-67
lines changed

11 files changed

+91
-67
lines changed

.github/imgs/logo.svg

Lines changed: 20 additions & 14 deletions
Loading

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
3838

3939
- 🌍 海外版:[fastgpt.in](https://fastgpt.in/)
4040

41-
fastgpt.run 域名会弃用。
42-
4341
| | |
4442
| ---------------------------------- | ---------------------------------- |
4543
| ![Demo](./.github/imgs/intro1.png) | ![Demo](./.github/imgs/intro2.png) |
@@ -53,23 +51,21 @@ fastgpt.run 域名会弃用。
5351

5452
`1` 应用编排能力
5553
- [x] 提供简易模式,无需操作编排
56-
- [x] 对话下一步指引
5754
- [x] 工作流编排
5855
- [x] 源文件引用追踪
5956
- [x] 模块封装,实现多级复用
60-
- [x] 混合检索 & 重排
6157
- [x] Tool 模块
62-
- [ ] 嵌入 [Laf](https://github.com/labring/laf),实现在线编写 HTTP 模块
58+
- [ ] 嵌入 [Laf](https://github.com/labring/laf),实现在线编写 HTTP 模块。初版已完成。
6359
- [ ] 插件封装功能,支持低代码渲染
6460

6561
`2` 知识库能力
6662
- [x] 多库复用,混用
6763
- [x] chunk 记录修改和删除
68-
- [x] 支持知识库单独设置向量模型
6964
- [x] 源文件存储
7065
- [x] 支持手动输入,直接分段,QA 拆分导入
71-
- [x] 支持txt,md,html,pdf,docx,pptx,csv,xlsx (有需要更多可 PR file loader)
66+
- [x] 支持 txt,md,html,pdf,docx,pptx,csv,xlsx (有需要更多可 PR file loader)
7267
- [x] 支持 url 读取、CSV 批量导入
68+
- [x] 混合检索 & 重排
7369
- [ ] 支持文件阅读器
7470
- [ ] 更多的数据预处理方案
7571

@@ -90,6 +86,8 @@ fastgpt.run 域名会弃用。
9086
- [x] Iframe 一键嵌入
9187
- [x] 聊天窗口嵌入支持自定义 Icon,默认打开,拖拽等功能
9288
- [x] 统一查阅对话记录,并对数据进行标注
89+
`6` 其他
90+
- [x] 支持语音输入和输出 (可配置语音输入语音回答)
9391

9492
<a href="#readme">
9593
<img src="https://img.shields.io/badge/-返回顶部-7d09f1.svg" alt="#" align="right">

docSite/assets/imgs/laf4.png

89.4 KB
Loading

docSite/assets/imgs/laf4.webp

-23.6 KB
Binary file not shown.

docSite/content/docs/development/custom-models/bge-rerank.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ weight: 910
3131

3232
3 个模型代码分别为:
3333

34-
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)
35-
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)
36-
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)
34+
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)
35+
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)
36+
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)
3737

3838
### 3. 安装依赖
3939

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,53 @@
11
---
22
title: "Laf 函数调用"
33
description: "FastGPT Laf 函数调用模块介绍"
4-
icon: "Laf"
4+
icon: "code"
55
draft: false
66
toc: true
77
weight: 355
88
---
99

10-
## 特点
11-
12-
- 可重复添加
13-
- 有外部输入
14-
- 手动配置
15-
- 触发执行
16-
- 核中核模块
1710

1811
![](/imgs/laf1.webp)
1912

2013
## 介绍
2114

22-
Laf 函数调用模块可以调用 Laf 账号下的云函数,其操作与 HTTP 模块相同,可以理解为封装了请求 Laf 云函数的 http 模块,值得注意的不同之处为
15+
`Laf 函数调用`模块可以调用 Laf 账号下的云函数,其工作原理与 HTTP 模块相同,有以下特殊特征
2316

2417
- 只能使用 POST 请求
25-
- 请求自带系统参数 systemParams
18+
- 请求自带系统参数 systemParams,无需通过变量传递。
2619

27-
## 具体使用
20+
## 绑定 Laf 账号
2821

29-
要能调用 Laf 云函数,首先需要绑定 Laf 账号和应用,并且在应用中创建云函数。
22+
要调用 Laf 云函数,首先需要绑定 Laf 账号和应用,并且在应用中创建云函数。
3023

3124
Laf 提供了 PAT(访问凭证) 来实现 Laf 平台外的快捷登录,可以访问 [Laf 文档](https://doc.Laf.run/zh/cli/#%E7%99%BB%E5%BD%95)查看详细如何获取 PAT。
3225

33-
在获取到 PAT 后,我们可以进入 fastgpt 的账号页或是直接在高级编排中使用 Laf 模块,填入 PAT 验证后,选择需要绑定的应用(应用需要是 Running 状态),即可调用 Laf 云函数。
26+
在获取到 PAT 后,我们可以进入 FastGPT 的`账号页`或是在高级编排中的 `Laf模块` 对 Laf 账号进行绑定。Laf 账号是团队共享的,仅团队管理员可配置。
27+
28+
填入 PAT 验证后,选择需要绑定的应用(应用需要是 Running 状态),即可调用该应用下的云函数。
3429

3530
> 如果需要解绑则取消绑定后,点击“更新”即可
3631
3732
![](/imgs/laf2.webp)
3833

39-
为了更便捷地调用 Laf 云函数,可以参照下面的代码编写云函数,以便 openAPI 识别
34+
## 编写云函数
4035

41-
```ts
42-
import cloud from '@Lafjs/cloud'
36+
Laf 云函数拥有根据 interface 自动生成 OpenAPI 的能力,可以参照下面的代码编写云函数,以便自动生成 OpenAPI 文档。
4337

44-
interface IRequestBody {
45-
username: string // 用户名
46-
passwd?: string // 密码
47-
}
38+
`Laf模块`可以根据 OpenAPI 文档,自动识别出入参,无需手动添加数据类型。如果不会写 TS,可忽略,手动在 FastGPT 中添加参数即可。
39+
40+
```ts
41+
import cloud from '@lafjs/cloud'
4842

49-
interface IResponse {
50-
message: string // 返回信息
51-
data: any // 返回数据
43+
interface IRequestBody { // 自定义入参,FastGPT 传入的均为POST请求。
44+
data1: string // 必填参数
45+
data2?: string // 可选参数
5246
}
5347

54-
type extendedBody = IRequestBody & {
55-
systemParams?: {
56-
appId: string,
48+
interface RequestProps extends IRequestBody { // 完整入参,这个无需改动。
49+
systemParams: { // 这是FastGPT默认会传递过来的参数
50+
appId: string,
5751
variables: string,
5852
histories: string,
5953
cTime: string,
@@ -62,27 +56,45 @@ type extendedBody = IRequestBody & {
6256
}
6357
}
6458

59+
interface IResponse { // 响应内容
60+
message: string // 必返回的参数
61+
msg?: string; // 可选的返回参数
62+
}
63+
6564
export default async function (ctx: FunctionContext): Promise<IResponse> {
66-
const body: extendedBody = ctx.body;
65+
const {
66+
data1,
67+
data2,
68+
systemParams
69+
}: RequestProps = ctx.body;
6770

68-
console.log(body.systemParams.chatId);
71+
console.log({
72+
data1,
73+
data2,
74+
systemParams
75+
});
6976

7077
return {
7178
message: 'ok',
72-
data: '查找到用户名为' + body.username + '的用户'
79+
msg: 'msg'
7380
};
7481
}
7582
```
7683

84+
当然,你也可以在 Laf 平台上选择 fastgpt_template,快速生成该函数模板。
85+
7786
具体操作可以是,进入 Laf 的函数页面,新建函数(注意 fastgpt 只会调用 post 请求的函数),然后复制上面的代码或者点击更多模板搜索“fastgpt”,使用下面的模板
7887

7988
![](/imgs/laf3.webp)
8089

81-
这样就能直接通过点击“同步参数”,一键填写输入输出
90+
## FastGPT 中使用
91+
92+
在选择函数后,可以通过点击“同步参数”,自动同步云函数的参数到 FastGPT 中。当然也可以手动添加,手动修改后的参数不会被“同步参数”修改。
93+
94+
![](/imgs/laf4.png)
8295

83-
![](/imgs/laf4.webp)
96+
## 使用注意事项
8497

85-
当然也可以手动添加,手动修改后的参数不会被“同步参数”修改
98+
### 调用报错
8699

87-
## 作用
88-
Laf 账号是绑定在团队上的,团队的成员可以轻松调用已经编写好的云函数
100+
先在 laf 中调试函数,看是否正常调用。可以通过 console.log,打印入参,将入参放在 Laf 测试页面的 Body 中进行测试。

projects/app/src/components/core/app/TTSSelect.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ const TTSSelect = ({
7272
[audioSpeechModelList, onChange, value]
7373
);
7474

75+
const onCloseTTSModal = useCallback(() => {
76+
cancelAudio();
77+
onClose();
78+
}, [cancelAudio, onClose]);
79+
7580
return (
7681
<Flex alignItems={'center'}>
7782
<MyIcon name={'core/app/simpleMode/tts'} mr={2} w={'20px'} />
@@ -100,7 +105,7 @@ const TTSSelect = ({
100105
</>
101106
}
102107
isOpen={isOpen}
103-
onClose={onClose}
108+
onClose={onCloseTTSModal}
104109
w={'500px'}
105110
>
106111
<ModalBody px={[5, 16]} py={[4, 8]}>

projects/app/src/components/core/module/Flow/components/nodes/NodeLaf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ const NodeLaf = (props: NodeProps<FlowModuleItemType>) => {
232232
);
233233

234234
if (!lafFunction) return;
235-
const url = `${feConfigs.lafEnv}/app/${lafData?.lafApp?.appid}/function${lafFunction?.path}`;
235+
const url = `${feConfigs.lafEnv}/app/${lafData?.lafApp?.appid}/function${lafFunction?.path}?templateid=fastgptflow`;
236236
window.open(url, '_blank');
237237
}}
238238
>

projects/app/src/components/support/laf/LafAccountModal.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useUserStore } from '@/web/support/user/useUserStore';
1313
import type { LafAccountType } from '@fastgpt/global/support/user/team/type.d';
1414
import { postLafPat2Token, getLafApplications } from '@/web/support/laf/api';
1515
import { getErrText } from '@fastgpt/global/common/error/utils';
16+
import { getDocPath } from '@/web/common/system/doc';
1617

1718
const LafAccountModal = ({
1819
defaultData = {
@@ -100,7 +101,7 @@ const LafAccountModal = ({
100101
<Box fontSize={'sm'} color={'myGray.500'}>
101102
<Box>{t('support.user.Laf account intro')}</Box>
102103
<Box textDecoration={'underline'}>
103-
<Link href={`https://doc.laf.run/zh/`} isExternal>
104+
<Link href={getDocPath('/docs/workflow/modules/laf/')} isExternal>
104105
{t('support.user.Laf account course')}
105106
</Link>
106107
</Box>
@@ -171,12 +172,14 @@ const LafAccountModal = ({
171172
)}
172173
</ModalBody>
173174
<ModalFooter>
174-
<Button mr={3} variant={'whiteBase'} onClick={onClose}>
175+
<Button variant={'whiteBase'} onClick={onClose}>
175176
{t('common.Close')}
176177
</Button>
177-
<Button isLoading={isUpdating} onClick={handleSubmit((data) => onSubmit(data))}>
178-
{t('common.Update')}
179-
</Button>
178+
{appid && (
179+
<Button ml={3} isLoading={isUpdating} onClick={handleSubmit((data) => onSubmit(data))}>
180+
{t('common.Update')}
181+
</Button>
182+
)}
180183
</ModalFooter>
181184
</MyModal>
182185
);

projects/app/src/pages/app/detail/components/OutLink/SelectUsingWayModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const SelectUsingWayModal = ({ share, onClose }: { share: OutLinkSchema; onClose
102102
data-open-icon="${getValues('scriptOpenIcon')}"
103103
data-close-icon="${getValues('scriptCloseIcon')}"
104104
defer
105-
/>
105+
></script>
106106
<script>
107107
console.log("Chat box loaded")
108108
</script>`

0 commit comments

Comments
 (0)