Docs: fix zh-cn sitemap (#1631)
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
This commit is contained in:
9
docSite/content/zh-cn/docs/workflow/_index.md
Normal file
9
docSite/content/zh-cn/docs/workflow/_index.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
weight: 300
|
||||
title: '高级编排'
|
||||
description: 'FastGPT 高级编排文档'
|
||||
icon: 'family_history'
|
||||
draft: false
|
||||
images: []
|
||||
---
|
||||
<!-- 300 ~ 500 -->
|
||||
8
docSite/content/zh-cn/docs/workflow/examples/_index.md
Normal file
8
docSite/content/zh-cn/docs/workflow/examples/_index.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
weight: 400
|
||||
title: "编排示例"
|
||||
description: "介绍 FastGPT 的高级编排实践案例"
|
||||
icon: "list"
|
||||
draft: false
|
||||
images: []
|
||||
---
|
||||
471
docSite/content/zh-cn/docs/workflow/examples/dalle3.md
Normal file
471
docSite/content/zh-cn/docs/workflow/examples/dalle3.md
Normal file
@@ -0,0 +1,471 @@
|
||||
---
|
||||
title: 'Dalle3 绘图'
|
||||
description: '使用 HTTP 模块绘制图片'
|
||||
icon: 'image'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 404
|
||||
---
|
||||
|
||||
| | |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|
||||
## 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 模块增加一个自定义输出 `data[0].url` 。
|
||||
|
||||
### 2. 文本加工 - 构建图片链接
|
||||
|
||||
在 `Markdown` 语法中 `` 表示插入图片,图片链接由【HTTP 请求】模块输出。
|
||||
|
||||
因此可以增加一个输入来接收 `【HTTP 请求】模块` 的图片链接输出,并在 `【文本加工】模块 - 文本` 中通过变量来引用图片链接,从而得到一个完整的 `Markdown` 图片格式。
|
||||
|
||||
### 3. 指定回复
|
||||
|
||||
指定回复可以直接输出传入的内容到客户端,因此可以直接输出加工好的 `Markdown` 图片格式即可。
|
||||
|
||||
## 编排代码
|
||||
|
||||
{{% details title="编排配置" closed="true" %}}
|
||||
|
||||
```json
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"nodeId": "userGuide",
|
||||
"name": "系统配置",
|
||||
"intro": "可以配置应用的系统参数",
|
||||
"avatar": "/imgs/workflow/userGuide.png",
|
||||
"flowNodeType": "userGuide",
|
||||
"position": {
|
||||
"x": 531.2422736065552,
|
||||
"y": -486.7611729549753
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "welcomeText",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "core.app.Welcome Text",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"key": "variables",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "core.app.Chat Variable",
|
||||
"value": []
|
||||
},
|
||||
{
|
||||
"key": "questionGuide",
|
||||
"valueType": "boolean",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "core.app.Question Guide",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "tts",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"value": {
|
||||
"type": "web"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "whisper",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"value": {
|
||||
"open": false,
|
||||
"autoSend": false,
|
||||
"autoTTSResponse": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "scheduleTrigger",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "448745",
|
||||
"name": "流程开始",
|
||||
"intro": "",
|
||||
"avatar": "/imgs/workflow/userChatInput.svg",
|
||||
"flowNodeType": "workflowStart",
|
||||
"position": {
|
||||
"x": 532.1275542407774,
|
||||
"y": 46.03775600322817
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "用户问题",
|
||||
"required": true,
|
||||
"toolDescription": "用户问题"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "userChatInput",
|
||||
"key": "userChatInput",
|
||||
"label": "core.module.input.label.user question",
|
||||
"valueType": "string",
|
||||
"type": "static"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "tMyUnRL5jIrC",
|
||||
"name": "HTTP 请求",
|
||||
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
|
||||
"avatar": "/imgs/workflow/http.png",
|
||||
"flowNodeType": "httpRequest468",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 921.2377506442713,
|
||||
"y": -483.94114977914256
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
"renderTypeList": [
|
||||
"addInputParam"
|
||||
],
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"description": "core.module.input.description.HTTP Dynamic Input",
|
||||
"editField": {
|
||||
"key": true,
|
||||
"valueType": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "prompt",
|
||||
"valueType": "string",
|
||||
"label": "prompt",
|
||||
"renderTypeList": [
|
||||
"reference"
|
||||
],
|
||||
"description": "",
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"valueType": true
|
||||
},
|
||||
"value": [
|
||||
"448745",
|
||||
"userChatInput"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "system_httpMethod",
|
||||
"renderTypeList": [
|
||||
"custom"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"value": "POST",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "system_httpReqUrl",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Http Request Url",
|
||||
"placeholder": "https://api.ai.com/getInventory",
|
||||
"required": false,
|
||||
"value": "https://api.openai.com/v1/images/generations"
|
||||
},
|
||||
{
|
||||
"key": "system_httpHeader",
|
||||
"renderTypeList": [
|
||||
"custom"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": [
|
||||
{
|
||||
"key": "Authorization",
|
||||
"type": "string",
|
||||
"value": "Bearer sk-zsfBsxEU3ApSFGYxF4CdB97e9556412588421823371b9f7b"
|
||||
}
|
||||
],
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Http Request Header",
|
||||
"placeholder": "core.module.input.description.Http Request Header",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "system_httpParams",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "system_httpJsonBody",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": "{\n \"model\": \"dall-e-3\",\n \"prompt\": \"{{prompt}}\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n}",
|
||||
"label": "",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "system_addOutputParam",
|
||||
"key": "system_addOutputParam",
|
||||
"type": "dynamic",
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"editField": {
|
||||
"key": true,
|
||||
"valueType": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "httpRawResponse",
|
||||
"key": "httpRawResponse",
|
||||
"label": "原始响应",
|
||||
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||
"valueType": "any",
|
||||
"type": "static"
|
||||
},
|
||||
{
|
||||
"id": "DeKGGioBwaMf",
|
||||
"type": "dynamic",
|
||||
"key": "data[0].url",
|
||||
"valueType": "string",
|
||||
"label": "data[0].url"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "CO3POL8svbbi",
|
||||
"name": "文本加工",
|
||||
"intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
|
||||
"avatar": "/imgs/workflow/textEditor.svg",
|
||||
"flowNodeType": "pluginModule",
|
||||
"showStatus": false,
|
||||
"position": {
|
||||
"x": 1417.5940290051137,
|
||||
"y": -478.81889618104356
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
"valueType": "dynamic",
|
||||
"label": "动态外部数据",
|
||||
"renderTypeList": [
|
||||
"addInputParam"
|
||||
],
|
||||
"required": false,
|
||||
"description": "",
|
||||
"canEdit": false,
|
||||
"value": "",
|
||||
"editField": {
|
||||
"key": true
|
||||
},
|
||||
"dynamicParamDefaultValue": {
|
||||
"inputType": "reference",
|
||||
"valueType": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "url",
|
||||
"valueType": "string",
|
||||
"label": "url",
|
||||
"renderTypeList": [
|
||||
"reference"
|
||||
],
|
||||
"required": true,
|
||||
"description": "",
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true
|
||||
},
|
||||
"value": [
|
||||
"tMyUnRL5jIrC",
|
||||
"DeKGGioBwaMf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "文本",
|
||||
"valueType": "string",
|
||||
"label": "文本",
|
||||
"renderTypeList": [
|
||||
"textarea"
|
||||
],
|
||||
"required": true,
|
||||
"description": "",
|
||||
"canEdit": false,
|
||||
"value": "",
|
||||
"editField": {
|
||||
"key": true
|
||||
},
|
||||
"maxLength": "",
|
||||
"dynamicParamDefaultValue": {
|
||||
"inputType": "reference",
|
||||
"valueType": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "text",
|
||||
"type": "static",
|
||||
"key": "text",
|
||||
"valueType": "string",
|
||||
"label": "text",
|
||||
"description": ""
|
||||
}
|
||||
],
|
||||
"pluginId": "community-textEditor"
|
||||
},
|
||||
{
|
||||
"nodeId": "7mapnCgHfKW6",
|
||||
"name": "指定回复",
|
||||
"intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
|
||||
"avatar": "/imgs/workflow/reply.png",
|
||||
"flowNodeType": "answerNode",
|
||||
"position": {
|
||||
"x": 1922.5628399315042,
|
||||
"y": -471.67391598231796
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "text",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "core.module.input.label.Response content",
|
||||
"description": "core.module.input.description.Response content",
|
||||
"placeholder": "core.module.input.description.Response content",
|
||||
"selectedTypeIndex": 1,
|
||||
"value": [
|
||||
"CO3POL8svbbi",
|
||||
"text"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"source": "448745",
|
||||
"target": "tMyUnRL5jIrC",
|
||||
"sourceHandle": "448745-source-right",
|
||||
"targetHandle": "tMyUnRL5jIrC-target-left"
|
||||
},
|
||||
{
|
||||
"source": "tMyUnRL5jIrC",
|
||||
"target": "CO3POL8svbbi",
|
||||
"sourceHandle": "tMyUnRL5jIrC-source-right",
|
||||
"targetHandle": "CO3POL8svbbi-target-left"
|
||||
},
|
||||
{
|
||||
"source": "CO3POL8svbbi",
|
||||
"target": "7mapnCgHfKW6",
|
||||
"sourceHandle": "CO3POL8svbbi-source-right",
|
||||
"targetHandle": "7mapnCgHfKW6-target-left"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
489
docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md
Normal file
489
docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md
Normal file
@@ -0,0 +1,489 @@
|
||||
---
|
||||
title: '发送飞书webhook通知'
|
||||
description: '利用工具调用模块,发送一个飞书webhook通知'
|
||||
icon: 'image'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 404
|
||||
---
|
||||
|
||||
该文章展示如何发送一个简单的飞书webhook通知,以此类推,发送其他类型的通知也可以这么操作。
|
||||
|
||||
| | |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|
||||
## 1. 准备飞书机器人
|
||||
|
||||
| | | |
|
||||
| --------------------- | --------------------- |--------------------- |
|
||||
|  |  | |
|
||||
|
||||
## 2. 导入编排代码
|
||||
|
||||
复制下面配置,点击「高级编排」右上角的导入按键,导入该配置,导入后将飞书提供的接口地址复制到「HTTP 模块」。
|
||||
|
||||
{{% details title="编排配置" closed="true" %}}
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"nodeId": "userGuide",
|
||||
"name": "core.module.template.App system setting",
|
||||
"intro": "core.app.tip.userGuideTip",
|
||||
"avatar": "/imgs/workflow/userGuide.png",
|
||||
"flowNodeType": "userGuide",
|
||||
"position": {
|
||||
"x": -92.26884681344463,
|
||||
"y": 710.9354029649536
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "welcomeText",
|
||||
"type": "hidden",
|
||||
"valueType": "string",
|
||||
"label": "core.app.Welcome Text",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": "",
|
||||
"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,
|
||||
"value": false,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "tts",
|
||||
"type": "hidden",
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": {
|
||||
"type": "web"
|
||||
},
|
||||
"connected": false
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "userChatInput",
|
||||
"name": "core.module.template.Chat entrance",
|
||||
"intro": "当用户发送一个内容后,流程将会从这个模块开始执行。",
|
||||
"avatar": "/imgs/workflow/userChatInput.svg",
|
||||
"flowNodeType": "questionInput",
|
||||
"position": {
|
||||
"x": 241.60980819261408,
|
||||
"y": 1330.9528898009685
|
||||
},
|
||||
"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": [
|
||||
{
|
||||
"nodeId": "n84rvg",
|
||||
"key": "userChatInput"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "n84rvg",
|
||||
"name": "工具调用(实验)",
|
||||
"intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
|
||||
"avatar": "/imgs/workflow/tool.svg",
|
||||
"flowNodeType": "tools",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 809.4264785615641,
|
||||
"y": 873.3971746859133
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "model",
|
||||
"type": "settingLLMModel",
|
||||
"label": "core.module.input.label.aiModel",
|
||||
"required": true,
|
||||
"valueType": "string",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"llmModelType": "all",
|
||||
"value": "gpt-3.5-turbo",
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "temperature",
|
||||
"type": "hidden",
|
||||
"label": "",
|
||||
"value": 0,
|
||||
"valueType": "number",
|
||||
"min": 0,
|
||||
"max": 10,
|
||||
"step": 1,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "maxToken",
|
||||
"type": "hidden",
|
||||
"label": "",
|
||||
"value": 2000,
|
||||
"valueType": "number",
|
||||
"min": 100,
|
||||
"max": 4000,
|
||||
"step": 50,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "systemPrompt",
|
||||
"type": "textarea",
|
||||
"max": 3000,
|
||||
"valueType": "string",
|
||||
"label": "core.ai.Prompt",
|
||||
"description": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"placeholder": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"type": "numberInput",
|
||||
"label": "core.module.input.label.chat history",
|
||||
"required": true,
|
||||
"min": 0,
|
||||
"max": 30,
|
||||
"valueType": "chatHistory",
|
||||
"value": 6,
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"type": "custom",
|
||||
"label": "",
|
||||
"required": true,
|
||||
"valueType": "string",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"label": "core.module.input.label.user question",
|
||||
"type": "hidden",
|
||||
"valueType": "string",
|
||||
"targets": []
|
||||
},
|
||||
{
|
||||
"key": "selectedTools",
|
||||
"valueType": "tools",
|
||||
"type": "hidden",
|
||||
"targets": [
|
||||
{
|
||||
"nodeId": "3mbu91",
|
||||
"key": "selectedTools"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "finish",
|
||||
"label": "",
|
||||
"description": "",
|
||||
"valueType": "boolean",
|
||||
"type": "hidden",
|
||||
"targets": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "3mbu91",
|
||||
"name": "HTTP 请求",
|
||||
"intro": "调用飞书webhook,发送一个通知",
|
||||
"avatar": "/imgs/workflow/http.png",
|
||||
"flowNodeType": "httpRequest468",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 1483.6437630977423,
|
||||
"y": 798.9716928475544
|
||||
},
|
||||
"inputs": [
|
||||
|
||||
{
|
||||
"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": "这里填写你的飞书机器人地址",
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "system_httpHeader",
|
||||
"type": "custom",
|
||||
"valueType": "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,
|
||||
"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 \"msg_type\": \"text\",\r\n \"content\": {\r\n \"text\": \"{{text}}\"\r\n }\r\n}",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "DYNAMIC_INPUT_KEY",
|
||||
"type": "target",
|
||||
"valueType": "any",
|
||||
"label": "core.workflow.inputType.dynamicTargetInput",
|
||||
"description": "core.module.input.description.dynamic input",
|
||||
"required": false,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": true,
|
||||
"hideInApp": true,
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
"type": "addInputParam",
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true,
|
||||
"dataType": true
|
||||
},
|
||||
"defaultEditField": {
|
||||
"label": "",
|
||||
"key": "",
|
||||
"description": "",
|
||||
"inputType": "target",
|
||||
"valueType": "string"
|
||||
},
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"valueType": "string",
|
||||
"type": "hidden",
|
||||
"key": "text",
|
||||
"label": "text",
|
||||
"toolDescription": "需要发送的通知内容",
|
||||
"required": true,
|
||||
"connected": false
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "httpRawResponse",
|
||||
"label": "原始响应",
|
||||
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||
"valueType": "any",
|
||||
"type": "source",
|
||||
"targets": [
|
||||
{
|
||||
"nodeId": "rzx4mj",
|
||||
"key": "switch"
|
||||
},
|
||||
{
|
||||
"nodeId": "psdhs1",
|
||||
"key": "switch"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "system_addOutputParam",
|
||||
"type": "addOutputParam",
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"targets": [],
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true,
|
||||
"dataType": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
"defaultEditField": {
|
||||
"label": "",
|
||||
"key": "",
|
||||
"description": "",
|
||||
"outputType": "source",
|
||||
"valueType": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "source",
|
||||
"valueType": "string",
|
||||
"key": "prompt",
|
||||
"label": "prompt",
|
||||
"description": "",
|
||||
"required": false,
|
||||
"edit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true,
|
||||
"dataType": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
"targets": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "rzx4mj",
|
||||
"name": "工具调用终止",
|
||||
"intro": "该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。",
|
||||
"avatar": "/imgs/workflow/toolStop.svg",
|
||||
"flowNodeType": "stopTool",
|
||||
"position": {
|
||||
"x": 2145.5070710160267,
|
||||
"y": 1306.3581817783079
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "switch",
|
||||
"type": "triggerAndFinish",
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Trigger",
|
||||
"valueType": "any",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "psdhs1",
|
||||
"name": "指定回复",
|
||||
"intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
|
||||
"avatar": "/imgs/workflow/reply.png",
|
||||
"flowNodeType": "answerNode",
|
||||
"position": {
|
||||
"x": 2117.0429459850598,
|
||||
"y": 1658.4125434513746
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "switch",
|
||||
"type": "triggerAndFinish",
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Trigger",
|
||||
"valueType": "any",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"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,
|
||||
"value": "笑死发送成功啦",
|
||||
"connected": false
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "finish",
|
||||
"label": "",
|
||||
"description": "",
|
||||
"valueType": "boolean",
|
||||
"type": "hidden",
|
||||
"targets": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
|
||||
|
||||
## 3. 流程说明
|
||||
|
||||
1. 为工具调用挂载一个HTTP模块,功能描述写上:调用飞书webhook,发送一个通知。
|
||||
2. HTTP模块的输入参数中,填写飞书机器人的地址,填写发送的通知内容。
|
||||
3. HTTP模块输出连接上一个工具终止模块,用于强制结束工具调用。不终止的话,会把调用结果返回给模型,模型会继续回答一次问题,浪费 Tokens
|
||||
4. HTTP模块输出再连上一个指定回复,直接回复一个发送成功,用于替代AI的回答。
|
||||
432
docSite/content/zh-cn/docs/workflow/examples/fixingEvidence.md
Normal file
432
docSite/content/zh-cn/docs/workflow/examples/fixingEvidence.md
Normal file
@@ -0,0 +1,432 @@
|
||||
---
|
||||
title: '固定开头和结尾内容'
|
||||
description: '利用指定回复,创建固定的开头和结尾'
|
||||
icon: 'healing'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 401
|
||||
---
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
如上图,可以通过指定回复编排一个固定的开头和结尾内容。
|
||||
|
||||
## 模块编排
|
||||
|
||||
复制下面配置,点击「高级编排」右上角的导入按键,导入该配置。
|
||||
|
||||
{{% details title="编排配置" closed="true" %}}
|
||||
|
||||
```json
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"nodeId": "7z5g5h",
|
||||
"name": "流程开始",
|
||||
"intro": "",
|
||||
"avatar": "/imgs/workflow/userChatInput.svg",
|
||||
"flowNodeType": "workflowStart",
|
||||
"position": {
|
||||
"x": -269.50851681351924,
|
||||
"y": 1657.6123698022448
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "问题输入",
|
||||
"required": true,
|
||||
"toolDescription": "用户问题",
|
||||
"type": "systemInput",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0,
|
||||
"value": [
|
||||
"7z5g5h",
|
||||
"userChatInput"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "userChatInput",
|
||||
"type": "static",
|
||||
"key": "userChatInput",
|
||||
"valueType": "string",
|
||||
"label": "core.module.input.label.user question"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "nlfwkc",
|
||||
"name": "AI 对话",
|
||||
"intro": "AI 大模型对话",
|
||||
"avatar": "/imgs/workflow/AI.png",
|
||||
"flowNodeType": "chatNode",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 907.2058332478431,
|
||||
"y": 1348.9992737142143
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "model",
|
||||
"renderTypeList": [
|
||||
"settingLLMModel",
|
||||
"reference"
|
||||
],
|
||||
"label": "core.module.input.label.aiModel",
|
||||
"valueType": "string",
|
||||
"type": "selectLLMModel",
|
||||
"required": true,
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": "gpt-3.5-turbo",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "temperature",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": 0,
|
||||
"valueType": "number",
|
||||
"min": 0,
|
||||
"max": 10,
|
||||
"step": 1,
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "maxToken",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": 2000,
|
||||
"valueType": "number",
|
||||
"min": 100,
|
||||
"max": 4000,
|
||||
"step": 50,
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "isResponseAnswerText",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": true,
|
||||
"valueType": "boolean",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "quoteTemplate",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "string",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "quotePrompt",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "string",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "systemPrompt",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"max": 300,
|
||||
"valueType": "string",
|
||||
"label": "core.ai.Prompt",
|
||||
"description": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"placeholder": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"type": "textarea",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"value": "",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"renderTypeList": [
|
||||
"numberInput",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "chatHistory",
|
||||
"label": "core.module.input.label.chat history",
|
||||
"required": true,
|
||||
"min": 0,
|
||||
"max": 30,
|
||||
"value": 6,
|
||||
"type": "numberInput",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "问题输入",
|
||||
"required": true,
|
||||
"toolDescription": "用户问题",
|
||||
"type": "custom",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true,
|
||||
"selectedTypeIndex": 0,
|
||||
"value": [
|
||||
"7z5g5h",
|
||||
"userChatInput"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "quoteQA",
|
||||
"renderTypeList": [
|
||||
"settingDatasetQuotePrompt"
|
||||
],
|
||||
"label": "",
|
||||
"debugLabel": "知识库引用",
|
||||
"description": "core.module.Dataset quote.Input description",
|
||||
"valueType": "datasetQuote",
|
||||
"type": "target",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true,
|
||||
"selectedTypeIndex": 0,
|
||||
"value": [
|
||||
"fljhzy",
|
||||
"quoteQA"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "answerText",
|
||||
"type": "static",
|
||||
"key": "answerText",
|
||||
"valueType": "string",
|
||||
"label": "core.module.output.label.Ai response content",
|
||||
"description": "core.module.output.description.Ai response content"
|
||||
},
|
||||
{
|
||||
"id": "history",
|
||||
"type": "static",
|
||||
"key": "history",
|
||||
"valueType": "chatHistory",
|
||||
"label": "core.module.output.label.New context",
|
||||
"description": "core.module.output.description.New context"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "q9equb",
|
||||
"name": "core.module.template.App system setting",
|
||||
"intro": "可以配置应用的系统参数。",
|
||||
"avatar": "/imgs/workflow/userGuide.png",
|
||||
"flowNodeType": "userGuide",
|
||||
"position": {
|
||||
"x": -275.92529567956024,
|
||||
"y": 1094.1001488133452
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "welcomeText",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "core.app.Welcome Text",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": "你好,我是电影《星际穿越》 AI 助手,有什么可以帮助你的?\n[导演是谁]\n[剧情介绍]\n[票房分析]",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "variables",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "core.module.Variable",
|
||||
"value": [],
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "questionGuide",
|
||||
"valueType": "boolean",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"type": "switch",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "tts",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "whisper",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": ""
|
||||
},
|
||||
{
|
||||
"key": "scheduleTrigger",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "tc90wz",
|
||||
"name": "指定回复",
|
||||
"intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
|
||||
"avatar": "/imgs/workflow/reply.png",
|
||||
"flowNodeType": "answerNode",
|
||||
"position": {
|
||||
"x": 159.49274056478237,
|
||||
"y": 1621.4635230667668
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "text",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "core.module.input.label.Response content",
|
||||
"description": "core.module.input.description.Response content",
|
||||
"placeholder": "core.module.input.description.Response content",
|
||||
"type": "textarea",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"value": "这是开头\\n",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "U5T3dMVY4wj7",
|
||||
"name": "指定回复",
|
||||
"intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
|
||||
"avatar": "/imgs/workflow/reply.png",
|
||||
"flowNodeType": "answerNode",
|
||||
"position": {
|
||||
"x": 1467.0625486167608,
|
||||
"y": 1597.346243737531
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "text",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "core.module.input.label.Response content",
|
||||
"description": "core.module.input.description.Response content",
|
||||
"placeholder": "core.module.input.description.Response content",
|
||||
"value": "这是结尾"
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"source": "7z5g5h",
|
||||
"target": "tc90wz",
|
||||
"sourceHandle": "7z5g5h-source-right",
|
||||
"targetHandle": "tc90wz-target-left"
|
||||
},
|
||||
{
|
||||
"source": "tc90wz",
|
||||
"target": "nlfwkc",
|
||||
"sourceHandle": "tc90wz-source-right",
|
||||
"targetHandle": "nlfwkc-target-left"
|
||||
},
|
||||
{
|
||||
"source": "nlfwkc",
|
||||
"target": "U5T3dMVY4wj7",
|
||||
"sourceHandle": "nlfwkc-source-right",
|
||||
"targetHandle": "U5T3dMVY4wj7-target-left"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
|
||||
1285
docSite/content/zh-cn/docs/workflow/examples/google_search.md
Normal file
1285
docSite/content/zh-cn/docs/workflow/examples/google_search.md
Normal file
File diff suppressed because it is too large
Load Diff
853
docSite/content/zh-cn/docs/workflow/examples/lab_appointment.md
Normal file
853
docSite/content/zh-cn/docs/workflow/examples/lab_appointment.md
Normal file
@@ -0,0 +1,853 @@
|
||||
---
|
||||
title: '实验室预约'
|
||||
description: '展示高级编排操作数据库的能力'
|
||||
icon: 'database'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 403
|
||||
---
|
||||
|
||||
| | |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
|
||||
|
||||
本示例演示了利用工具调用,自动选择调用知识库搜索实验室相关内容,或调用 HTTP 模块实现数据库的 CRUD 操作。
|
||||
|
||||
以一个实验室预约为例,用户可以通过对话系统预约、取消、修改预约和查询预约记录。
|
||||
|
||||
## 1. 全局变量使用
|
||||
|
||||
通过设计一个全局变量,让用户输入姓名,模拟用户身份信息。实际使用过程中,通常是直接通过嵌入 Token 来标记用户身份。
|
||||
|
||||
## 2. 工具调用
|
||||
|
||||

|
||||
|
||||
背景知识中,引导模型调用工具去执行不通的操作。
|
||||
|
||||
{{% alert icon="🤗" context="warning" %}}
|
||||
**Tips:** 这里需要增加适当的上下文,方便模型结合历史纪录进行判断和决策~
|
||||
{{% /alert %}}
|
||||
|
||||
## 3. HTTP 模块
|
||||
|
||||

|
||||
|
||||
HTTP模块中,需要设置 3 个工具参数:
|
||||
|
||||
- 预约行为:可取 get, put, post, delete 四个值,分别对应查询、修改、新增、删除操作。当然,你也可以写4个HTTP模块,来分别处理。
|
||||
- labname: 实验室名。非必填,因为查询和删除时候,不需要。
|
||||
- time: 预约时间。
|
||||
|
||||
|
||||
# 总结
|
||||
|
||||
1. 工具调用模块是非常强大的功能,可以在一定程度上替代问题分类和内容提取。
|
||||
2. 通过工具模块,动态的调用不同的工具,可以将复杂业务解耦。
|
||||
|
||||
|
||||
# 附件
|
||||
|
||||
## 编排配置
|
||||
|
||||
可直接复制,导入到 FastGPT 中。
|
||||
|
||||
{{% details title="编排配置" closed="true" %}}
|
||||
|
||||
```json
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"nodeId": "userChatInput",
|
||||
"name": "流程开始",
|
||||
"intro": "当用户发送一个内容后,流程将会从这个模块开始执行。",
|
||||
"avatar": "/imgs/workflow/userChatInput.svg",
|
||||
"flowNodeType": "workflowStart",
|
||||
"position": {
|
||||
"x": 309.7143912167367,
|
||||
"y": 1501.2761754220846
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "问题输入",
|
||||
"required": true,
|
||||
"toolDescription": "用户问题",
|
||||
"type": "systemInput",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0,
|
||||
"value": [
|
||||
"userChatInput",
|
||||
"userChatInput"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "userChatInput",
|
||||
"type": "static",
|
||||
"key": "userChatInput",
|
||||
"valueType": "string",
|
||||
"label": "core.module.input.label.user question"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "eg5upi",
|
||||
"name": "指定回复",
|
||||
"intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
|
||||
"avatar": "/imgs/workflow/reply.png",
|
||||
"flowNodeType": "answerNode",
|
||||
"position": {
|
||||
"x": 1962.729630445213,
|
||||
"y": 2295.9791334948304
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "text",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "core.module.input.label.Response content",
|
||||
"description": "core.module.input.description.Response content",
|
||||
"placeholder": "core.module.input.description.Response content",
|
||||
"type": "textarea",
|
||||
"showTargetInApp": true,
|
||||
"showTargetInPlugin": true,
|
||||
"connected": true,
|
||||
"selectedTypeIndex": 1,
|
||||
"value": [
|
||||
"40clf3",
|
||||
"result"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "kge59i",
|
||||
"name": "用户引导",
|
||||
"intro": "可以配置应用的系统参数。",
|
||||
"avatar": "/imgs/workflow/userGuide.png",
|
||||
"flowNodeType": "userGuide",
|
||||
"position": {
|
||||
"x": -327.218389965887,
|
||||
"y": 1504.8056414948464
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "welcomeText",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "core.app.Welcome Text",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": "你好,我是实验室助手,请问有什么可以帮助你的么?如需预约或修改预约实验室,请提供姓名、时间和实验室名称。\n[实验室介绍]\n[开放时间]\n[预约]",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "variables",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "core.module.Variable",
|
||||
"value": [
|
||||
{
|
||||
"id": "gt9b23",
|
||||
"key": "name",
|
||||
"label": "name",
|
||||
"type": "input",
|
||||
"required": true,
|
||||
"maxLen": 50,
|
||||
"enums": [
|
||||
{
|
||||
"value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "questionGuide",
|
||||
"valueType": "boolean",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"type": "switch",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "tts",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": {
|
||||
"type": "model",
|
||||
"model": "tts-1",
|
||||
"voice": "alloy"
|
||||
},
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "whisper",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "scheduleTrigger",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"label": "",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "40clf3",
|
||||
"name": "HTTP请求",
|
||||
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
|
||||
"avatar": "/imgs/workflow/http.png",
|
||||
"flowNodeType": "httpRequest468",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 1118.6532653446993,
|
||||
"y": 1955.886106913907
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "system_httpMethod",
|
||||
"renderTypeList": [
|
||||
"custom"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"value": "POST",
|
||||
"required": true,
|
||||
"type": "custom",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"valueType": "string",
|
||||
"renderTypeList": [
|
||||
"reference"
|
||||
],
|
||||
"key": "action",
|
||||
"label": "action",
|
||||
"toolDescription": "预约行为,一共四种:\nget - 查询预约情况\nput - 更新预约\npost - 新增预约\ndelete - 删除预约",
|
||||
"required": true,
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"valueType": "string",
|
||||
"renderTypeList": [
|
||||
"reference"
|
||||
],
|
||||
"key": "labname",
|
||||
"label": "labname",
|
||||
"toolDescription": "实验室名称",
|
||||
"required": false,
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"valueType": "string",
|
||||
"renderTypeList": [
|
||||
"reference"
|
||||
],
|
||||
"key": "time",
|
||||
"label": "time",
|
||||
"toolDescription": "预约时间,按 YYYY/MM/DD HH:mm 格式返回",
|
||||
"required": false,
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"description": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "system_httpReqUrl",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Http Request Url",
|
||||
"placeholder": "https://api.ai.com/getInventory",
|
||||
"required": false,
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"value": "https://d8dns0.laf.dev/appointment-lab",
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "system_httpHeader",
|
||||
"renderTypeList": [
|
||||
"custom"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"description": "core.module.input.description.Http Request Header",
|
||||
"placeholder": "core.module.input.description.Http Request Header",
|
||||
"required": false,
|
||||
"type": "custom",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "system_httpParams",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"required": false,
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "system_httpJsonBody",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"valueType": "any",
|
||||
"value": "{\r\n \"name\": \"{{name}}\",\r\n \"time\": \"{{time}}\",\r\n \"labname\": \"{{labname}}\",\r\n \"action\": \"{{action}}\"\r\n}",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"type": "hidden",
|
||||
"showTargetInApp": false,
|
||||
"showTargetInPlugin": false,
|
||||
"connected": false,
|
||||
"selectedTypeIndex": 0
|
||||
},
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
"renderTypeList": [
|
||||
"addInputParam"
|
||||
],
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"description": "core.module.input.description.HTTP Dynamic Input",
|
||||
"editField": {
|
||||
"key": true,
|
||||
"valueType": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "system_addOutputParam",
|
||||
"type": "dynamic",
|
||||
"key": "system_addOutputParam",
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"editField": {
|
||||
"key": true,
|
||||
"valueType": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "result",
|
||||
"type": "static",
|
||||
"key": "result",
|
||||
"valueType": "string",
|
||||
"label": "result",
|
||||
"description": "result",
|
||||
"canEdit": true,
|
||||
"editField": {
|
||||
"key": true,
|
||||
"name": true,
|
||||
"description": true,
|
||||
"dataType": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "httpRawResponse",
|
||||
"type": "static",
|
||||
"key": "httpRawResponse",
|
||||
"valueType": "any",
|
||||
"label": "原始响应",
|
||||
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "fYxwWym8flYL",
|
||||
"name": "工具调用(实验)",
|
||||
"intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
|
||||
"avatar": "/imgs/workflow/tool.svg",
|
||||
"flowNodeType": "tools",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 933.9342354248961,
|
||||
"y": 1229.3563445150553
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "model",
|
||||
"renderTypeList": [
|
||||
"settingLLMModel",
|
||||
"reference"
|
||||
],
|
||||
"label": "core.module.input.label.aiModel",
|
||||
"valueType": "string",
|
||||
"llmModelType": "all",
|
||||
"value": "gpt-3.5-turbo"
|
||||
},
|
||||
{
|
||||
"key": "temperature",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": 0,
|
||||
"valueType": "number",
|
||||
"min": 0,
|
||||
"max": 10,
|
||||
"step": 1
|
||||
},
|
||||
{
|
||||
"key": "maxToken",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": 2000,
|
||||
"valueType": "number",
|
||||
"min": 100,
|
||||
"max": 4000,
|
||||
"step": 50
|
||||
},
|
||||
{
|
||||
"key": "systemPrompt",
|
||||
"renderTypeList": [
|
||||
"textarea",
|
||||
"reference"
|
||||
],
|
||||
"max": 3000,
|
||||
"valueType": "string",
|
||||
"label": "core.ai.Prompt",
|
||||
"description": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"placeholder": "core.app.tip.chatNodeSystemPromptTip",
|
||||
"value": "当前时间为: {{cTime}}\n你是实验室助手,用户可能会询问实验室相关介绍或预约实验室。\n请选择合适的工具去帮助他们。"
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"renderTypeList": [
|
||||
"numberInput",
|
||||
"reference"
|
||||
],
|
||||
"valueType": "chatHistory",
|
||||
"label": "core.module.input.label.chat history",
|
||||
"required": true,
|
||||
"min": 0,
|
||||
"max": 30,
|
||||
"value": 6
|
||||
},
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "用户问题",
|
||||
"required": true,
|
||||
"value": [
|
||||
"userChatInput",
|
||||
"userChatInput"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "JSSQtDgwmmbE",
|
||||
"name": "知识库搜索",
|
||||
"intro": "调用“语义检索”和“全文检索”能力,从“知识库”中查找实验室介绍和使用规则等信息。",
|
||||
"avatar": "/imgs/workflow/db.png",
|
||||
"flowNodeType": "datasetSearchNode",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 447.0795498711184,
|
||||
"y": 1971.5311041711186
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "datasets",
|
||||
"renderTypeList": [
|
||||
"selectDataset",
|
||||
"reference"
|
||||
],
|
||||
"label": "core.module.input.label.Select dataset",
|
||||
"value": [],
|
||||
"valueType": "selectDataset",
|
||||
"list": [],
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "similarity",
|
||||
"renderTypeList": [
|
||||
"selectDatasetParamsModal"
|
||||
],
|
||||
"label": "",
|
||||
"value": 0.4,
|
||||
"valueType": "number"
|
||||
},
|
||||
{
|
||||
"key": "limit",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"value": 1500,
|
||||
"valueType": "number"
|
||||
},
|
||||
{
|
||||
"key": "searchMode",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "string",
|
||||
"value": "embedding"
|
||||
},
|
||||
{
|
||||
"key": "usingReRank",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "datasetSearchUsingExtensionQuery",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "datasetSearchExtensionModel",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "string",
|
||||
"value": "gpt-3.5-turbo"
|
||||
},
|
||||
{
|
||||
"key": "datasetSearchExtensionBg",
|
||||
"renderTypeList": [
|
||||
"hidden"
|
||||
],
|
||||
"label": "",
|
||||
"valueType": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"renderTypeList": [
|
||||
"reference",
|
||||
"textarea"
|
||||
],
|
||||
"valueType": "string",
|
||||
"label": "用户问题",
|
||||
"required": true,
|
||||
"toolDescription": "需要检索的内容"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "quoteQA",
|
||||
"key": "quoteQA",
|
||||
"label": "core.module.Dataset quote.label",
|
||||
"description": "特殊数组格式,搜索结果为空时,返回空数组。",
|
||||
"type": "static",
|
||||
"valueType": "datasetQuote"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "IdntVQiTopHT",
|
||||
"name": "工具调用终止",
|
||||
"intro": "该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。",
|
||||
"avatar": "/imgs/workflow/toolStop.svg",
|
||||
"flowNodeType": "stopTool",
|
||||
"position": {
|
||||
"x": 1969.73331750207,
|
||||
"y": 2650.0258908119413
|
||||
},
|
||||
"inputs": [],
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"source": "40clf3",
|
||||
"target": "eg5upi",
|
||||
"sourceHandle": "40clf3-source-right",
|
||||
"targetHandle": "eg5upi-target-left"
|
||||
},
|
||||
{
|
||||
"source": "userChatInput",
|
||||
"target": "fYxwWym8flYL",
|
||||
"sourceHandle": "userChatInput-source-right",
|
||||
"targetHandle": "fYxwWym8flYL-target-left"
|
||||
},
|
||||
{
|
||||
"source": "fYxwWym8flYL",
|
||||
"target": "40clf3",
|
||||
"sourceHandle": "selectedTools",
|
||||
"targetHandle": "selectedTools"
|
||||
},
|
||||
{
|
||||
"source": "fYxwWym8flYL",
|
||||
"target": "JSSQtDgwmmbE",
|
||||
"sourceHandle": "selectedTools",
|
||||
"targetHandle": "selectedTools"
|
||||
},
|
||||
{
|
||||
"source": "40clf3",
|
||||
"target": "IdntVQiTopHT",
|
||||
"sourceHandle": "40clf3-source-right",
|
||||
"targetHandle": "IdntVQiTopHT-target-left"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
|
||||
## Laf 云函数代码
|
||||
|
||||
可以在 [Laf](https://laf.dev/) 中快速构建 HTTP 接口。
|
||||
|
||||
{{% details title="函数代码" closed="true" %}}
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud'
|
||||
const db = cloud.database()
|
||||
|
||||
type RequestType = {
|
||||
name: string;
|
||||
time?: string;
|
||||
labname?: string;
|
||||
action: 'post' | 'delete' | 'put' | 'get'
|
||||
}
|
||||
|
||||
export default async function (ctx: FunctionContext) {
|
||||
try {
|
||||
const { action,...body } = ctx.body as RequestType
|
||||
|
||||
if (action === 'get') {
|
||||
return await getRecord(ctx.body)
|
||||
}
|
||||
if (action === 'post') {
|
||||
return await createRecord(ctx.body)
|
||||
}
|
||||
if (action === 'put') {
|
||||
return await putRecord(ctx.body)
|
||||
}
|
||||
if (action === 'delete') {
|
||||
return await removeRecord(ctx.body)
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
result: "异常"
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
result: "异常"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function putRecord({ name, time, labname }: RequestType) {
|
||||
const missData = []
|
||||
if (!name) missData.push("你的姓名")
|
||||
|
||||
if (missData.length > 0) {
|
||||
return {
|
||||
result: `请提供: ${missData.join("、")}`
|
||||
}
|
||||
}
|
||||
|
||||
const { data: record } = await db.collection("LabAppointment").where({
|
||||
name, status: "unStart"
|
||||
}).getOne()
|
||||
|
||||
if (!record) {
|
||||
return {
|
||||
result: `${name} 还没有预约记录`
|
||||
}
|
||||
}
|
||||
|
||||
const updateWhere = {
|
||||
name,
|
||||
time: time || record.time,
|
||||
labname: labname || record.labname
|
||||
}
|
||||
|
||||
await db.collection("LabAppointment").where({
|
||||
name, status: "unStart"
|
||||
}).update(updateWhere)
|
||||
|
||||
return {
|
||||
result: `修改预约成功。
|
||||
姓名:${name}·
|
||||
时间: ${updateWhere.time}
|
||||
实验室名: ${updateWhere.labname}
|
||||
` }
|
||||
}
|
||||
|
||||
|
||||
async function getRecord({ name }: RequestType) {
|
||||
if (!name) {
|
||||
return {
|
||||
result: "请提供你的姓名"
|
||||
}
|
||||
}
|
||||
const { data } = await db.collection('LabAppointment').where({ name, status: "unStart" }).getOne()
|
||||
|
||||
if (!data) {
|
||||
return {
|
||||
result: `${name} 没有预约中的记录`
|
||||
}
|
||||
}
|
||||
return {
|
||||
result: `${name} 有一条预约记录:
|
||||
姓名:${data.name}
|
||||
时间: ${data.time}
|
||||
实验室名: ${data.labname}
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
async function removeRecord({ name }: RequestType) {
|
||||
if (!name) {
|
||||
return {
|
||||
result: "请提供你的姓名"
|
||||
}
|
||||
}
|
||||
const { deleted } = await db.collection('LabAppointment').where({ name, status: "unStart" }).remove()
|
||||
|
||||
if (deleted > 0) {
|
||||
return {
|
||||
result: `取消预约记录成功: ${name}`
|
||||
}
|
||||
}
|
||||
return {
|
||||
result: ` ${name} 没有预约中的记录`
|
||||
}
|
||||
}
|
||||
|
||||
async function createRecord({ name, time, labname }: RequestType) {
|
||||
const missData = []
|
||||
if (!name) missData.push("你的姓名")
|
||||
if (!time) missData.push("需要预约的时间")
|
||||
if (!labname) missData.push("实验室名名称")
|
||||
|
||||
if (missData.length > 0) {
|
||||
return {
|
||||
result: `请提供: ${missData.join("、")}`
|
||||
}
|
||||
}
|
||||
|
||||
const { data: record } = await db.collection("LabAppointment").where({
|
||||
name, status: "unStart"
|
||||
}).getOne()
|
||||
|
||||
if (record) {
|
||||
return {
|
||||
result: `您已经有一个预约记录了:
|
||||
姓名:${record.name}
|
||||
时间: ${record.time}
|
||||
实验室名: ${record.labname}
|
||||
|
||||
每人仅能同时预约一个实验室名。
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
await db.collection("LabAppointment").add({
|
||||
name, time, labname, status: "unStart"
|
||||
})
|
||||
|
||||
return {
|
||||
result: `预约成功。
|
||||
姓名:${name}
|
||||
时间: ${time}
|
||||
实验室名: ${labname}
|
||||
` }
|
||||
}
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
93
docSite/content/zh-cn/docs/workflow/intro.md
Normal file
93
docSite/content/zh-cn/docs/workflow/intro.md
Normal file
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: "高级编排介绍"
|
||||
description: "快速了解 FastGPT 高级编排"
|
||||
icon: "circle"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 301
|
||||
---
|
||||
|
||||
FastGPT 从 V4 版本开始采用新的交互方式来构建 AI 应用。使用了 Flow 节点编排(工作流)的方式来实现复杂工作流,提高可玩性和扩展性。但同时也提高了上手的门槛,有一定开发背景的用户使用起来会比较容易。
|
||||
|
||||
[查看视频教程](https://www.bilibili.com/video/BV1aB4y1Z7Hy/?spm_id_from=333.999.list.card_archive.click&vd_source=903c2b09b7412037c2eddc6a8fb9828b)
|
||||
|
||||

|
||||
|
||||
## 什么是节点?
|
||||
|
||||
在程序中,节点可以理解为一个个 Function 或者接口。可以理解为它就是一个**步骤**。将多个节点一个个拼接起来,即可一步步的去实现最终的 AI 输出。
|
||||
|
||||
如下图,这是一个最简单的 AI 对话。它由用流程开始和 AI 对话节点组成。
|
||||
|
||||

|
||||
|
||||
执行流程如下:
|
||||
1. 用户输入问题后,【流程开始】节点执行,用户问题被保存。
|
||||
2. 【AI 对话】节点执行,此节点有两个必填参数“聊天记录” “用户问题”,聊天记录的值是默认输入的6条,表示此模块上下文长度。用户问题选择的是【流程开始】模块中保存的用户问题。
|
||||
3. 【AI 对话】节点根据传入的聊天记录和用户问题,调用对话接口,从而实现回答。
|
||||
|
||||
### 节点分类
|
||||
|
||||
从功能上,节点可以分为 2 类:
|
||||
|
||||
1. **系统节点**:用户引导(配置一些对话框信息)、用户问题(流程入口)。
|
||||
2. **功能节点**:知识库搜索、AI 对话等剩余节点。(这些节点都有输入和输出,可以自由组合)。
|
||||
|
||||
### 节点的组成
|
||||
|
||||
每个节点会包含 3 个核心部分:输入、输出和触发器。
|
||||
|
||||

|
||||
|
||||
- AI模型、提示词、聊天记录、用户问题,知识库引用为输入,节点的输入可以是手动输入也可以是变量引用,变量引用的范围包括“全局变量”和之前任意一个节点的输出。
|
||||
- 新的上下文和AI回复内容为输出,输出可以被之后任意节点变量引用。
|
||||
- 节点的上下左右有四个“触发器”可以被用来连接,被连接的节点按顺序决定是否执行。
|
||||
|
||||
## 重点 - 工作流是如何运行的
|
||||
|
||||
FastGPT的工作流从【流程开始】节点开始执行,可以理解为从用户输入问题开始,没有**固定的出口**,是以节点运行结束作为出口,如果在一个轮调用中,所有节点都不再允许,则工作流结束。
|
||||
|
||||
下面我们来看下,工作流是如何运行的,以及每个节点何时被触发执行。
|
||||
|
||||

|
||||
|
||||
如上图所示节点会“被连接”也会“连接其他节点”,我们称“被连接”的那根线为前置线,“连接其他节点的线”为后置线。上图例子中【知识库搜索】模块左侧有一根前置线,右侧有一根后置线。而【AI对话】节点只有左侧一根前置线。
|
||||
|
||||
FastGPT工作流中的线有以下几种状态:
|
||||
- `waiting`:被连接的节点等待执行。
|
||||
- `active`:被连接的节点可以执行。
|
||||
- `skip`:被连接的节点不需要执行跳过。
|
||||
|
||||
节点执行的原则:
|
||||
|
||||
1. 判断前置线中有没有状态为 `waiting` 的,如果有则等待。
|
||||
2. 判断前置线中状态有没有状态为 `active` 如果有则执行。
|
||||
3. 如果前置线中状态即没有 `waiting` 也没有 `active` 则认为此节点需要跳过。
|
||||
4. 节点执行完毕后,需要根据实际情况更改后置线的状态为`active`或`skip`并且更改前置线状态为`waiting`等待下一轮执行。
|
||||
|
||||
让我们看一下上面例子的执行过程:
|
||||
1. 【流程开始】节点执行完毕,更改后置线为`active`。
|
||||
2. 【知识库搜索】节点判断前置线状态为`active`开始执行,执行完毕后更改后置线状态为`active` 前置线状态为`waiting`。
|
||||
3. 【AI对话】节点判断前置线状态为`active`开始执行,流程执行结束。
|
||||
|
||||
## 如何连接节点
|
||||
|
||||
1. 为了方便连接,FastGPT 每个节点的上下左右都有连接点,左和上是前置线连接点,右和下是后置线连接点。
|
||||
2. 可以点击连接线中间的 x 来删除连接线。
|
||||
3. 可以左键点击选中连接线
|
||||
|
||||
## 如何阅读?
|
||||
|
||||
1. 建议从左往右阅读。
|
||||
2. 从 **用户问题** 节点开始。用户问题节点,代表的是用户发送了一段文本,触发任务开始。
|
||||
3. 关注【AI 对话】和【指定回复】节点,这两个节点是输出答案的地方。
|
||||
|
||||
## FAQ
|
||||
|
||||
### 想合并多个输出结果怎么实现?
|
||||
|
||||
1. 文本加工,可以对字符串进行合并。
|
||||
2. 知识库搜索合并,可以合并多个知识库搜索结果
|
||||
3. 其他结果,无法直接合并,可以考虑传入到`HTTP`节点中进行合并,使用`[Laf](https://laf.run/)`可以快速实现一个无服务器HTTP接口。
|
||||
|
||||
|
||||
10
docSite/content/zh-cn/docs/workflow/modules/_index.md
Normal file
10
docSite/content/zh-cn/docs/workflow/modules/_index.md
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
weight: 350
|
||||
title: "模块介绍"
|
||||
description: "介绍 FastGPT 的常用模块"
|
||||
icon: "apps"
|
||||
draft: false
|
||||
images: []
|
||||
---
|
||||
|
||||
<!-- 350 ~ 400 -->
|
||||
34
docSite/content/zh-cn/docs/workflow/modules/ai_chat.md
Normal file
34
docSite/content/zh-cn/docs/workflow/modules/ai_chat.md
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: "AI 对话"
|
||||
description: "FastGPT AI 对话模块介绍"
|
||||
icon: "chat"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 351
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 触发执行
|
||||
- 核心模块
|
||||
|
||||

|
||||
|
||||
## 参数说明
|
||||
|
||||
## AI模型
|
||||
|
||||
可以通过 [config.json](/docs/development/configuration/) 配置可选的对话模型,通过 [one-api](/docs/development/one-api/) 来实现多模型接入。
|
||||
|
||||
点击AI模型后,可以配置模型的相关参数。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
{{% alert icon="🍅" context="success" %}}
|
||||
具体配置参数介绍可以参考: [AI参数配置说明](/docs/course/ai_settings)
|
||||
{{% /alert %}}
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: "内容提取"
|
||||
description: "FastGPT 内容提取模块介绍"
|
||||
icon: "content_paste_go"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 352
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 需要手动配置
|
||||
- 触发执行
|
||||
- function_call 模块
|
||||
- 核心模块
|
||||
|
||||

|
||||
|
||||
## 功能
|
||||
|
||||
从文本中提取结构化数据,通常是配合 HTTP 模块实现扩展。也可以做一些直接提取操作,例如:翻译。
|
||||
|
||||
## 参数说明
|
||||
|
||||
### 提取要求描述
|
||||
|
||||
顾名思义,给模型设置一个目标,需要提取哪些内容。
|
||||
|
||||
**示例 1**
|
||||
|
||||
> 你是实验室预约助手,从对话中提取出姓名,预约时间,实验室号。当前时间 {{cTime}}
|
||||
|
||||
**示例 2**
|
||||
|
||||
> 你是谷歌搜索助手,从对话中提取出搜索关键词
|
||||
|
||||
**示例 3**
|
||||
|
||||
> 将我的问题直接翻译成英文,不要回答问题
|
||||
|
||||
### 历史记录
|
||||
|
||||
通常需要一些历史记录,才能更完整的提取用户问题。例如上图中需要提供姓名、时间和实验室名,用户可能一开始只给了时间和实验室名,没有提供自己的姓名。再经过一轮缺失提示后,用户输入了姓名,此时需要结合上一次的记录才能完整的提取出 3 个内容。
|
||||
|
||||
### 目标字段
|
||||
|
||||
目标字段与提取的结果相对应,从上图可以看到,每增加一个字段,输出会增加一个对应的出口。
|
||||
|
||||
+ **key**: 字段的唯一标识,不可重复!
|
||||
+ **字段描述**:描述该字段是关于什么的,例如:姓名、时间、搜索词等等。
|
||||
+ **必须**:是否强制模型提取该字段,可能提取出来是空字符串。
|
||||
|
||||
## 输出介绍
|
||||
|
||||
- **完整提取结果**: 一个 JSON 字符串,包含所有字段的提取结果。
|
||||
- **目标字段提取结果**:类型均为字符串。
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: "问题优化(已合并到知识库搜索)"
|
||||
description: "问题优化模块介绍和使用"
|
||||
icon: "input"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 364
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 触发执行
|
||||
|
||||

|
||||
|
||||
## 背景
|
||||
|
||||
在 RAG 中,我们需要根据输入的问题去数据库里执行 embedding 搜索,查找相关的内容,从而查找到相似的内容(简称知识库搜索)。
|
||||
|
||||
在搜索的过程中,尤其是连续对话的搜索,我们通常会发现后续的问题难以搜索到合适的内容,其中一个原因是知识库搜索只会使用“当前”的问题去执行。看下面的例子:
|
||||
|
||||

|
||||
|
||||
用户在提问“第二点是什么”的时候,只会去知识库里查找“第二点是什么”,压根查不到内容。实际上需要查询的是“QA结构是什么”。因此我们需要引入一个【问题优化】模块,来对用户当前的问题进行补全,从而使得知识库搜索能够搜索到合适的内容。使用补全后效果如下:
|
||||
|
||||

|
||||
|
||||
|
||||
## 功能
|
||||
|
||||
调用 AI 去对用户当前的问题进行补全。目前主要是补全“指代”词,使得检索词更加的完善可靠,从而增强上下文连续对话的知识库搜索能力。
|
||||
|
||||
遇到最大的难题在于:模型对于【补全】的概念可能不清晰,且对于长上下文往往无法准确的知道应该如何补全。
|
||||
|
||||
## 示例
|
||||
|
||||
- [接入谷歌搜索](/docs/workflow/examples/google_search/)
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: "自定义反馈"
|
||||
description: "自定义反馈模块介绍"
|
||||
icon: "feedback"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 354
|
||||
---
|
||||
|
||||
该模块为临时模块,后续会针对该模块进行更全面的设计。
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 无外部输入
|
||||
- 自动执行
|
||||
|
||||
|
||||
| | |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
|
||||
## 介绍
|
||||
|
||||
自定义反馈模块,可以为你的对话增加一个反馈标记,从而方便在后台更好的分析对话的数据。
|
||||
|
||||
在调试模式下,不会记录反馈内容,而是直接提示: `自动反馈测试: 反馈内容`。
|
||||
|
||||
在对话模式(对话、分享窗口、带 chatId 的 API 调用)时,会将反馈内容记录到对话日志中。(会延迟60s记录)
|
||||
|
||||
## 作用
|
||||
|
||||
自定义反馈模块的功能类似于程序开发的`埋点`,便于你观测的对话中的数据。
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: '知识库搜索'
|
||||
description: 'FastGPT AI 知识库搜索模块介绍'
|
||||
icon: 'chat'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 357
|
||||
---
|
||||
|
||||
知识库搜索具体参数说明,以及内部逻辑请移步:[FastGPT知识库搜索方案](/docs/course/data_search/)
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加(复杂编排时防止线太乱,可以更美观)
|
||||
- 有外部输入
|
||||
- 有静态配置
|
||||
- 触发执行
|
||||
- 核心模块
|
||||
|
||||

|
||||
|
||||
## 参数说明
|
||||
|
||||
### 输入 - 关联的知识库
|
||||
|
||||
可以选择一个或多个**相同向量模型**的知识库,用于向量搜索。
|
||||
|
||||
### 输入 - 搜索参数
|
||||
|
||||
[点击查看参数介绍](/docs/course/data_search/#搜索参数)
|
||||
|
||||
### 输出 - 引用内容
|
||||
|
||||
以数组格式输出引用,长度可以为 0。意味着,即使没有搜索到内容,这个输出链路也会走通。
|
||||
253
docSite/content/zh-cn/docs/workflow/modules/http.md
Normal file
253
docSite/content/zh-cn/docs/workflow/modules/http.md
Normal file
@@ -0,0 +1,253 @@
|
||||
---
|
||||
title: "HTTP 模块"
|
||||
description: "FastGPT HTTP 模块介绍"
|
||||
icon: "http"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 355
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 手动配置
|
||||
- 触发执行
|
||||
- 核中核模块
|
||||
|
||||

|
||||
|
||||
## 介绍
|
||||
|
||||
HTTP 模块会向对应的地址发送一个 `HTTP` 请求,实际操作与 Postman 和 ApiFox 这类直流工具使用差不多。
|
||||
|
||||
- Params 为路径请求参数,GET请求中用的居多。
|
||||
- Body 为请求体,POST/PUT请求中用的居多。
|
||||
- Headers 为请求头,用于传递一些特殊的信息。
|
||||
- 自定义变量中可以接收前方节点的输出作为变量
|
||||
- 3 种数据中均可以通过 `{{}}` 来引用变量。
|
||||
- url 也可以通过 `{{}}` 来引用变量。
|
||||
- 变量来自于`全局变量`、`系统变量`、`前方节点输出`
|
||||
|
||||
## 参数结构
|
||||
|
||||
### 系统变量说明
|
||||
|
||||
你可以将鼠标放置在`请求参数`旁边的问号中,里面会提示你可用的变量。
|
||||
|
||||
- appId: 应用的ID
|
||||
- chatId: 当前对话的ID,测试模式下不存在。
|
||||
- responseChatItemId: 当前对话中,响应的消息ID,测试模式下不存在。
|
||||
- variables: 当前对话的全局变量。
|
||||
- cTime: 当前时间。
|
||||
- histories: 历史记录(默认最多取10条,无法修改长度)
|
||||
|
||||
### Params, Headers
|
||||
|
||||
不多描述,使用方法和Postman, ApiFox 基本一致。
|
||||
|
||||
可通过 {{key}} 来引入变量。例如:
|
||||
|
||||
| key | value |
|
||||
| --- | --- |
|
||||
| appId | {{appId}} |
|
||||
| Authorization | Bearer {{token}} |
|
||||
|
||||
### Body
|
||||
|
||||
只有特定请求类型下会生效。
|
||||
|
||||
可以写一个`自定义的 Json`,并通过 {{key}} 来引入变量。例如:
|
||||
|
||||
{{< tabs tabTotal="3" >}}
|
||||
{{< tab tabName="假设有一组变量" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
```json
|
||||
{
|
||||
"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
|
||||
{
|
||||
"message": "测试",
|
||||
"data":{
|
||||
"user": {
|
||||
"name": "xxx",
|
||||
"age": 12
|
||||
},
|
||||
"list": [
|
||||
{
|
||||
"name": "xxx",
|
||||
"age": 50
|
||||
},
|
||||
[{ "test": 22 }]
|
||||
],
|
||||
"psw": "xxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
{{< tab tabName="FastGPT 转化后的格式" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
```json
|
||||
{
|
||||
"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"
|
||||
}
|
||||
```
|
||||
|
||||
{{< /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对话`。
|
||||
|
||||
|
||||
{{% alert context="warning" %}}
|
||||
HTTP模块非常强大,你可以对接一些公开的API,来提高编排的功能。
|
||||
|
||||
如果你不想额外部署服务,可以使用 [Laf](https://laf.dev/) 来快速开发上线接口,即写即发,无需部署。
|
||||
{{% /alert %}}
|
||||
|
||||
## laf 对接 HTTP 示例
|
||||
|
||||
|
||||
下面是在 Laf 编写的 POST 请求示例:
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud'
|
||||
const db = cloud.database()
|
||||
|
||||
type RequestType = {
|
||||
appId: string;
|
||||
appointment: string;
|
||||
action: 'post' | 'delete' | 'put' | 'get'
|
||||
}
|
||||
|
||||
export default async function (ctx: FunctionContext) {
|
||||
try {
|
||||
// 从 body 中获取参数
|
||||
const { appId, appointment, action } = ctx.body as RequestType
|
||||
|
||||
const parseBody = JSON.parse(appointment)
|
||||
if (action === 'get') {
|
||||
return await getRecord(parseBody)
|
||||
}
|
||||
if (action === 'post') {
|
||||
return await createRecord(parseBody)
|
||||
}
|
||||
if (action === 'put') {
|
||||
return await putRecord(parseBody)
|
||||
}
|
||||
if (action === 'delete') {
|
||||
return await removeRecord(parseBody)
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
response: "异常"
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
response: "异常"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 作用
|
||||
|
||||
通过 HTTP 模块你可以无限扩展,比如:
|
||||
- 操作数据库
|
||||
- 调用外部数据源
|
||||
- 执行联网搜索
|
||||
- 发送邮箱
|
||||
- ....
|
||||
|
||||
|
||||
## 相关示例
|
||||
|
||||
- [谷歌搜索](/docs/workflow/examples/google_search/)
|
||||
- [发送飞书webhook](/docs/workflow/examples/feishu_webhook/)
|
||||
- [实验室预约(操作数据库)](/docs/workflow/examples/lab_appointment/)
|
||||
16
docSite/content/zh-cn/docs/workflow/modules/input.md
Normal file
16
docSite/content/zh-cn/docs/workflow/modules/input.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: "对话入口"
|
||||
description: "FastGPT 对话入口模块介绍"
|
||||
icon: "input"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 356
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 流程入口
|
||||
- 无输入
|
||||
- 自动执行
|
||||
|
||||

|
||||
98
docSite/content/zh-cn/docs/workflow/modules/laf.md
Normal file
98
docSite/content/zh-cn/docs/workflow/modules/laf.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: "Laf 函数调用"
|
||||
description: "FastGPT Laf 函数调用模块介绍"
|
||||
icon: "code"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 355
|
||||
---
|
||||
|
||||
|
||||

|
||||
|
||||
## 介绍
|
||||
|
||||
`Laf 函数调用`模块可以调用 Laf 账号下的云函数,其工作原理与 HTTP 模块相同,有以下特殊特征:
|
||||
|
||||
- 只能使用 POST 请求
|
||||
- 请求自带系统参数 systemParams,无需通过变量传递。
|
||||
|
||||
## 绑定 Laf 账号
|
||||
|
||||
要调用 Laf 云函数,首先需要绑定 Laf 账号和应用,并且在应用中创建云函数。
|
||||
|
||||
Laf 提供了 PAT(访问凭证) 来实现 Laf 平台外的快捷登录,可以访问 [Laf 文档](https://doc.Laf.run/zh/cli/#%E7%99%BB%E5%BD%95)查看详细如何获取 PAT。
|
||||
|
||||
在获取到 PAT 后,我们可以进入 FastGPT 的`账号页`或是在高级编排中的 `Laf模块` 对 Laf 账号进行绑定。Laf 账号是团队共享的,仅团队管理员可配置。
|
||||
|
||||
填入 PAT 验证后,选择需要绑定的应用(应用需要是 Running 状态),即可调用该应用下的云函数。
|
||||
|
||||

|
||||
|
||||
## 编写云函数
|
||||
|
||||
Laf 云函数拥有根据 interface 自动生成 OpenAPI 的能力,可以参照下面的代码编写云函数,以便自动生成 OpenAPI 文档。
|
||||
|
||||
`Laf模块`可以根据 OpenAPI 文档,自动识别出入参,无需手动添加数据类型。如果不会写 TS,可忽略,手动在 FastGPT 中添加参数即可。
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud'
|
||||
|
||||
interface IRequestBody { // 自定义入参,FastGPT 传入的均为POST请求。
|
||||
data1: string // 必填参数
|
||||
data2?: string // 可选参数
|
||||
}
|
||||
|
||||
interface RequestProps extends IRequestBody { // 完整入参,这个无需改动。
|
||||
systemParams: { // 这是FastGPT默认会传递过来的参数
|
||||
appId: string,
|
||||
variables: string,
|
||||
histories: string,
|
||||
cTime: string,
|
||||
chatId: string,
|
||||
responseChatItemId: string
|
||||
}
|
||||
}
|
||||
|
||||
interface IResponse { // 响应内容
|
||||
message: string // 必返回的参数
|
||||
msg?: string; // 可选的返回参数
|
||||
}
|
||||
|
||||
export default async function (ctx: FunctionContext): Promise<IResponse> {
|
||||
const {
|
||||
data1,
|
||||
data2,
|
||||
systemParams
|
||||
}: RequestProps = ctx.body;
|
||||
|
||||
console.log({
|
||||
data1,
|
||||
data2,
|
||||
systemParams
|
||||
});
|
||||
|
||||
return {
|
||||
message: 'ok',
|
||||
msg: 'msg'
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
当然,你也可以在 Laf 平台上选择 fastgpt_template,快速生成该函数模板。
|
||||
|
||||
具体操作可以是,进入 Laf 的函数页面,新建函数(注意 fastgpt 只会调用 post 请求的函数),然后复制上面的代码或者点击更多模板搜索“fastgpt”,使用下面的模板
|
||||
|
||||

|
||||
|
||||
## FastGPT 中使用
|
||||
|
||||
在选择函数后,可以通过点击“同步参数”,自动同步云函数的参数到 FastGPT 中。当然也可以手动添加,手动修改后的参数不会被“同步参数”修改。
|
||||
|
||||

|
||||
|
||||
## 使用注意事项
|
||||
|
||||
### 调用报错
|
||||
|
||||
先在 laf 中调试函数,看是否正常调用。可以通过 console.log,打印入参,将入参放在 Laf 测试页面的 Body 中进行测试。
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: "问题分类"
|
||||
description: "FastGPT 问题分类模块介绍"
|
||||
icon: "quiz"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 358
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 需要手动配置
|
||||
- 触发执行
|
||||
- function_call 模块
|
||||
|
||||

|
||||
|
||||
## 功能
|
||||
|
||||
可以将用户的问题进行分类,分类后执行不同操作。在一些较模糊的场景中,分类效果不是很明显。
|
||||
|
||||
## 参数说明
|
||||
|
||||
### 系统提示词
|
||||
|
||||
被放置在对话最前面,可用于补充说明分类内容的定义。例如问题会被分为:
|
||||
|
||||
1. 打招呼
|
||||
2. Laf 常见问题
|
||||
3. 其他问题
|
||||
|
||||
由于 Laf 不是一个明确的东西,需要给它一个定义,此时提示词里可以填入 Laf 的定义:
|
||||
|
||||
```
|
||||
Laf 是云开发平台,可以快速的开发应用
|
||||
Laf 是一个开源的 BaaS 开发平台(Backend as a Service)
|
||||
Laf 是一个开箱即用的 serverless 开发平台
|
||||
Laf 是一个集「函数计算」、「数据库」、「对象存储」等于一身的一站式开发平台
|
||||
Laf 可以是开源版的腾讯云开发、开源版的 Google Firebase、开源版的 UniCloud
|
||||
```
|
||||
|
||||
### 聊天记录
|
||||
|
||||
适当增加一些聊天记录,可以联系上下文进行分类。
|
||||
|
||||
### 用户问题
|
||||
|
||||
用户输入的内容。
|
||||
|
||||
### 分类内容
|
||||
|
||||
依然以这 3 个分类为例,可以看到最终组成的 Function。其中返回值由系统随机生成,不需要关心。
|
||||
|
||||
1. 打招呼
|
||||
2. Laf 常见问题
|
||||
3. 其他问题
|
||||
|
||||
```js
|
||||
const agentFunction = {
|
||||
name: agentFunName,
|
||||
description: '判断用户问题的类型属于哪方面,返回对应的枚举字段',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: `打招呼,返回: abc;Laf 常见问题,返回:vvv;其他问题,返回:aaa`
|
||||
enum: ["abc","vvv","aaa"]
|
||||
}
|
||||
},
|
||||
required: ['type']
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
上面的 Function 必然会返回 `type = abc,vvv,aaa` 其中一个值,从而实现分类判断。
|
||||
26
docSite/content/zh-cn/docs/workflow/modules/reply.md
Normal file
26
docSite/content/zh-cn/docs/workflow/modules/reply.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: "指定回复"
|
||||
description: "FastGPT 指定回复模块介绍"
|
||||
icon: "reply"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 359
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加(防止复杂编排时线太乱,重复添加可以更美观)
|
||||
- 可手动输入
|
||||
- 可外部输入
|
||||
- 会输出结果给客户端
|
||||
|
||||
指定回复模块通常用户特殊状态回复,回复内容有两种:
|
||||
|
||||
1. 一种是手动输入固定内容。
|
||||
2. 一种是通过变量引用。
|
||||
|
||||
{{< figure
|
||||
src="/imgs/specialreply.png"
|
||||
alt=""
|
||||
caption="图 1"
|
||||
>}}
|
||||
32
docSite/content/zh-cn/docs/workflow/modules/text_editor.md
Normal file
32
docSite/content/zh-cn/docs/workflow/modules/text_editor.md
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: "文本加工"
|
||||
description: "FastGPT 文本加工模块介绍"
|
||||
icon: "input"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 363
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 触发执行
|
||||
- 手动配置
|
||||
|
||||

|
||||
|
||||
|
||||
## 功能
|
||||
对输入文本进行固定加工处理,入参仅支持字符串和数字格式,入参以变量形式使用在文本编辑区域。
|
||||
|
||||
根据上方示例图的处理方式,对任何输入都会在前面拼接“用户的问题是:”。
|
||||
|
||||
|
||||
## 作用
|
||||
|
||||
给任意模块输入自定格式文本,或处理 AI 模块系统提示词。
|
||||
|
||||
## 示例
|
||||
|
||||
- [接入谷歌搜索](/docs/workflow/examples/google_search/)
|
||||
31
docSite/content/zh-cn/docs/workflow/modules/tfswitch.md
Normal file
31
docSite/content/zh-cn/docs/workflow/modules/tfswitch.md
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: "判断器"
|
||||
description: "FastGPT 判断器模块介绍"
|
||||
icon: "input"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 362
|
||||
---
|
||||
|
||||
## 特点
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 触发执行
|
||||
|
||||

|
||||
|
||||
## 功能
|
||||
|
||||
对任意变量进行`IF`判断,若满足条件则执行`IF`分支,不满足条件执行`ELSE`分支。
|
||||
|
||||
|
||||
上述例子中若「知识库引用」变量的长度等于0则执行`IF`分支,否则执行`ELSE`分支。
|
||||
|
||||
|
||||
支持增加更多的判断条件和分支,同编程语言中的`IF`语句逻辑相同。
|
||||
|
||||
## 作用
|
||||
|
||||
适用场景有:让大模型做判断后输出固定内容,根据大模型回复内容判断是否触发后续模块。
|
||||
|
||||
59
docSite/content/zh-cn/docs/workflow/modules/tool.md
Normal file
59
docSite/content/zh-cn/docs/workflow/modules/tool.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: "工具调用"
|
||||
description: "FastGPT 工具调用模块介绍"
|
||||
icon: "build"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 356
|
||||
---
|
||||
|
||||

|
||||
|
||||
## 什么是工具
|
||||
|
||||
工具可以是一个系统模块,例如:AI对话、知识库搜索、HTTP模块等。也可以是一个插件。
|
||||
|
||||
工具调用可以让 LLM 更动态的决策流程,而不都是固定的流程。(当然,缺点就是费tokens)
|
||||
|
||||
## 工具的组成
|
||||
|
||||
1. 工具介绍。通常是模块的介绍或插件的介绍,这个介绍会告诉LLM,这个工具的作用是什么。
|
||||
2. 工具参数。对于系统模块来说,工具参数已经是固定的,无需额外配置。对于插件来说,工具参数是一个可配置项。
|
||||
|
||||
## 工具是如何运行的
|
||||
|
||||
要了解工具如何运行的,首先需要知道它的运行条件。
|
||||
|
||||
1. 需要工具的介绍(或者叫描述)。这个介绍会告诉LLM,这个工具的作用是什么,LLM会根据上下文语义,决定是否需要调用这个工具。
|
||||
2. 工具的参数。有些工具调用时,可能需要一些特殊的参数。参数中有2个关键的值:`参数介绍`和`是否必须`。
|
||||
|
||||
结合工具的介绍、参数介绍和参数是否必须,LLM会决定是否调用这个工具。有以下几种情况:
|
||||
|
||||
|
||||
1. 无参数的工具:直接根据工具介绍,决定是否需要执行。例如:获取当前时间。
|
||||
2. 有参数的工具:
|
||||
1. 无必须的参数:尽管上下文中,没有适合的参数,也可以调用该工具。但有时候,LLM会自己伪造一个参数。
|
||||
2. 有必须的参数:如果没有适合的参数,LLM可能不会调用该工具。可以通过提示词,引导用户提供参数。
|
||||
|
||||
### 工具调用逻辑
|
||||
|
||||
在支持`函数调用`的模型中,可以一次性调用多个工具,调用逻辑如下:
|
||||
|
||||

|
||||
|
||||
## 怎么用
|
||||
|
||||
| 有工具调用模块 | 无工具调用模块 |
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|
||||
高级编排中,托动工具调用的连接点,可用的工具头部会出现一个菱形,可以将它与工具调用模块底部的菱形相连接。
|
||||
|
||||
被连接的工具,会自动分离工具输入与普通的输入,并且可以编辑`介绍`,可以通过调整介绍,使得该工具调用时机更加精确。
|
||||
|
||||
关于工具调用,如何调试仍然是一个玄学,所以建议,不要一次性增加太多工具,选择少量工具调优后再进一步尝试。
|
||||
|
||||
## 相关示例
|
||||
|
||||
- [谷歌搜索](/docs/workflow/examples/google_search/)
|
||||
- [发送飞书webhook](/docs/workflow/examples/feishu_webhook/)
|
||||
Reference in New Issue
Block a user