Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
0d887613
authored
Dec 18, 2025
by
Archer
Committed by
GitHub
Dec 18, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: redis del (#6115)
* fix: log * fix: redirect api
parent
527237d0
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
49 additions
and
18 deletions
+49
-18
document/content/docs/introduction/development/openapi/chat.mdx
+5
-5
document/data/doc-last-modified.json
+1
-1
packages/global/openapi/core/app/log/api.ts
+5
-2
packages/service/common/response/index.ts
+15
-4
packages/service/common/system/log.ts
+2
-1
packages/service/core/chat/saveChat.ts
+1
-0
projects/app/src/pages/api/core/chat/clearHistories.ts
+4
-0
projects/app/src/pages/api/core/chat/delHistory.ts
+4
-0
projects/app/src/pages/api/core/chat/getHistories.ts
+4
-0
projects/app/src/pages/api/core/chat/history/batchDelete.ts
+0
-1
projects/app/src/pages/api/core/chat/history/clearHistories.ts
+1
-1
projects/app/src/pages/api/core/chat/history/delHistory.ts
+1
-1
projects/app/src/pages/api/core/chat/history/getHistories.ts
+1
-1
projects/app/src/pages/api/core/chat/history/updateHistory.ts
+1
-1
projects/app/src/pages/api/core/chat/updateHistory.ts
+4
-0
No files found.
document/content/docs/introduction/development/openapi/chat.mdx
View file @
0d887613
...
@@ -616,7 +616,7 @@ event取值:
...
@@ -616,7 +616,7 @@ event取值:
<Tab value="请求示例">
<Tab value="请求示例">
```bash
```bash
curl --location --request POST 'http://localhost:3000/api/core/chat/getHistories' \
curl --location --request POST 'http://localhost:3000/api/core/chat/
history/
getHistories' \
--header 'Authorization: Bearer [apikey]' \
--header 'Authorization: Bearer [apikey]' \
--header 'Content-Type: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
--data-raw '{
...
@@ -679,7 +679,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/getHistories
...
@@ -679,7 +679,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/getHistories
<Tab value="请求示例">
<Tab value="请求示例">
```bash
```bash
curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistory' \
curl --location --request POST 'http://localhost:3000/api/core/chat/
history/
updateHistory' \
--header 'Authorization: Bearer [apikey]' \
--header 'Authorization: Bearer [apikey]' \
--header 'Content-Type: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
--data-raw '{
...
@@ -721,7 +721,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistor
...
@@ -721,7 +721,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistor
<Tab value="请求示例">
<Tab value="请求示例">
```bash
```bash
curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistory' \
curl --location --request POST 'http://localhost:3000/api/core/chat/
history/
updateHistory' \
--header 'Authorization: Bearer [apikey]' \
--header 'Authorization: Bearer [apikey]' \
--header 'Content-Type: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
--data-raw '{
...
@@ -763,7 +763,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistor
...
@@ -763,7 +763,7 @@ curl --location --request POST 'http://localhost:3000/api/core/chat/updateHistor
<Tab value="请求示例">
<Tab value="请求示例">
```bash
```bash
curl --location --request DELETE 'http://localhost:3000/api/core/chat/delHistory?chatId=[chatId]&appId=[appId]' \
curl --location --request DELETE 'http://localhost:3000/api/core/chat/
history/
delHistory?chatId=[chatId]&appId=[appId]' \
--header 'Authorization: Bearer [apikey]'
--header 'Authorization: Bearer [apikey]'
```
```
...
@@ -800,7 +800,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/chat/delHistory
...
@@ -800,7 +800,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/chat/delHistory
<Tab value="请求示例">
<Tab value="请求示例">
```bash
```bash
curl --location --request DELETE 'http://localhost:3000/api/core/chat/clearHistories?appId=[appId]' \
curl --location --request DELETE 'http://localhost:3000/api/core/chat/
history/
clearHistories?appId=[appId]' \
--header 'Authorization: Bearer [apikey]'
--header 'Authorization: Bearer [apikey]'
```
```
...
...
document/data/doc-last-modified.json
View file @
0d887613
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
"document/content/docs/upgrading/4-14/4142.mdx"
:
"2025-11-18T19:27:14+08:00"
,
"document/content/docs/upgrading/4-14/4142.mdx"
:
"2025-11-18T19:27:14+08:00"
,
"document/content/docs/upgrading/4-14/4143.mdx"
:
"2025-11-26T20:52:05+08:00"
,
"document/content/docs/upgrading/4-14/4143.mdx"
:
"2025-11-26T20:52:05+08:00"
,
"document/content/docs/upgrading/4-14/4144.mdx"
:
"2025-12-16T14:56:04+08:00"
,
"document/content/docs/upgrading/4-14/4144.mdx"
:
"2025-12-16T14:56:04+08:00"
,
"document/content/docs/upgrading/4-14/4145.mdx"
:
"2025-12-18T1
0:17:10
+08:00"
,
"document/content/docs/upgrading/4-14/4145.mdx"
:
"2025-12-18T1
1:09:13
+08:00"
,
"document/content/docs/upgrading/4-8/40.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/40.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/41.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/41.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/42.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/42.mdx"
:
"2025-08-02T19:38:37+08:00"
,
...
...
packages/global/openapi/core/app/log/api.ts
View file @
0d887613
...
@@ -31,12 +31,15 @@ export type updateLogKeysBody = z.infer<typeof UpdateLogKeysBodySchema>;
...
@@ -31,12 +31,15 @@ export type updateLogKeysBody = z.infer<typeof UpdateLogKeysBodySchema>;
export
const
ChatLogItemSchema
=
z
.
object
({
export
const
ChatLogItemSchema
=
z
.
object
({
_id
:
z
.
string
().
meta
({
example
:
'68ad85a7463006c963799a05'
,
description
:
'对话日志 ID'
}),
_id
:
z
.
string
().
meta
({
example
:
'68ad85a7463006c963799a05'
,
description
:
'对话日志 ID'
}),
chatId
:
z
.
string
().
meta
({
example
:
'chat123'
,
description
:
'对话 ID'
}),
chatId
:
z
.
string
().
meta
({
example
:
'chat123'
,
description
:
'对话 ID'
}),
title
:
z
.
string
().
optional
().
meta
({
example
:
'用户对话'
,
description
:
'对话标题'
}),
title
:
z
.
string
().
nullish
().
meta
({
example
:
'用户对话'
,
description
:
'对话标题'
}),
customTitle
:
z
.
string
().
nullish
().
meta
({
example
:
'自定义标题'
,
description
:
'自定义对话标题'
}),
customTitle
:
z
.
string
().
nullish
().
meta
({
example
:
'自定义标题'
,
description
:
'自定义对话标题'
}),
source
:
z
.
enum
(
ChatSourceEnum
).
meta
({
example
:
ChatSourceEnum
.
api
,
description
:
'对话来源'
}),
source
:
z
.
enum
(
ChatSourceEnum
).
meta
({
example
:
ChatSourceEnum
.
api
,
description
:
'对话来源'
}),
sourceName
:
z
.
string
().
nullish
().
meta
({
example
:
'API调用'
,
description
:
'来源名称'
}),
sourceName
:
z
.
string
().
nullish
().
meta
({
example
:
'API调用'
,
description
:
'来源名称'
}),
updateTime
:
z
.
date
().
meta
({
example
:
'2024-01-01T00:30:00.000Z'
,
description
:
'更新时间'
}),
updateTime
:
z
.
date
().
meta
({
example
:
'2024-01-01T00:30:00.000Z'
,
description
:
'更新时间'
}),
createTime
:
z
.
date
().
meta
({
example
:
'2024-01-01T00:00:00.000Z'
,
description
:
'创建时间'
}),
createTime
:
z
.
date
()
.
nullish
()
.
meta
({
example
:
'2024-01-01T00:00:00.000Z'
,
description
:
'创建时间'
}),
messageCount
:
z
.
int
().
nullish
().
meta
({
example
:
10
,
description
:
'消息数量'
}),
messageCount
:
z
.
int
().
nullish
().
meta
({
example
:
10
,
description
:
'消息数量'
}),
userGoodFeedbackCount
:
z
.
int
().
nullish
().
meta
({
example
:
3
,
description
:
'好评反馈数量'
}),
userGoodFeedbackCount
:
z
.
int
().
nullish
().
meta
({
example
:
3
,
description
:
'好评反馈数量'
}),
userBadFeedbackCount
:
z
.
int
().
nullish
().
meta
({
example
:
1
,
description
:
'差评反馈数量'
}),
userBadFeedbackCount
:
z
.
int
().
nullish
().
meta
({
example
:
1
,
description
:
'差评反馈数量'
}),
...
...
packages/service/common/response/index.ts
View file @
0d887613
...
@@ -17,8 +17,9 @@ export interface ProcessedError {
...
@@ -17,8 +17,9 @@ export interface ProcessedError {
code
:
number
;
code
:
number
;
statusText
:
string
;
statusText
:
string
;
message
:
string
;
message
:
string
;
data
?:
any
;
shouldClearCookie
:
boolean
;
shouldClearCookie
:
boolean
;
data
?:
any
;
zodError
?:
any
;
}
}
/**
/**
...
@@ -32,6 +33,7 @@ export function processError(params: {
...
@@ -32,6 +33,7 @@ export function processError(params: {
defaultCode
?:
number
;
defaultCode
?:
number
;
}):
ProcessedError
{
}):
ProcessedError
{
const
{
error
,
url
,
defaultCode
=
500
}
=
params
;
const
{
error
,
url
,
defaultCode
=
500
}
=
params
;
let
zodError
;
const
errResponseKey
=
typeof
error
===
'string'
?
error
:
error
?.
message
;
const
errResponseKey
=
typeof
error
===
'string'
?
error
:
error
?.
message
;
...
@@ -67,7 +69,14 @@ export function processError(params: {
...
@@ -67,7 +69,14 @@ export function processError(params: {
if
(
error
instanceof
UserError
)
{
if
(
error
instanceof
UserError
)
{
addLog
.
info
(
`Request error:
${
url
}
,
${
msg
}
`
);
addLog
.
info
(
`Request error:
${
url
}
,
${
msg
}
`
);
}
else
if
(
error
instanceof
ZodError
)
{
}
else
if
(
error
instanceof
ZodError
)
{
addLog
.
error
(
`[Zod] Error in
${
url
}
`
,
error
.
message
);
zodError
=
(()
=>
{
try
{
return
JSON
.
parse
(
error
.
message
);
}
catch
(
error
)
{}
})();
addLog
.
error
(
`[Zod] Error in
${
url
}
`
,
{
data
:
zodError
});
msg
=
error
.
message
;
msg
=
error
.
message
;
}
else
{
}
else
{
addLog
.
error
(
`System unexpected error:
${
url
}
,
${
msg
}
`
,
error
);
addLog
.
error
(
`System unexpected error:
${
url
}
,
${
msg
}
`
,
error
);
...
@@ -78,7 +87,8 @@ export function processError(params: {
...
@@ -78,7 +87,8 @@ export function processError(params: {
code
:
defaultCode
,
code
:
defaultCode
,
statusText
:
'error'
,
statusText
:
'error'
,
message
:
replaceSensitiveText
(
msg
),
message
:
replaceSensitiveText
(
msg
),
shouldClearCookie
:
false
shouldClearCookie
:
false
,
zodError
};
};
}
}
...
@@ -107,7 +117,8 @@ export const jsonRes = <T = any>(
...
@@ -107,7 +117,8 @@ export const jsonRes = <T = any>(
code
:
processedError
.
code
,
code
:
processedError
.
code
,
statusText
:
processedError
.
statusText
,
statusText
:
processedError
.
statusText
,
message
:
message
||
processedError
.
message
,
message
:
message
||
processedError
.
message
,
data
:
processedError
.
data
!==
undefined
?
processedError
.
data
:
null
data
:
processedError
.
data
!==
undefined
?
processedError
.
data
:
null
,
zodError
:
processedError
.
zodError
});
});
return
;
return
;
...
...
packages/service/common/system/log.ts
View file @
0d887613
...
@@ -4,6 +4,7 @@ import { LogLevelEnum } from './log/constant';
...
@@ -4,6 +4,7 @@ import { LogLevelEnum } from './log/constant';
import
{
connectionMongo
}
from
'../mongo/index'
;
import
{
connectionMongo
}
from
'../mongo/index'
;
import
{
getMongoLog
}
from
'./log/schema'
;
import
{
getMongoLog
}
from
'./log/schema'
;
import
{
getLogger
}
from
'../otel/log'
;
import
{
getLogger
}
from
'../otel/log'
;
import
{
getErrText
}
from
'@fastgpt/global/common/error/utils'
;
export
enum
EventTypeEnum
{
export
enum
EventTypeEnum
{
outLinkBot
=
'[Outlink bot]'
,
outLinkBot
=
'[Outlink bot]'
,
...
@@ -151,7 +152,7 @@ export const addLog = {
...
@@ -151,7 +152,7 @@ export const addLog = {
error
(
msg
:
string
,
error
?:
any
)
{
error
(
msg
:
string
,
error
?:
any
)
{
this
.
log
(
LogLevelEnum
.
error
,
msg
,
{
this
.
log
(
LogLevelEnum
.
error
,
msg
,
{
...(
error
?.
data
&&
{
data
:
error
?.
data
}),
...(
error
?.
data
&&
{
data
:
error
?.
data
}),
message
:
error
?.
message
||
error
,
message
:
getErrText
(
error
)
,
stack
:
error
?.
stack
,
stack
:
error
?.
stack
,
...(
error
?.
config
&&
{
...(
error
?.
config
&&
{
config
:
{
config
:
{
...
...
packages/service/core/chat/saveChat.ts
View file @
0d887613
...
@@ -313,6 +313,7 @@ export async function saveChat(props: Props) {
...
@@ -313,6 +313,7 @@ export async function saveChat(props: Props) {
shareId
,
shareId
,
outLinkUid
,
outLinkUid
,
metadata
:
metadataUpdate
,
metadata
:
metadataUpdate
,
createTime
:
new
Date
(),
updateTime
:
new
Date
()
updateTime
:
new
Date
()
}
}
},
},
...
...
projects/app/src/pages/api/core/chat/clearHistories.ts
0 → 100644
View file @
0d887613
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
handler
}
from
'./history/clearHistories'
;
export
default
NextAPI
(
handler
);
projects/app/src/pages/api/core/chat/delHistory.ts
0 → 100644
View file @
0d887613
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
handler
}
from
'./history/delHistory'
;
export
default
NextAPI
(
handler
);
projects/app/src/pages/api/core/chat/getHistories.ts
0 → 100644
View file @
0d887613
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
handler
}
from
'./history/getHistories'
;
export
default
NextAPI
(
handler
);
projects/app/src/pages/api/core/chat/history/batchDelete.ts
View file @
0d887613
...
@@ -9,7 +9,6 @@ import { getS3ChatSource } from '@fastgpt/service/common/s3/sources/chat';
...
@@ -9,7 +9,6 @@ import { getS3ChatSource } from '@fastgpt/service/common/s3/sources/chat';
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
AppReadChatLogPerVal
}
from
'@fastgpt/global/support/permission/app/constant'
;
import
{
AppReadChatLogPerVal
}
from
'@fastgpt/global/support/permission/app/constant'
;
import
{
ChatBatchDeleteBodySchema
}
from
'@fastgpt/global/openapi/core/chat/history/api'
;
import
{
ChatBatchDeleteBodySchema
}
from
'@fastgpt/global/openapi/core/chat/history/api'
;
import
{
UserError
}
from
'@fastgpt/global/common/error/utils'
;
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
const
{
appId
,
chatIds
}
=
ChatBatchDeleteBodySchema
.
parse
(
req
.
body
);
const
{
appId
,
chatIds
}
=
ChatBatchDeleteBodySchema
.
parse
(
req
.
body
);
...
...
projects/app/src/pages/api/core/chat/history/clearHistories.ts
View file @
0d887613
...
@@ -7,7 +7,7 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
...
@@ -7,7 +7,7 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
import
{
authChatCrud
}
from
'@/service/support/permission/auth/chat'
;
import
{
authChatCrud
}
from
'@/service/support/permission/auth/chat'
;
/* clear all chat histories of an app */
/* clear all chat histories of an app */
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
export
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
const
{
appId
,
shareId
,
outLinkUid
,
teamId
,
teamToken
}
=
ClearChatHistoriesSchema
.
parse
(
const
{
appId
,
shareId
,
outLinkUid
,
teamId
,
teamToken
}
=
ClearChatHistoriesSchema
.
parse
(
req
.
query
req
.
query
);
);
...
...
projects/app/src/pages/api/core/chat/history/delHistory.ts
View file @
0d887613
...
@@ -6,7 +6,7 @@ import { NextAPI } from '@/service/middleware/entry';
...
@@ -6,7 +6,7 @@ import { NextAPI } from '@/service/middleware/entry';
import
{
type
ApiRequestProps
}
from
'@fastgpt/service/type/next'
;
import
{
type
ApiRequestProps
}
from
'@fastgpt/service/type/next'
;
/* delete single chat history (soft delete) */
/* delete single chat history (soft delete) */
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
export
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
const
{
appId
,
chatId
}
=
DelChatHistorySchema
.
parse
(
req
.
query
);
const
{
appId
,
chatId
}
=
DelChatHistorySchema
.
parse
(
req
.
query
);
await
authChatCrud
({
await
authChatCrud
({
...
...
projects/app/src/pages/api/core/chat/history/getHistories.ts
View file @
0d887613
...
@@ -14,7 +14,7 @@ import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination';
...
@@ -14,7 +14,7 @@ import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination';
import
{
addMonths
}
from
'date-fns'
;
import
{
addMonths
}
from
'date-fns'
;
/* get chat histories list */
/* get chat histories list */
async
function
handler
(
export
async
function
handler
(
req
:
ApiRequestProps
,
req
:
ApiRequestProps
,
_res
:
ApiResponseType
_res
:
ApiResponseType
):
Promise
<
GetHistoriesResponseType
>
{
):
Promise
<
GetHistoriesResponseType
>
{
...
...
projects/app/src/pages/api/core/chat/history/updateHistory.ts
View file @
0d887613
...
@@ -7,7 +7,7 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
...
@@ -7,7 +7,7 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
import
{
WritePermissionVal
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
WritePermissionVal
}
from
'@fastgpt/global/support/permission/constant'
;
/* update chat history: title, customTitle, top */
/* update chat history: title, customTitle, top */
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
export
async
function
handler
(
req
:
ApiRequestProps
,
res
:
NextApiResponse
)
{
const
{
appId
,
chatId
,
title
,
customTitle
,
top
}
=
UpdateHistoryBodySchema
.
parse
(
req
.
body
);
const
{
appId
,
chatId
,
title
,
customTitle
,
top
}
=
UpdateHistoryBodySchema
.
parse
(
req
.
body
);
await
authChatCrud
({
await
authChatCrud
({
req
,
req
,
...
...
projects/app/src/pages/api/core/chat/updateHistory.ts
0 → 100644
View file @
0d887613
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
handler
}
from
'./history/updateHistory'
;
export
default
NextAPI
(
handler
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment