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
72a9307e
authored
Aug 16, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: chat data outsize
parent
2f81fbc4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
45 deletions
+60
-45
client/src/pages/account/index.tsx
+1
-0
client/src/service/response.ts
+2
-2
client/src/service/utils/chat/saveChat.ts
+57
-43
No files found.
client/src/pages/account/index.tsx
View file @
72a9307e
...
...
@@ -11,6 +11,7 @@ import SideTabs from '@/components/SideTabs';
import
Tabs
from
'@/components/Tabs'
;
import
UserInfo
from
'./components/Info'
;
import
{
serviceSideProps
}
from
'@/utils/i18n'
;
import
{
feConfigs
}
from
'@/store/static'
;
const
BillTable
=
dynamic
(()
=>
import
(
'./components/BillTable'
),
{
ssr
:
false
...
...
client/src/service/response.ts
View file @
72a9307e
...
...
@@ -52,7 +52,7 @@ export const jsonRes = <T = any>(
}
else
if
(
openaiError
[
error
?.
response
?.
statusText
])
{
msg
=
openaiError
[
error
.
response
.
statusText
];
}
console
.
log
(
error
);
console
.
log
(
error
?.
response
);
}
res
.
status
(
code
).
json
({
...
...
@@ -92,7 +92,7 @@ export const sseErrRes = (res: NextApiResponse, error: any) => {
}
else
if
(
openaiError
[
error
?.
response
?.
statusText
])
{
msg
=
openaiError
[
error
.
response
.
statusText
];
}
console
.
log
(
'sse error => '
,
error
);
console
.
log
(
'sse error => '
,
error
?.
response
);
sseResponse
({
res
,
...
...
client/src/service/utils/chat/saveChat.ts
View file @
72a9307e
...
...
@@ -23,54 +23,68 @@ export async function saveChat({
shareId
,
content
}:
Props
)
{
const
chatHistory
=
await
Chat
.
findOne
(
{
chatId
,
userId
},
'_id'
);
try
{
const
chatHistory
=
await
Chat
.
findOne
(
{
chatId
,
userId
},
'_id'
);
const
promise
=
[];
const
promise
=
[];
if
(
chatHistory
)
{
promise
.
push
(
Chat
.
updateOne
(
{
chatId
,
userId
},
{
$push
:
{
content
:
{
$each
:
content
,
$slice
:
-
50
}
},
if
(
chatHistory
)
{
promise
.
push
(
Chat
.
updateOne
(
{
chatId
,
userId
},
{
$push
:
{
content
:
{
$each
:
content
,
$slice
:
-
40
}
},
title
:
content
[
0
].
value
.
slice
(
0
,
20
),
updateTime
:
new
Date
()
}
)
);
}
else
{
promise
.
push
(
Chat
.
create
({
chatId
,
userId
,
appId
,
variables
,
title
:
content
[
0
].
value
.
slice
(
0
,
20
),
source
,
shareId
,
content
:
content
})
);
}
if
(
isOwner
&&
source
===
ChatSourceEnum
.
online
)
{
promise
.
push
(
App
.
findByIdAndUpdate
(
appId
,
{
updateTime
:
new
Date
()
}
)
);
}
else
{
promise
.
push
(
Chat
.
create
({
chatId
,
userId
,
appId
,
variables
,
title
:
content
[
0
].
value
.
slice
(
0
,
20
),
source
,
shareId
,
content
:
content
})
);
}
})
);
}
if
(
isOwner
&&
source
===
ChatSourceEnum
.
online
)
{
promise
.
push
(
App
.
findByIdAndUpdate
(
appId
,
{
updateTime
:
new
Date
()
})
await
Promise
.
all
(
promise
);
}
catch
(
error
)
{
Chat
.
updateOne
(
{
chatId
,
userId
},
{
$push
:
{
content
:
{
$each
:
[],
$slice
:
-
10
}
}
}
);
}
await
Promise
.
all
(
promise
);
}
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