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
e4aeee7b
authored
Jun 14, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: token count
parent
8036ed61
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
12 deletions
+16
-12
client/src/pages/api/openapi/kb/pushData.ts
+10
-7
client/src/pages/kb/components/Detail.tsx
+1
-0
client/src/service/pg.ts
+3
-3
client/src/service/utils/chat/claude.ts
+1
-1
client/src/service/utils/chat/openai.ts
+1
-1
No files found.
client/src/pages/api/openapi/kb/pushData.ts
View file @
e4aeee7b
...
@@ -76,14 +76,17 @@ export async function pushDataToKb({
...
@@ -76,14 +76,17 @@ export async function pushDataToKb({
data
.
forEach
((
item
)
=>
{
data
.
forEach
((
item
)
=>
{
const
text
=
item
.
q
+
item
.
a
;
const
text
=
item
.
q
+
item
.
a
;
// count token
if
(
mode
===
TrainingModeEnum
.
qa
)
{
const
token
=
modelToolMap
[
OpenAiChatEnum
.
GPT35
].
countTokens
({
// count token
messages
:
[{
obj
:
'System'
,
value
:
item
.
q
}]
const
token
=
modelToolMap
[
OpenAiChatEnum
.
GPT35
].
countTokens
({
});
messages
:
[{
obj
:
'System'
,
value
:
item
.
q
}]
});
if
(
token
>
modeMaxToken
[
TrainingModeEnum
.
qa
])
{
return
;
}
}
if
(
mode
===
TrainingModeEnum
.
qa
&&
token
>
modeMaxToken
[
TrainingModeEnum
.
qa
])
{
if
(
!
set
.
has
(
text
))
{
console
.
log
(
'q is too long'
);
}
else
if
(
!
set
.
has
(
text
))
{
filterData
.
push
(
item
);
filterData
.
push
(
item
);
set
.
add
(
text
);
set
.
add
(
text
);
}
}
...
...
client/src/pages/kb/components/Detail.tsx
View file @
e4aeee7b
...
@@ -40,6 +40,7 @@ const Detail = ({ kbId }: { kbId: string }) => {
...
@@ -40,6 +40,7 @@ const Detail = ({ kbId }: { kbId: string }) => {
onSuccess
(
res
)
{
onSuccess
(
res
)
{
kbId
&&
setLastKbId
(
kbId
);
kbId
&&
setLastKbId
(
kbId
);
if
(
res
)
{
if
(
res
)
{
setCurrentTab
(
TabEnum
.
data
);
reset
(
res
);
reset
(
res
);
BasicInfo
.
current
?.
initInput
?.(
res
.
tags
);
BasicInfo
.
current
?.
initInput
?.(
res
.
tags
);
}
}
...
...
client/src/service/pg.ts
View file @
e4aeee7b
...
@@ -12,9 +12,9 @@ export const connectPg = async () => {
...
@@ -12,9 +12,9 @@ export const connectPg = async () => {
user
:
process
.
env
.
PG_USER
,
user
:
process
.
env
.
PG_USER
,
password
:
process
.
env
.
PG_PASSWORD
,
password
:
process
.
env
.
PG_PASSWORD
,
database
:
process
.
env
.
PG_DB_NAME
,
database
:
process
.
env
.
PG_DB_NAME
,
max
:
8
0
,
max
:
global
.
systemEnv
.
vectorMaxProcess
+
1
0
,
idleTimeoutMillis
:
6
0000
,
idleTimeoutMillis
:
3
0000
,
connectionTimeoutMillis
:
20
000
connectionTimeoutMillis
:
5
000
});
});
global
.
pgClient
.
on
(
'error'
,
(
err
)
=>
{
global
.
pgClient
.
on
(
'error'
,
(
err
)
=>
{
...
...
client/src/service/utils/chat/claude.ts
View file @
e4aeee7b
...
@@ -24,7 +24,7 @@ export const claudChat = async ({ apiKey, messages, stream, chatId }: ChatComple
...
@@ -24,7 +24,7 @@ export const claudChat = async ({ apiKey, messages, stream, chatId }: ChatComple
headers
:
{
headers
:
{
Authorization
:
apiKey
Authorization
:
apiKey
},
},
timeout
:
stream
?
60000
:
24
0000
,
timeout
:
stream
?
60000
:
48
0000
,
responseType
:
stream
?
'stream'
:
'json'
responseType
:
stream
?
'stream'
:
'json'
}
}
);
);
...
...
client/src/service/utils/chat/openai.ts
View file @
e4aeee7b
...
@@ -42,7 +42,7 @@ export const chatResponse = async ({
...
@@ -42,7 +42,7 @@ export const chatResponse = async ({
stop
:
[
'.!?。'
]
stop
:
[
'.!?。'
]
},
},
{
{
timeout
:
stream
?
60000
:
24
0000
,
timeout
:
stream
?
60000
:
48
0000
,
responseType
:
stream
?
'stream'
:
'json'
,
responseType
:
stream
?
'stream'
:
'json'
,
...
axiosConfig
(
apiKey
)
...
axiosConfig
(
apiKey
)
}
}
...
...
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