mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-31 03:22:18 +00:00
modules
This commit is contained in:
@@ -1 +1,50 @@
|
||||
# 内容提取
|
||||
# Content Extraction
|
||||
|
||||
- Repeatable addition
|
||||
- External input
|
||||
- Manual configuration
|
||||
- Trigger execution
|
||||
- function_call module
|
||||
- Core module
|
||||
|
||||

|
||||
|
||||
## Functionality
|
||||
|
||||
Extract structured data from text, usually in conjunction with the HTTP module for extension. It can also perform direct extraction operations, such as translation.
|
||||
|
||||
## Parameter Description
|
||||
|
||||
### Extraction Requirement Description
|
||||
|
||||
As the name suggests, give the model a target and specify which content needs to be extracted.
|
||||
|
||||
**Example 1**
|
||||
|
||||
> You are a lab reservation assistant, extract the name, appointment time, and lab number from the conversation. Current time is {{cTime}}.
|
||||
|
||||
**Example 2**
|
||||
|
||||
> You are a Google search assistant, extract the search keywords from the conversation.
|
||||
|
||||
**Example 3**
|
||||
|
||||
> Translate my question directly into English, do not answer the question.
|
||||
|
||||
### History Records
|
||||
|
||||
Usually, some history records are needed to extract user questions more completely. For example, in the figure above, the name, time, and lab name need to be provided in advance. The user may only provide the time and lab name at the beginning, without giving their own name. After a round of missing prompts, the user enters their name. At this time, it is necessary to combine the previous record to extract all 3 contents completely.
|
||||
|
||||
### Target Fields
|
||||
|
||||
The target fields correspond to the extracted results. From the figure above, it can be seen that for each additional field, there will be a corresponding output.
|
||||
key: The unique identifier of the field, cannot be repeated!
|
||||
Field Description: Describes what the field is about, such as name, time, search term, etc.
|
||||
Required: Whether to force the model to extract the field, it may be extracted as an empty string.
|
||||
|
||||
## Output Introduction
|
||||
|
||||
- Field fully extracted: Indicates that the user's question contains all the content that needs to be extracted.
|
||||
- Missing extracted fields: The opposite of "Field fully extracted", triggered when there are missing extracted fields.
|
||||
- Complete extraction result: A JSON string containing the extraction results of all fields.
|
||||
- Extraction results of target fields: All types are strings.
|
||||
|
69
docSite/docs/flow-modules/modules/cq.md
Normal file
69
docSite/docs/flow-modules/modules/cq.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Problem Classification
|
||||
|
||||
- Can be added repeatedly
|
||||
- Has external input
|
||||
- Manual configuration
|
||||
- Trigger execution
|
||||
- function_call module
|
||||
|
||||

|
||||
|
||||
## Functionality
|
||||
|
||||
It can classify user questions and perform different operations based on the classification. In some ambiguous scenarios, the classification effect may not be very obvious.
|
||||
|
||||
## Parameter Description
|
||||
|
||||
### System Prompt Words
|
||||
|
||||
Placed at the beginning of the conversation, it can be used to supplement the definition of the classification content. For example, questions will be classified into:
|
||||
|
||||
1. Greetings
|
||||
2. Common questions about laf
|
||||
3. Other questions
|
||||
|
||||
Because laf is not a clear concept and needs to be defined, the prompt words can be filled with the definition of laf:
|
||||
|
||||
```
|
||||
laf is a cloud development platform that allows for rapid application development.
|
||||
laf is an open-source BaaS (Backend as a Service) development platform.
|
||||
laf is a ready-to-use serverless development platform.
|
||||
laf is an all-in-one development platform that combines "function computing," "database," "object storage," and more.
|
||||
laf can be an open-source version of Tencent Cloud Development, Google Firebase, or UniCloud.
|
||||
```
|
||||
|
||||
### Chat Records
|
||||
|
||||
Adding some chat records can help with context-based classification.
|
||||
|
||||
### User Question
|
||||
|
||||
The input content from the user.
|
||||
|
||||
### Classification Content
|
||||
|
||||
Using the example of these 3 classifications, you can see the final function composition. The return value is randomly generated by the system and does not need to be concerned about.
|
||||
|
||||
1. Greetings
|
||||
2. Common questions about laf
|
||||
3. Other questions
|
||||
|
||||
```js
|
||||
const agentFunction = {
|
||||
name: agentFunName,
|
||||
description: 'Determines the type of user question and returns the corresponding enumeration field',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: `Greetings, return: abc; Common questions about laf, return: vvv; Other questions, return: aaa`
|
||||
enum: ["abc","vvv","aaa"]
|
||||
}
|
||||
},
|
||||
required: ['type']
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
The above function will definitely return one of the values: abc, vvv, or aaa, thereby achieving classification determination.
|
@@ -1 +1,88 @@
|
||||
# HTTP 模块
|
||||
# HTTP Module
|
||||
|
||||
- Can be added repeatedly
|
||||
- Has external input
|
||||
- Manual configuration
|
||||
- Trigger execution
|
||||
- Core module
|
||||
|
||||

|
||||
|
||||
## Introduction
|
||||
|
||||
The HTTP module sends a POST request to the corresponding address, with json parameters in the body. The specific parameters can be customized. It also receives a json response value, with customizable fields. In the above figure, we define an input parameter: extracted field (key is appointment, type is string), and an output parameter: extraction result (key is response, type is string).
|
||||
|
||||
So, the curl command for this request is:
|
||||
|
||||
```curl
|
||||
curl --location --request POST 'https://xxxx.laf.dev/appointment-lab' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"appointment":"{\"name\":\"小明\",\"time\":\"2023/08/16 15:00\",\"labname\":\"子良A323\"}"
|
||||
}'
|
||||
```
|
||||
|
||||
The response is:
|
||||
|
||||
```json
|
||||
{
|
||||
"response": "您已经有一个预约记录了,每人仅能同时预约一个实验室:\n 姓名:小明\n 时间: 2023/08/15 15:00\n 实验室: 子良A323\n "
|
||||
}
|
||||
```
|
||||
|
||||
**If you don't want to deploy additional services, you can use laf to quickly build interfaces, write and send them without deployment**
|
||||
|
||||
[laf online address](https://laf.dev/)
|
||||
|
||||
Here is a request example:
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud';
|
||||
const db = cloud.database();
|
||||
export default async function (ctx: FunctionContext) {
|
||||
const { appointment } = ctx.body;
|
||||
const { name, time, labname } = JSON.parse(appointment);
|
||||
const missData = [];
|
||||
if (!name) missData.push('你的姓名');
|
||||
if (!time) missData.push('需要预约的时间');
|
||||
if (!labname) missData.push('实验室名称');
|
||||
if (missData.length > 0) {
|
||||
return {
|
||||
response: `请提供: ${missData.join('、')}`
|
||||
};
|
||||
}
|
||||
const { data: record } = await db
|
||||
.collection('LabAppointment')
|
||||
.where({
|
||||
name,
|
||||
status: 'unStart'
|
||||
})
|
||||
.getOne();
|
||||
if (record) {
|
||||
return {
|
||||
response: `您已经有一个预约记录了,每人仅能同时预约一个实验室:
|
||||
姓名:${record.name}
|
||||
时间: ${record.time}
|
||||
实验室: ${record.labname}
|
||||
`
|
||||
};
|
||||
}
|
||||
await db.collection('LabAppointment').add({
|
||||
name,
|
||||
time,
|
||||
labname,
|
||||
status: 'unStart'
|
||||
});
|
||||
return {
|
||||
response: `预约成功。
|
||||
姓名:${name}
|
||||
时间: ${time}
|
||||
实验室: ${labname}
|
||||
`
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
With the HTTP module, you can do unlimited extensions, such as manipulating databases, performing internet searches, sending emails, and so on. If you have interesting use cases, feel free to submit a PR to [Examples](/docs/category/examples)
|
||||
|
BIN
docSite/docs/flow-modules/modules/imgs/cq1.png
Normal file
BIN
docSite/docs/flow-modules/modules/imgs/cq1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
BIN
docSite/docs/flow-modules/modules/imgs/extract1.png
Normal file
BIN
docSite/docs/flow-modules/modules/imgs/extract1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
BIN
docSite/docs/flow-modules/modules/imgs/http1.png
Normal file
BIN
docSite/docs/flow-modules/modules/imgs/http1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user