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
36a0ea7e
authored
Jun 12, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: sensitive check
parent
71dd7f3e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
29 deletions
+27
-29
client/src/pages/api/chat/chat.ts
+1
-1
client/src/pages/api/chat/shareChat/chat.ts
+1
-1
client/src/pages/api/openapi/chat/chat.ts
+1
-1
client/src/pages/api/openapi/text/sensitiveCheck.ts
+24
-17
client/src/service/api/text.ts
+0
-5
client/src/types/plugin.d.ts
+0
-4
No files found.
client/src/pages/api/chat/chat.ts
View file @
36a0ea7e
...
@@ -10,7 +10,7 @@ import { resStreamResponse } from '@/service/utils/chat';
...
@@ -10,7 +10,7 @@ import { resStreamResponse } from '@/service/utils/chat';
import
{
appKbSearch
}
from
'../openapi/kb/appKbSearch'
;
import
{
appKbSearch
}
from
'../openapi/kb/appKbSearch'
;
import
{
ChatRoleEnum
,
QUOTE_LEN_HEADER
,
GUIDE_PROMPT_HEADER
}
from
'@/constants/chat'
;
import
{
ChatRoleEnum
,
QUOTE_LEN_HEADER
,
GUIDE_PROMPT_HEADER
}
from
'@/constants/chat'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
sensitiveCheck
}
from
'
@/service/api/text
'
;
import
{
sensitiveCheck
}
from
'
../openapi/text/sensitiveCheck
'
;
import
{
NEW_CHATID_HEADER
}
from
'@/constants/chat'
;
import
{
NEW_CHATID_HEADER
}
from
'@/constants/chat'
;
import
{
saveChat
}
from
'./saveChat'
;
import
{
saveChat
}
from
'./saveChat'
;
import
{
Types
}
from
'mongoose'
;
import
{
Types
}
from
'mongoose'
;
...
...
client/src/pages/api/chat/shareChat/chat.ts
View file @
36a0ea7e
...
@@ -9,7 +9,7 @@ import { pushChatBill, updateShareChatBill } from '@/service/events/pushBill';
...
@@ -9,7 +9,7 @@ import { pushChatBill, updateShareChatBill } from '@/service/events/pushBill';
import
{
resStreamResponse
}
from
'@/service/utils/chat'
;
import
{
resStreamResponse
}
from
'@/service/utils/chat'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
sensitiveCheck
}
from
'
@/service/api/text
'
;
import
{
sensitiveCheck
}
from
'
../../openapi/text/sensitiveCheck
'
;
import
{
appKbSearch
}
from
'../../openapi/kb/appKbSearch'
;
import
{
appKbSearch
}
from
'../../openapi/kb/appKbSearch'
;
/* 发送提示词 */
/* 发送提示词 */
...
...
client/src/pages/api/openapi/chat/chat.ts
View file @
36a0ea7e
...
@@ -9,7 +9,7 @@ import { pushChatBill } from '@/service/events/pushBill';
...
@@ -9,7 +9,7 @@ import { pushChatBill } from '@/service/events/pushBill';
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
withNextCors
}
from
'@/service/utils/tools'
;
import
{
withNextCors
}
from
'@/service/utils/tools'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
{
sensitiveCheck
}
from
'
@/service/api/text
'
;
import
{
sensitiveCheck
}
from
'
../../openapi/text/sensitiveCheck
'
;
import
{
NEW_CHATID_HEADER
}
from
'@/constants/chat'
;
import
{
NEW_CHATID_HEADER
}
from
'@/constants/chat'
;
import
{
Types
}
from
'mongoose'
;
import
{
Types
}
from
'mongoose'
;
import
{
appKbSearch
}
from
'../kb/appKbSearch'
;
import
{
appKbSearch
}
from
'../kb/appKbSearch'
;
...
...
client/src/pages/api/openapi/text/sensitiveCheck.ts
View file @
36a0ea7e
...
@@ -2,19 +2,35 @@
...
@@ -2,19 +2,35 @@
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
{
jsonRes
}
from
'@/service/response'
;
import
{
jsonRes
}
from
'@/service/response'
;
import
{
authUser
,
getSystemOpenAiKey
}
from
'@/service/utils/auth'
;
import
{
authUser
,
getSystemOpenAiKey
}
from
'@/service/utils/auth'
;
import
type
{
TextPluginRequestParams
}
from
'@/types/plugin'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
axiosConfig
}
from
'@/service/utils/tools'
;
import
{
axiosConfig
}
from
'@/service/utils/tools'
;
export
type
Props
=
{
input
:
string
;
};
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
try
{
try
{
if
(
!
global
.
systemEnv
.
sensitiveCheck
)
{
return
jsonRes
(
res
);
}
await
authUser
({
req
});
await
authUser
({
req
});
const
{
input
}
=
req
.
body
as
TextPluginRequestParams
;
const
result
=
await
sensitiveCheck
(
req
.
body
);
jsonRes
(
res
,
{
data
:
result
,
message
:
result
});
}
catch
(
err
)
{
jsonRes
(
res
,
{
code
:
500
,
error
:
err
});
}
}
export
async
function
sensitiveCheck
({
input
}:
Props
)
{
if
(
!
global
.
systemEnv
.
sensitiveCheck
)
{
return
Promise
.
resolve
(
''
);
}
const
response
=
await
axios
({
const
response
=
await
axios
({
...
axiosConfig
(
getSystemOpenAiKey
(
'chat'
)),
...
axiosConfig
(
getSystemOpenAiKey
(
'chat'
)),
...
@@ -31,18 +47,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -31,18 +47,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
for
(
const
val
of
values
)
{
for
(
const
val
of
values
)
{
if
(
val
>
0.2
)
{
if
(
val
>
0.2
)
{
return
jsonRes
(
res
,
{
return
Promise
.
reject
(
'您的内容不合规'
);
code
:
500
,
message
:
'您的内容不合规'
});
}
}
}
}
jsonRes
(
res
);
return
''
;
}
catch
(
err
)
{
jsonRes
(
res
,
{
code
:
500
,
error
:
err
});
}
}
}
client/src/service/api/text.ts
deleted
100644 → 0
View file @
71dd7f3e
import
{
POST
}
from
'./request'
;
import
type
{
TextPluginRequestParams
}
from
'@/types/plugin'
;
export
const
sensitiveCheck
=
(
data
:
TextPluginRequestParams
)
=>
POST
(
'/openapi/text/sensitiveCheck'
,
data
);
client/src/types/plugin.d.ts
View file @
36a0ea7e
...
@@ -19,7 +19,3 @@ export type KbTestItemType = {
...
@@ -19,7 +19,3 @@ export type KbTestItemType = {
time
:
Date
;
time
:
Date
;
results
:
(
KbDataItemType
&
{
score
:
number
})[];
results
:
(
KbDataItemType
&
{
score
:
number
})[];
};
};
export
type
TextPluginRequestParams
=
{
input
:
string
;
};
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