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
f19c2d2c
authored
Apr 07, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 去掉raw content
parent
84d91f3f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
23 deletions
+7
-23
src/pages/api/model/data/exportModelData.ts
+5
-16
src/pages/api/model/data/pushModelDataJson.ts
+1
-3
src/service/events/generateVector.ts
+0
-2
src/service/events/pushBill.ts
+1
-2
No files found.
src/pages/api/model/data/exportModelData.ts
View file @
f19c2d2c
...
...
@@ -32,7 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
VecModelDataIdx
,
`@modelId:{
${
modelId
}
} @userId:{
${
userId
}
}`
,
{
RETURN
:
[
'q'
,
'text'
,
'rawVector'
],
RETURN
:
[
'q'
,
'text'
],
LIMIT
:
{
from
:
0
,
size
:
10000
...
...
@@ -40,21 +40,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
}
);
const
data
=
searchRes
.
documents
.
filter
((
item
)
=>
{
if
(
!
item
?.
value
?.
rawVector
)
return
false
;
try
{
JSON
.
parse
(
item
.
value
.
rawVector
as
string
);
return
true
;
}
catch
(
error
)
{
return
false
;
}
})
.
map
((
item
:
any
)
=>
({
prompt
:
item
.
value
.
q
,
completion
:
item
.
value
.
text
,
vector
:
JSON
.
parse
(
item
.
value
.
rawVector
)
}));
const
data
=
searchRes
.
documents
.
map
((
item
:
any
)
=>
({
prompt
:
item
.
value
.
q
,
completion
:
item
.
value
.
text
}));
jsonRes
(
res
,
{
data
:
JSON
.
stringify
(
data
)
...
...
src/pages/api/model/data/pushModelDataJson.ts
View file @
f19c2d2c
...
...
@@ -53,9 +53,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
userId
,
'modelId'
,
String
(
modelId
),
...(
vector
?
[
'vector'
,
vectorToBuffer
(
formatVector
(
vector
)),
'rawVector'
,
JSON
.
stringify
(
vector
)]
:
[]),
...(
vector
?
[
'vector'
,
vectorToBuffer
(
formatVector
(
vector
))]
:
[]),
'q'
,
item
.
prompt
,
'text'
,
...
...
src/service/events/generateVector.ts
View file @
f19c2d2c
...
...
@@ -68,8 +68,6 @@ export async function generateVector(next = false): Promise<any> {
dataItem
.
id
,
'vector'
,
vectorToBuffer
(
vector
),
'rawVector'
,
JSON
.
stringify
(
vector
),
'status'
,
ModelDataStatusEnum
.
ready
]);
...
...
src/service/events/pushBill.ts
View file @
f19c2d2c
import
{
connectToDatabase
,
Bill
,
User
}
from
'../mongo'
;
import
{
modelList
,
ChatModelNameEnum
}
from
'@/constants/model'
;
import
{
encode
}
from
'gpt-token-utils'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
BillTypeEnum
}
from
'@/constants/user'
;
import
type
{
DataType
}
from
'@/types/data'
;
...
...
@@ -22,7 +21,7 @@ export const pushChatBill = async ({
try
{
// 计算 token 数量
const
tokens
=
encode
(
text
).
length
;
const
tokens
=
Math
.
floor
(
encode
(
text
).
length
*
0.7
)
;
console
.
log
(
`chat generate success. text len:
${
text
.
length
}
. token len:
${
tokens
}
`
);
...
...
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