Doc (#2910)
* feat: add app chat openapi (#2908) * add chat openapi * create question guide openapi * change auth method * add chat openapi doc * delete unused code * feat: chat openapi doc * rerank doc * add chat detail openapi & doc * update chat openapi doc --------- Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: heheer <1239331448@qq.com>
This commit is contained in:
parent
27ef4dc8ea
commit
d55ccc9f64
@ -77,7 +77,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
|||||||
`4` OpenAPI 接口
|
`4` OpenAPI 接口
|
||||||
- [x] completions 接口 (chat 模式对齐 GPT 接口)
|
- [x] completions 接口 (chat 模式对齐 GPT 接口)
|
||||||
- [x] 知识库 CRUD
|
- [x] 知识库 CRUD
|
||||||
- [ ] 对话 CRUD
|
- [x] 对话 CRUD
|
||||||
|
|
||||||
`5` 运营能力
|
`5` 运营能力
|
||||||
- [x] 免登录分享窗口
|
- [x] 免登录分享窗口
|
||||||
|
|||||||
@ -227,6 +227,27 @@ weight: 708
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ReRank 接入(硅基流动)
|
||||||
|
|
||||||
|
有免费的 `bge-reranker-v2-m3` 模型可以使用。
|
||||||
|
|
||||||
|
1. 注册硅基流动账号: https://siliconflow.cn/
|
||||||
|
2. 进入控制台,获取 API key: https://cloud.siliconflow.cn/account/ak
|
||||||
|
3. 修改 FastGPT 配置文件
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"reRankModels": [
|
||||||
|
{
|
||||||
|
"model": "BAAI/bge-reranker-v2-m3", // 这里的model需要对应 siliconflow 的模型名
|
||||||
|
"name": "BAAI/bge-reranker-v2-m3",
|
||||||
|
"requestUrl": "https://api.siliconflow.cn/v1/rerank",
|
||||||
|
"requestAuth": "siliconflow 上申请的 key"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### ReRank 接入(Cohere)
|
### ReRank 接入(Cohere)
|
||||||
|
|
||||||
这个重排模型对中文不是很好,不如 bge 的好用。
|
这个重排模型对中文不是很好,不如 bge 的好用。
|
||||||
@ -239,7 +260,7 @@ weight: 708
|
|||||||
"reRankModels": [
|
"reRankModels": [
|
||||||
{
|
{
|
||||||
"model": "rerank-multilingual-v2.0", // 这里的model需要对应 cohere 的模型名
|
"model": "rerank-multilingual-v2.0", // 这里的model需要对应 cohere 的模型名
|
||||||
"name": "检索重排", // 随意
|
"name": "rerank-multilingual-v2.0",
|
||||||
"requestUrl": "https://api.cohere.ai/v1/rerank",
|
"requestUrl": "https://api.cohere.ai/v1/rerank",
|
||||||
"requestAuth": "Coherer上申请的key"
|
"requestAuth": "Coherer上申请的key"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,15 @@ toc: true
|
|||||||
weight: 852
|
weight: 852
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# 发起对话
|
||||||
|
|
||||||
{{% alert icon="🤖 " context="success" %}}
|
{{% alert icon="🤖 " context="success" %}}
|
||||||
* 该接口的 API Key 需使用`应用特定的 key`,否则会报错。
|
* 该接口的 API Key 需使用`应用特定的 key`,否则会报错。
|
||||||
|
|
||||||
* 有些包调用时,`BaseUrl`需要添加`v1`路径,有些不需要,如果出现404情况,可补充`v1`重试。
|
* 有些包调用时,`BaseUrl`需要添加`v1`路径,有些不需要,如果出现404情况,可补充`v1`重试。
|
||||||
{{% /alert %}}
|
{{% /alert %}}
|
||||||
|
|
||||||
## 发起对话(简易应用和工作流)
|
## 请求简易应用和工作流
|
||||||
|
|
||||||
对话接口兼容`GPT`的接口!如果你的项目使用的是标准的`GPT`官方接口,可以直接通过修改`BaseUrl`和 `Authorization`来访问 FastGpt 应用,不过需要注意下面几个规则:
|
对话接口兼容`GPT`的接口!如果你的项目使用的是标准的`GPT`官方接口,可以直接通过修改`BaseUrl`和 `Authorization`来访问 FastGpt 应用,不过需要注意下面几个规则:
|
||||||
|
|
||||||
@ -24,12 +26,12 @@ weight: 852
|
|||||||
|
|
||||||
### 请求
|
### 请求
|
||||||
|
|
||||||
{{< tabs tabTotal="2" >}}
|
{{< tabs tabTotal="3" >}}
|
||||||
{{< tab tabName="请求示例" >}}
|
{{< tab tabName="基础请求示例" >}}
|
||||||
{{< markdownify >}}
|
{{< markdownify >}}
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \
|
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
|
||||||
--header 'Authorization: Bearer fastgpt-xxxxxx' \
|
--header 'Authorization: Bearer fastgpt-xxxxxx' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@ -42,8 +44,49 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
|
|||||||
},
|
},
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
|
"role": "user",
|
||||||
"content": "导演是谁",
|
"content": "导演是谁",
|
||||||
"role": "user"
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="图片/文件请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
* 仅`messages`有部分区别,其他参数一致。
|
||||||
|
* 目前不支持上次文件,需上传到自己的对象存储中,获取对应的文件链接。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
|
||||||
|
--header 'Authorization: Bearer fastgpt-xxxxxx' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"chatId": "abcd",
|
||||||
|
"stream": false,
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "导演是谁"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image_url",
|
||||||
|
"image_url": {
|
||||||
|
"url": "图片链接"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "file_url",
|
||||||
|
"name": "文件名",
|
||||||
|
"url": "文档链接,支持 txt md html word pdf ppt csv excel"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
@ -269,7 +312,6 @@ event取值:
|
|||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 请求插件
|
## 请求插件
|
||||||
|
|
||||||
插件的接口与对话接口一致,仅请求参数略有区别,有以下规定:
|
插件的接口与对话接口一致,仅请求参数略有区别,有以下规定:
|
||||||
@ -455,8 +497,728 @@ event取值:
|
|||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
## 使用案例
|
|
||||||
|
|
||||||
- [接入 NextWeb/ChatGPT web 等应用](/docs/course/openapi)
|
|
||||||
- [接入 onwechat](/docs/use-cases/onwechat)
|
# 对话 CRUD
|
||||||
- [接入 飞书](/docs/course/feishu)
|
|
||||||
|
{{% alert icon="🤖 " context="success" %}}
|
||||||
|
* 以下接口可使用任意`API Key`调用。
|
||||||
|
* 4.8.12 以上版本才能使用
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
**重要字段**
|
||||||
|
|
||||||
|
* chatId - 指一个应用下,某一个对话窗口的 ID
|
||||||
|
* dataId - 指一个对话窗口下,某一个对话记录的 ID
|
||||||
|
|
||||||
|
## 历史记录
|
||||||
|
|
||||||
|
### 获取某个应用历史记录
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/getHistories' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"offset": 0,
|
||||||
|
"pageSize": 20
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- offset - 偏移量,即从第几条数据开始取
|
||||||
|
- pageSize - 记录数量
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"chatId": "usdAP1GbzSGu",
|
||||||
|
"updateTime": "2024-10-13T03:29:05.779Z",
|
||||||
|
"appId": "66e29b870b24ce35330c0f08",
|
||||||
|
"customTitle": "",
|
||||||
|
"title": "你好",
|
||||||
|
"top": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chatId": "lC0uTAsyNBlZ",
|
||||||
|
"updateTime": "2024-10-13T03:22:19.950Z",
|
||||||
|
"appId": "66e29b870b24ce35330c0f08",
|
||||||
|
"customTitle": "",
|
||||||
|
"title": "测试",
|
||||||
|
"top": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"total": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 修改某个对话的标题
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistory' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"chatId": "chatId",
|
||||||
|
"customTitle": "自定义标题"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- customTitle - 自定义对话名
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 置顶 / 取消置顶
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistory' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"chatId": "chatId",
|
||||||
|
"top": true
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- top - 是否置顶,ture 置顶,false 取消置顶
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 删除某个历史记录
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request DELETE 'http://localhost:3000/api/core/chat/delHistory?chatId={{chatId}}&appId={{appId}}' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 清空所有历史记录
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request DELETE 'http://localhost:3000/api/core/chat/clearHistories?appId={{appId}}' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
## 对话记录
|
||||||
|
|
||||||
|
指的是某个 chatId 下的对话记录操作。
|
||||||
|
|
||||||
|
### 获取单个对话初始化信息
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request GET 'http://localhost:3000/api/core/chat/init?appId={{appId}}&chatId={{chatId}}' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}'
|
||||||
|
```
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"chatId": "sPVOuEohjo3w",
|
||||||
|
"appId": "66e29b870b24ce35330c0f08",
|
||||||
|
"variables": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"chatConfig": {
|
||||||
|
"questionGuide": true,
|
||||||
|
"ttsConfig": {
|
||||||
|
"type": "web"
|
||||||
|
},
|
||||||
|
"whisperConfig": {
|
||||||
|
"open": false,
|
||||||
|
"autoSend": false,
|
||||||
|
"autoTTSResponse": false
|
||||||
|
},
|
||||||
|
"chatInputGuide": {
|
||||||
|
"open": false,
|
||||||
|
"textList": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"customUrl": ""
|
||||||
|
},
|
||||||
|
"instruction": "",
|
||||||
|
"variables": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"fileSelectConfig": {
|
||||||
|
"canSelectFile": true,
|
||||||
|
"canSelectImg": true,
|
||||||
|
"maxFiles": 10
|
||||||
|
},
|
||||||
|
"_id": "66f1139aaab9ddaf1b5c596d",
|
||||||
|
"welcomeText": ""
|
||||||
|
},
|
||||||
|
"chatModels": [
|
||||||
|
"GPT-4o-mini"
|
||||||
|
],
|
||||||
|
"name": "测试",
|
||||||
|
"avatar": "/imgs/app/avatar/workflow.svg",
|
||||||
|
"intro": "",
|
||||||
|
"type": "advanced",
|
||||||
|
"pluginInputs": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 获取对话记录列表
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/getPaginationRecords' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"chatId": "chatId",
|
||||||
|
"offset": 0,
|
||||||
|
"pageSize": 10,
|
||||||
|
"loadCustomFeedbacks": true
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- offset - 偏移量
|
||||||
|
- pageSize - 记录数量
|
||||||
|
- loadCustomFeedbacks - 是否读取自定义反馈(可选)
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"_id": "670b84e6796057dda04b0fd2",
|
||||||
|
"dataId": "jzqdV4Ap1u004rhd2WW8yGLn",
|
||||||
|
"obj": "Human",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": {
|
||||||
|
"content": "你好"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customFeedbacks": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_id": "670b84e6796057dda04b0fd3",
|
||||||
|
"dataId": "x9KQWcK9MApGdDQH7z7bocw1",
|
||||||
|
"obj": "AI",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": {
|
||||||
|
"content": "你好!有什么我可以帮助你的吗?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customFeedbacks": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"llmModuleAccount": 1,
|
||||||
|
"totalQuoteList": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"totalRunningTime": 2.42,
|
||||||
|
"historyPreviewLength": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"total": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 获取单个对话记录运行详情
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request GET 'http://localhost:3000/api/core/chat/getResData?appId={{appId}}&chatId={{chatId}}&dataId={{dataId}}' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 对话 Id
|
||||||
|
- dataId - 对话记录 Id
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "mVlxkz8NfyfU",
|
||||||
|
"nodeId": "448745",
|
||||||
|
"moduleName": "common:core.module.template.work_start",
|
||||||
|
"moduleType": "workflowStart",
|
||||||
|
"runningTime": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b3FndAdHSobY",
|
||||||
|
"nodeId": "z04w8JXSYjl3",
|
||||||
|
"moduleName": "AI 对话",
|
||||||
|
"moduleType": "chatNode",
|
||||||
|
"runningTime": 1.22,
|
||||||
|
"totalPoints": 0.02475,
|
||||||
|
"model": "GPT-4o-mini",
|
||||||
|
"tokens": 75,
|
||||||
|
"query": "测试",
|
||||||
|
"maxToken": 2000,
|
||||||
|
"historyPreview": [
|
||||||
|
{
|
||||||
|
"obj": "Human",
|
||||||
|
"value": "你好"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"obj": "AI",
|
||||||
|
"value": "你好!有什么我可以帮助你的吗?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"obj": "Human",
|
||||||
|
"value": "测试"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"obj": "AI",
|
||||||
|
"value": "测试成功!请问你有什么具体的问题或者需要讨论的话题吗?"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"contextTotalLen": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
|
### 删除对话记录
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request DELETE 'http://localhost:3000/api/core/chat/item/delete?contentId={{contentId}}&chatId={{chatId}}&appId={{appId}}' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- contentId - 对话记录 Id
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 点赞 / 取消点赞
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/feedback/updateUserFeedback' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"chatId": "chatId",
|
||||||
|
"dataId": "dataId",
|
||||||
|
"userGoodFeedback": "yes"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- dataId - 对话记录 Id
|
||||||
|
- userGoodFeedback - 用户点赞时的信息(可选),取消点赞时不填此参数即可
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
### 点踩 / 取消点踩
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/chat/feedback/updateUserFeedback' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"appId": "appId",
|
||||||
|
"chatId": "chatId",
|
||||||
|
"dataId": "dataId",
|
||||||
|
"userBadFeedback": "yes"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- appId - 应用 Id
|
||||||
|
- chatId - 历史记录 Id
|
||||||
|
- dataId - 对话记录 Id
|
||||||
|
- userBadFeedback - 用户点踩时的信息(可选),取消点踩时不填此参数即可
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
## 猜你想问
|
||||||
|
|
||||||
|
{{< tabs tabTotal="3" >}}
|
||||||
|
{{< tab tabName="请求示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/core/ai/agent/createQuestionGuide' \
|
||||||
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"messages":[
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "你好"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "你好!有什么我可以帮助你的吗?"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="参数说明" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
{{% alert icon=" " context="success" %}}
|
||||||
|
- messages - 对话消息,提供给 AI 的消息记录
|
||||||
|
{{% /alert %}}
|
||||||
|
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
|
||||||
|
{{< tab tabName="响应示例" >}}
|
||||||
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"statusText": "",
|
||||||
|
"message": "",
|
||||||
|
"data": [
|
||||||
|
"你对AI有什么看法?",
|
||||||
|
"想了解AI的应用吗?",
|
||||||
|
"你希望AI能做什么?"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{{< /markdownify >}}
|
||||||
|
{{< /tab >}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ weight: 853
|
|||||||
**新例子**
|
**新例子**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/usage/createTrainingUsage' \
|
curl --location --request POST 'http://localhost:3000/api/support/wallet/usage/createTrainingUsage' \
|
||||||
--header 'Authorization: Bearer {{apikey}}' \
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
@ -34,7 +34,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/usage/
|
|||||||
**x例子**
|
**x例子**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/bill/createTrainingBill' \
|
curl --location --request POST 'http://localhost:3000/api/support/wallet/bill/createTrainingBill' \
|
||||||
--header 'Authorization: Bearer {{apikey}}' \
|
--header 'Authorization: Bearer {{apikey}}' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
|
|||||||
2
packages/global/core/chat/api.d.ts
vendored
2
packages/global/core/chat/api.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
export type UpdateChatFeedbackProps = {
|
export type UpdateChatFeedbackProps = {
|
||||||
appId: string;
|
appId: string;
|
||||||
chatId: string;
|
chatId: string;
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
shareId?: string;
|
shareId?: string;
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
teamToken?: string;
|
teamToken?: string;
|
||||||
|
|||||||
2
packages/global/core/chat/type.d.ts
vendored
2
packages/global/core/chat/type.d.ts
vendored
@ -100,7 +100,7 @@ export type ChatItemSchema = (UserChatItemType | SystemChatItemType | AIChatItem
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type AdminFbkType = {
|
export type AdminFbkType = {
|
||||||
dataId: string;
|
feedbackDataId: string;
|
||||||
datasetId: string;
|
datasetId: string;
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
q: string;
|
q: string;
|
||||||
|
|||||||
@ -55,22 +55,22 @@ export const adaptStringValue = (value: any): ChatItemValueItemType[] => {
|
|||||||
export const addCustomFeedbacks = async ({
|
export const addCustomFeedbacks = async ({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
feedbacks
|
feedbacks
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
chatId?: string;
|
chatId?: string;
|
||||||
chatItemId?: string;
|
dataId?: string;
|
||||||
feedbacks: string[];
|
feedbacks: string[];
|
||||||
}) => {
|
}) => {
|
||||||
if (!chatId || !chatItemId) return;
|
if (!chatId || !dataId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await MongoChatItem.findOneAndUpdate(
|
await MongoChatItem.findOneAndUpdate(
|
||||||
{
|
{
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
dataId: chatItemId
|
dataId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$push: { customFeedbacks: { $each: feedbacks } }
|
$push: { customFeedbacks: { $each: feedbacks } }
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export const dispatchCustomFeedback = (props: Record<string, any>): Response =>
|
|||||||
const {
|
const {
|
||||||
runningAppInfo: { id: appId },
|
runningAppInfo: { id: appId },
|
||||||
chatId,
|
chatId,
|
||||||
responseChatItemId: chatItemId,
|
responseChatItemId: dataId,
|
||||||
stream,
|
stream,
|
||||||
workflowStreamResponse,
|
workflowStreamResponse,
|
||||||
params: { system_textareaInput: feedbackText = '' }
|
params: { system_textareaInput: feedbackText = '' }
|
||||||
@ -27,13 +27,13 @@ export const dispatchCustomFeedback = (props: Record<string, any>): Response =>
|
|||||||
addCustomFeedbacks({
|
addCustomFeedbacks({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
feedbacks: [feedbackText]
|
feedbacks: [feedbackText]
|
||||||
});
|
});
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
if (!chatId || !chatItemId) {
|
if (!chatId || !dataId) {
|
||||||
workflowStreamResponse?.({
|
workflowStreamResponse?.({
|
||||||
event: SseResponseEventEnum.fastAnswer,
|
event: SseResponseEventEnum.fastAnswer,
|
||||||
data: textAdaptGptResponse({
|
data: textAdaptGptResponse({
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { updateChatUserFeedback } from '@/web/core/chat/api';
|
|||||||
const FeedbackModal = ({
|
const FeedbackModal = ({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
shareId,
|
shareId,
|
||||||
@ -18,7 +18,7 @@ const FeedbackModal = ({
|
|||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
chatId: string;
|
chatId: string;
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
shareId?: string;
|
shareId?: string;
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
teamToken?: string;
|
teamToken?: string;
|
||||||
@ -35,7 +35,7 @@ const FeedbackModal = ({
|
|||||||
return updateChatUserFeedback({
|
return updateChatUserFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
shareId,
|
shareId,
|
||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React from 'react';
|
||||||
import { ModalBody, useTheme, ModalFooter, Button, Box, Card, Flex, Grid } from '@chakra-ui/react';
|
import { ModalBody, useTheme, ModalFooter, Button, Box, Card, Flex, Grid } from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
@ -13,7 +13,7 @@ import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
|||||||
const InputDataModal = dynamic(() => import('@/pages/dataset/detail/components/InputDataModal'));
|
const InputDataModal = dynamic(() => import('@/pages/dataset/detail/components/InputDataModal'));
|
||||||
|
|
||||||
export type AdminMarkType = {
|
export type AdminMarkType = {
|
||||||
dataId?: string;
|
feedbackDataId?: string;
|
||||||
datasetId?: string;
|
datasetId?: string;
|
||||||
collectionId?: string;
|
collectionId?: string;
|
||||||
q: string;
|
q: string;
|
||||||
@ -137,7 +137,7 @@ const SelectMarkCollection = ({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
collectionId={adminMarkData.collectionId}
|
collectionId={adminMarkData.collectionId}
|
||||||
dataId={adminMarkData.dataId}
|
dataId={adminMarkData.feedbackDataId}
|
||||||
defaultValue={{
|
defaultValue={{
|
||||||
q: adminMarkData.q,
|
q: adminMarkData.q,
|
||||||
a: adminMarkData.a
|
a: adminMarkData.a
|
||||||
@ -153,7 +153,7 @@ const SelectMarkCollection = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSuccess({
|
onSuccess({
|
||||||
dataId: data.dataId,
|
feedbackDataId: data.dataId,
|
||||||
datasetId: adminMarkData.datasetId,
|
datasetId: adminMarkData.datasetId,
|
||||||
collectionId: adminMarkData.collectionId,
|
collectionId: adminMarkData.collectionId,
|
||||||
q: data.q,
|
q: data.q,
|
||||||
|
|||||||
@ -142,10 +142,10 @@ const ChatBox = (
|
|||||||
|
|
||||||
const [feedbackId, setFeedbackId] = useState<string>();
|
const [feedbackId, setFeedbackId] = useState<string>();
|
||||||
const [readFeedbackData, setReadFeedbackData] = useState<{
|
const [readFeedbackData, setReadFeedbackData] = useState<{
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
content: string;
|
content: string;
|
||||||
}>();
|
}>();
|
||||||
const [adminMarkData, setAdminMarkData] = useState<AdminMarkType & { chatItemId: string }>();
|
const [adminMarkData, setAdminMarkData] = useState<AdminMarkType & { dataId: string }>();
|
||||||
const [questionGuides, setQuestionGuide] = useState<string[]>([]);
|
const [questionGuides, setQuestionGuide] = useState<string[]>([]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -660,16 +660,16 @@ const ChatBox = (
|
|||||||
|
|
||||||
if (chat.adminFeedback) {
|
if (chat.adminFeedback) {
|
||||||
setAdminMarkData({
|
setAdminMarkData({
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
datasetId: chat.adminFeedback.datasetId,
|
datasetId: chat.adminFeedback.datasetId,
|
||||||
collectionId: chat.adminFeedback.collectionId,
|
collectionId: chat.adminFeedback.collectionId,
|
||||||
dataId: chat.adminFeedback.dataId,
|
feedbackDataId: chat.adminFeedback.feedbackDataId,
|
||||||
q: chat.adminFeedback.q || q || '',
|
q: chat.adminFeedback.q || q || '',
|
||||||
a: chat.adminFeedback.a
|
a: chat.adminFeedback.a
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setAdminMarkData({
|
setAdminMarkData({
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
q,
|
q,
|
||||||
a: formatChatValue2InputType(chat.value).text
|
a: formatChatValue2InputType(chat.value).text
|
||||||
});
|
});
|
||||||
@ -703,7 +703,7 @@ const ChatBox = (
|
|||||||
chatId,
|
chatId,
|
||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
shareId,
|
shareId,
|
||||||
outLinkUid,
|
outLinkUid,
|
||||||
userGoodFeedback: isGoodFeedback ? undefined : 'yes'
|
userGoodFeedback: isGoodFeedback ? undefined : 'yes'
|
||||||
@ -725,7 +725,7 @@ const ChatBox = (
|
|||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
userGoodFeedback: undefined
|
userGoodFeedback: undefined
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -750,7 +750,7 @@ const ChatBox = (
|
|||||||
updateChatUserFeedback({
|
updateChatUserFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
shareId,
|
shareId,
|
||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
@ -767,7 +767,7 @@ const ChatBox = (
|
|||||||
return () => {
|
return () => {
|
||||||
if (!chat.dataId) return;
|
if (!chat.dataId) return;
|
||||||
setReadFeedbackData({
|
setReadFeedbackData({
|
||||||
chatItemId: chat.dataId || '',
|
dataId: chat.dataId || '',
|
||||||
content: chat.userBadFeedback || ''
|
content: chat.userBadFeedback || ''
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -778,7 +778,7 @@ const ChatBox = (
|
|||||||
closeCustomFeedback({
|
closeCustomFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: chat.dataId,
|
dataId: chat.dataId,
|
||||||
index: i
|
index: i
|
||||||
});
|
});
|
||||||
// update dom
|
// update dom
|
||||||
@ -945,7 +945,7 @@ const ChatBox = (
|
|||||||
text={t('common:core.app.feedback.Custom feedback')}
|
text={t('common:core.app.feedback.Custom feedback')}
|
||||||
/>
|
/>
|
||||||
{item.customFeedbacks.map((text, i) => (
|
{item.customFeedbacks.map((text, i) => (
|
||||||
<Box key={`${text}${i}`}>
|
<Box key={i}>
|
||||||
<MyTooltip
|
<MyTooltip
|
||||||
label={t('common:core.app.feedback.close custom feedback')}
|
label={t('common:core.app.feedback.close custom feedback')}
|
||||||
>
|
>
|
||||||
@ -1035,7 +1035,7 @@ const ChatBox = (
|
|||||||
teamId={teamId}
|
teamId={teamId}
|
||||||
teamToken={teamToken}
|
teamToken={teamToken}
|
||||||
chatId={chatId}
|
chatId={chatId}
|
||||||
chatItemId={feedbackId}
|
dataId={feedbackId}
|
||||||
shareId={shareId}
|
shareId={shareId}
|
||||||
outLinkUid={outLinkUid}
|
outLinkUid={outLinkUid}
|
||||||
onClose={() => setFeedbackId(undefined)}
|
onClose={() => setFeedbackId(undefined)}
|
||||||
@ -1057,7 +1057,7 @@ const ChatBox = (
|
|||||||
onCloseFeedback={() => {
|
onCloseFeedback={() => {
|
||||||
setChatHistories((state) =>
|
setChatHistories((state) =>
|
||||||
state.map((chatItem) =>
|
state.map((chatItem) =>
|
||||||
chatItem.dataId === readFeedbackData.chatItemId
|
chatItem.dataId === readFeedbackData.dataId
|
||||||
? { ...chatItem, userBadFeedback: undefined }
|
? { ...chatItem, userBadFeedback: undefined }
|
||||||
: chatItem
|
: chatItem
|
||||||
)
|
)
|
||||||
@ -1067,7 +1067,7 @@ const ChatBox = (
|
|||||||
updateChatUserFeedback({
|
updateChatUserFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: readFeedbackData.chatItemId
|
dataId: readFeedbackData.dataId
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
setReadFeedbackData(undefined);
|
setReadFeedbackData(undefined);
|
||||||
@ -1078,21 +1078,21 @@ const ChatBox = (
|
|||||||
{!!adminMarkData && (
|
{!!adminMarkData && (
|
||||||
<SelectMarkCollection
|
<SelectMarkCollection
|
||||||
adminMarkData={adminMarkData}
|
adminMarkData={adminMarkData}
|
||||||
setAdminMarkData={(e) => setAdminMarkData({ ...e, chatItemId: adminMarkData.chatItemId })}
|
setAdminMarkData={(e) => setAdminMarkData({ ...e, dataId: adminMarkData.dataId })}
|
||||||
onClose={() => setAdminMarkData(undefined)}
|
onClose={() => setAdminMarkData(undefined)}
|
||||||
onSuccess={(adminFeedback) => {
|
onSuccess={(adminFeedback) => {
|
||||||
if (!appId || !chatId || !adminMarkData.chatItemId) return;
|
if (!appId || !chatId || !adminMarkData.dataId) return;
|
||||||
updateChatAdminFeedback({
|
updateChatAdminFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: adminMarkData.chatItemId,
|
dataId: adminMarkData.dataId,
|
||||||
...adminFeedback
|
...adminFeedback
|
||||||
});
|
});
|
||||||
|
|
||||||
// update dom
|
// update dom
|
||||||
setChatHistories((state) =>
|
setChatHistories((state) =>
|
||||||
state.map((chatItem) =>
|
state.map((chatItem) =>
|
||||||
chatItem.dataId === adminMarkData.chatItemId
|
chatItem.dataId === adminMarkData.dataId
|
||||||
? {
|
? {
|
||||||
...chatItem,
|
...chatItem,
|
||||||
adminFeedback
|
adminFeedback
|
||||||
@ -1105,12 +1105,12 @@ const ChatBox = (
|
|||||||
updateChatUserFeedback({
|
updateChatUserFeedback({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId: readFeedbackData.chatItemId,
|
dataId: readFeedbackData.dataId,
|
||||||
userBadFeedback: undefined
|
userBadFeedback: undefined
|
||||||
});
|
});
|
||||||
setChatHistories((state) =>
|
setChatHistories((state) =>
|
||||||
state.map((chatItem) =>
|
state.map((chatItem) =>
|
||||||
chatItem.dataId === readFeedbackData.chatItemId
|
chatItem.dataId === readFeedbackData.dataId
|
||||||
? { ...chatItem, userBadFeedback: undefined }
|
? { ...chatItem, userBadFeedback: undefined }
|
||||||
: chatItem
|
: chatItem
|
||||||
)
|
)
|
||||||
|
|||||||
4
projects/app/src/global/core/chat/api.d.ts
vendored
4
projects/app/src/global/core/chat/api.d.ts
vendored
@ -84,12 +84,12 @@ export type DeleteChatItemProps = OutLinkChatAuthProps & {
|
|||||||
export type AdminUpdateFeedbackParams = AdminFbkType & {
|
export type AdminUpdateFeedbackParams = AdminFbkType & {
|
||||||
appId: string;
|
appId: string;
|
||||||
chatId: string;
|
chatId: string;
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CloseCustomFeedbackParams = {
|
export type CloseCustomFeedbackParams = {
|
||||||
appId: string;
|
appId: string;
|
||||||
chatId: string;
|
chatId: string;
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
index: number;
|
index: number;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,7 +13,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
|
|
||||||
const { tmbId, teamId } = await authChatCert({
|
const { tmbId, teamId } = await authChatCert({
|
||||||
req,
|
req,
|
||||||
authToken: true
|
authToken: true,
|
||||||
|
authApiKey: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const qgModel = global.llmModels[0];
|
const qgModel = global.llmModels[0];
|
||||||
|
|||||||
@ -36,7 +36,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (appId) {
|
if (appId) {
|
||||||
const { tmbId } = await authCert({ req, authToken: true });
|
const { tmbId } = await authCert({ req, authToken: true, authApiKey: true });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tmbId,
|
tmbId,
|
||||||
|
|||||||
@ -17,6 +17,7 @@ async function handler(req: ApiRequestProps<{}, DelHistoryProps>, res: NextApiRe
|
|||||||
await authChatCrud({
|
await authChatCrud({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
...req.query,
|
...req.query,
|
||||||
per: WritePermissionVal
|
per: WritePermissionVal
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,10 +10,10 @@ import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
|||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
try {
|
try {
|
||||||
await connectToDatabase();
|
await connectToDatabase();
|
||||||
const { appId, chatId, chatItemId, datasetId, dataId, q, a } =
|
const { appId, chatId, dataId, datasetId, feedbackDataId, q, a } =
|
||||||
req.body as AdminUpdateFeedbackParams;
|
req.body as AdminUpdateFeedbackParams;
|
||||||
|
|
||||||
if (!chatItemId || !datasetId || !dataId || !q) {
|
if (!dataId || !datasetId || !feedbackDataId || !q) {
|
||||||
throw new Error('missing parameter');
|
throw new Error('missing parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,12 +29,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
{
|
{
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
dataId: chatItemId
|
dataId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
adminFeedback: {
|
adminFeedback: {
|
||||||
datasetId,
|
datasetId,
|
||||||
dataId,
|
dataId: feedbackDataId,
|
||||||
q,
|
q,
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,14 +6,15 @@ import type { CloseCustomFeedbackParams } from '@/global/core/chat/api.d';
|
|||||||
import { MongoChatItem } from '@fastgpt/service/core/chat/chatItemSchema';
|
import { MongoChatItem } from '@fastgpt/service/core/chat/chatItemSchema';
|
||||||
import { authChatCrud } from '@/service/support/permission/auth/chat';
|
import { authChatCrud } from '@/service/support/permission/auth/chat';
|
||||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||||
|
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
|
||||||
|
|
||||||
/* remove custom feedback */
|
/* remove custom feedback */
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
try {
|
try {
|
||||||
await connectToDatabase();
|
await connectToDatabase();
|
||||||
const { appId, chatId, chatItemId, index } = req.body as CloseCustomFeedbackParams;
|
const { appId, chatId, dataId, index } = req.body as CloseCustomFeedbackParams;
|
||||||
|
|
||||||
if (!chatItemId || !appId || !chatId || !chatItemId) {
|
if (!dataId || !appId || !chatId) {
|
||||||
throw new Error('missing parameter');
|
throw new Error('missing parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,10 +27,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
});
|
});
|
||||||
await authCert({ req, authToken: true });
|
await authCert({ req, authToken: true });
|
||||||
|
|
||||||
await MongoChatItem.findOneAndUpdate(
|
await mongoSessionRun(async (session) => {
|
||||||
{ appId, chatId, dataId: chatItemId },
|
await MongoChatItem.findOneAndUpdate(
|
||||||
{ $unset: { [`customFeedbacks.${index}`]: 1 } }
|
{ appId, chatId, dataId },
|
||||||
);
|
{ $unset: { [`customFeedbacks.${index}`]: 1 } },
|
||||||
|
{
|
||||||
|
session
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await MongoChatItem.findOneAndUpdate(
|
||||||
|
{ appId, chatId, dataId },
|
||||||
|
{ $pull: { customFeedbacks: null } },
|
||||||
|
{
|
||||||
|
session
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
jsonRes(res);
|
jsonRes(res);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
const {
|
const {
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
shareId,
|
shareId,
|
||||||
teamId,
|
teamId,
|
||||||
teamToken,
|
teamToken,
|
||||||
@ -36,15 +36,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
per: ReadPermissionVal
|
per: ReadPermissionVal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!chatItemId) {
|
if (!dataId) {
|
||||||
throw new Error('chatItemId is required');
|
throw new Error('dataId is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
await MongoChatItem.findOneAndUpdate(
|
await MongoChatItem.findOneAndUpdate(
|
||||||
{
|
{
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
dataId: chatItemId
|
dataId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$unset: {
|
$unset: {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ async function handler(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (appId) {
|
if (appId) {
|
||||||
const { tmbId } = await authCert({ req, authToken: true });
|
const { tmbId } = await authCert({ req, authToken: true, authApiKey: true });
|
||||||
return {
|
return {
|
||||||
tmbId,
|
tmbId,
|
||||||
appId,
|
appId,
|
||||||
|
|||||||
@ -26,7 +26,14 @@ async function handler(
|
|||||||
req: ApiRequestProps<getPaginationRecordsBody, getPaginationRecordsQuery>,
|
req: ApiRequestProps<getPaginationRecordsBody, getPaginationRecordsQuery>,
|
||||||
res: ApiResponseType<any>
|
res: ApiResponseType<any>
|
||||||
): Promise<getPaginationRecordsResponse> {
|
): Promise<getPaginationRecordsResponse> {
|
||||||
const { chatId, appId, offset, pageSize = 10, loadCustomFeedbacks, type } = req.body;
|
const {
|
||||||
|
appId,
|
||||||
|
chatId,
|
||||||
|
offset,
|
||||||
|
pageSize = 10,
|
||||||
|
loadCustomFeedbacks,
|
||||||
|
type = GetChatTypeEnum.normal
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
if (!appId || !chatId) {
|
if (!appId || !chatId) {
|
||||||
return {
|
return {
|
||||||
@ -40,6 +47,7 @@ async function handler(
|
|||||||
authChatCrud({
|
authChatCrud({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
...req.body,
|
...req.body,
|
||||||
per: ReadPermissionVal
|
per: ReadPermissionVal
|
||||||
})
|
})
|
||||||
|
|||||||
@ -37,6 +37,7 @@ async function handler(
|
|||||||
await authChatCrud({
|
await authChatCrud({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
...req.query,
|
...req.query,
|
||||||
per: ReadPermissionVal
|
per: ReadPermissionVal
|
||||||
});
|
});
|
||||||
@ -44,6 +45,7 @@ async function handler(
|
|||||||
await authApp({
|
await authApp({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
appId,
|
appId,
|
||||||
per: ManagePermissionVal
|
per: ManagePermissionVal
|
||||||
});
|
});
|
||||||
|
|||||||
@ -29,6 +29,7 @@ async function handler(
|
|||||||
authApp({
|
authApp({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
appId,
|
appId,
|
||||||
per: ReadPermissionVal
|
per: ReadPermissionVal
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiResponse } from 'next';
|
||||||
import { jsonRes } from '@fastgpt/service/common/response';
|
import { jsonRes } from '@fastgpt/service/common/response';
|
||||||
import { connectToDatabase } from '@/service/mongo';
|
|
||||||
import { MongoChatItem } from '@fastgpt/service/core/chat/chatItemSchema';
|
import { MongoChatItem } from '@fastgpt/service/core/chat/chatItemSchema';
|
||||||
import { authChatCrud } from '@/service/support/permission/auth/chat';
|
import { authChatCrud } from '@/service/support/permission/auth/chat';
|
||||||
import type { DeleteChatItemProps } from '@/global/core/chat/api.d';
|
import type { DeleteChatItemProps } from '@/global/core/chat/api.d';
|
||||||
@ -9,7 +8,7 @@ import { ApiRequestProps } from '@fastgpt/service/type/next';
|
|||||||
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
|
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||||
|
|
||||||
async function handler(req: ApiRequestProps<{}, DeleteChatItemProps>, res: NextApiResponse) {
|
async function handler(req: ApiRequestProps<{}, DeleteChatItemProps>, res: NextApiResponse) {
|
||||||
const { appId, chatId, contentId, shareId, outLinkUid } = req.query;
|
const { appId, chatId, contentId } = req.query;
|
||||||
|
|
||||||
if (!contentId || !chatId) {
|
if (!contentId || !chatId) {
|
||||||
return jsonRes(res);
|
return jsonRes(res);
|
||||||
@ -18,6 +17,7 @@ async function handler(req: ApiRequestProps<{}, DeleteChatItemProps>, res: NextA
|
|||||||
await authChatCrud({
|
await authChatCrud({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
...req.query,
|
...req.query,
|
||||||
per: WritePermissionVal
|
per: WritePermissionVal
|
||||||
});
|
});
|
||||||
|
|||||||
@ -24,7 +24,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
throw new Error('model or voice not found');
|
throw new Error('model or voice not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { teamId, tmbId, authType } = await authChatCert({ req, authToken: true });
|
const { teamId, tmbId, authType } = await authChatCert({
|
||||||
|
req,
|
||||||
|
authToken: true,
|
||||||
|
authApiKey: true
|
||||||
|
});
|
||||||
|
|
||||||
const ttsModel = getAudioSpeechModel(ttsConfig.model);
|
const ttsModel = getAudioSpeechModel(ttsConfig.model);
|
||||||
const voiceData = ttsModel.voices?.find((item) => item.value === ttsConfig.voice);
|
const voiceData = ttsModel.voices?.find((item) => item.value === ttsConfig.voice);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiResponse } from 'next';
|
||||||
import { jsonRes } from '@fastgpt/service/common/response';
|
import { jsonRes } from '@fastgpt/service/common/response';
|
||||||
import { UpdateHistoryProps } from '@/global/core/chat/api.d';
|
import { UpdateHistoryProps } from '@/global/core/chat/api.d';
|
||||||
import { MongoChat } from '@fastgpt/service/core/chat/chatSchema';
|
import { MongoChat } from '@fastgpt/service/core/chat/chatSchema';
|
||||||
@ -13,6 +13,7 @@ async function handler(req: ApiRequestProps<UpdateHistoryProps>, res: NextApiRes
|
|||||||
await authChatCrud({
|
await authChatCrud({
|
||||||
req,
|
req,
|
||||||
authToken: true,
|
authToken: true,
|
||||||
|
authApiKey: true,
|
||||||
...req.body,
|
...req.body,
|
||||||
per: WritePermissionVal
|
per: WritePermissionVal
|
||||||
});
|
});
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
const {
|
const {
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
responseChatItemId: chatItemId,
|
responseChatItemId: dataId,
|
||||||
defaultFeedback,
|
defaultFeedback,
|
||||||
customFeedback
|
customFeedback
|
||||||
} = req.body as Props;
|
} = req.body as Props;
|
||||||
@ -38,12 +38,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
addCustomFeedbacks({
|
addCustomFeedbacks({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
feedbacks: [feedback]
|
feedbacks: [feedback]
|
||||||
});
|
});
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
if (!chatId || !chatItemId) {
|
if (!chatId || !dataId) {
|
||||||
return res.json({
|
return res.json({
|
||||||
response: `\\n\\n**自动反馈调试**: ${feedback}\\n\\n`
|
response: `\\n\\n**自动反馈调试**: ${feedback}\\n\\n`
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
customFeedback,
|
customFeedback,
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
responseChatItemId: chatItemId,
|
responseChatItemId: dataId,
|
||||||
customInputs
|
customInputs
|
||||||
} = req.body as Props;
|
} = req.body as Props;
|
||||||
|
|
||||||
@ -37,12 +37,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
addCustomFeedbacks({
|
addCustomFeedbacks({
|
||||||
appId,
|
appId,
|
||||||
chatId,
|
chatId,
|
||||||
chatItemId,
|
dataId,
|
||||||
feedbacks: [feedbackText]
|
feedbacks: [feedbackText]
|
||||||
});
|
});
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
if (!chatId || !chatItemId) {
|
if (!chatId || !dataId) {
|
||||||
return res.json({
|
return res.json({
|
||||||
[NodeOutputKeyEnum.answerText]: `\\n\\n**自动反馈调试**: "${feedbackText}"\\n\\n`,
|
[NodeOutputKeyEnum.answerText]: `\\n\\n**自动反馈调试**: "${feedbackText}"\\n\\n`,
|
||||||
text: feedbackText
|
text: feedbackText
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { devtools, persist } from 'zustand/middleware';
|
import { devtools } from 'zustand/middleware';
|
||||||
import { immer } from 'zustand/middleware/immer';
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
export type MarkDataStore = {
|
export type MarkDataStore = {
|
||||||
chatItemId: string;
|
dataId: string;
|
||||||
datasetId?: string;
|
datasetId?: string;
|
||||||
collectionId?: string;
|
collectionId?: string;
|
||||||
q: string;
|
q: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user