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
dd2d93c9
authored
Apr 24, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: error response
parent
e60c36b4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
27 deletions
+3
-27
src/api/data.ts
+0
-25
src/service/errorCode.ts
+1
-2
src/service/response.ts
+2
-0
No files found.
src/api/data.ts
deleted
100644 → 0
View file @
e60c36b4
import
{
GET
,
POST
,
DELETE
,
PUT
}
from
'./request'
;
import
{
RequestPaging
}
from
'../types/index'
;
import
{
Obj2Query
}
from
'@/utils/tools'
;
import
type
{
DataListItem
}
from
'@/types/data'
;
import
type
{
PagingData
}
from
'../types/index'
;
import
type
{
DataItemSchema
}
from
'@/types/mongoSchema'
;
import
type
{
CreateDataProps
}
from
'@/pages/data/components/CreateDataModal'
;
export
const
getDataList
=
()
=>
GET
<
DataListItem
[]
>
(
`/data/getDataList`
);
export
const
postData
=
(
data
:
CreateDataProps
)
=>
POST
<
string
>
(
`/data/postData`
,
data
);
export
const
postSplitData
=
(
dataId
:
string
,
text
:
string
)
=>
POST
(
`/data/splitData`
,
{
dataId
,
text
});
export
const
updateDataName
=
(
dataId
:
string
,
name
:
string
)
=>
PUT
(
`/data/putDataName?dataId=
${
dataId
}
&name=
${
name
}
`
);
export
const
delData
=
(
dataId
:
string
)
=>
DELETE
(
`/data/delData?dataId=
${
dataId
}
`
);
type
GetDataItemsProps
=
RequestPaging
&
{
dataId
:
string
;
};
export
const
getDataItems
=
(
data
:
GetDataItemsProps
)
=>
GET
<
PagingData
<
DataItemSchema
>>
(
`/data/getDataItems?
${
Obj2Query
(
data
)}
`
);
src/service/errorCode.ts
View file @
dd2d93c9
...
@@ -2,8 +2,7 @@ export const openaiError: Record<string, string> = {
...
@@ -2,8 +2,7 @@ export const openaiError: Record<string, string> = {
context_length_exceeded
:
'内容超长了,请重置对话'
,
context_length_exceeded
:
'内容超长了,请重置对话'
,
Unauthorized
:
'API-KEY 不合法'
,
Unauthorized
:
'API-KEY 不合法'
,
rate_limit_reached
:
'API被限制,请稍后再试'
,
rate_limit_reached
:
'API被限制,请稍后再试'
,
'Bad Request'
:
'Bad Request~ 可能内容太多了'
,
'Bad Request'
:
'Bad Request~ openai 异常'
,
'Too Many Requests'
:
'请求次数太多了,请慢点~'
,
'Bad Gateway'
:
'网关异常,请重试'
'Bad Gateway'
:
'网关异常,请重试'
};
};
export
const
openaiError2
:
Record
<
string
,
string
>
=
{
export
const
openaiError2
:
Record
<
string
,
string
>
=
{
...
...
src/service/response.ts
View file @
dd2d93c9
...
@@ -32,6 +32,8 @@ export const jsonRes = <T = any>(
...
@@ -32,6 +32,8 @@ export const jsonRes = <T = any>(
msg
=
error
;
msg
=
error
;
}
else
if
(
proxyError
[
error
?.
code
])
{
}
else
if
(
proxyError
[
error
?.
code
])
{
msg
=
'服务器代理出错'
;
msg
=
'服务器代理出错'
;
}
else
if
(
error
?.
response
?.
data
?.
error
?.
message
)
{
msg
=
error
?.
response
?.
data
?.
error
?.
message
;
}
else
if
(
openaiError2
[
error
?.
response
?.
data
?.
error
?.
type
])
{
}
else
if
(
openaiError2
[
error
?.
response
?.
data
?.
error
?.
type
])
{
msg
=
openaiError2
[
error
?.
response
?.
data
?.
error
?.
type
];
msg
=
openaiError2
[
error
?.
response
?.
data
?.
error
?.
type
];
}
else
if
(
openaiError
[
error
?.
response
?.
statusText
])
{
}
else
if
(
openaiError
[
error
?.
response
?.
statusText
])
{
...
...
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