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
9a0c9262
authored
May 12, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: token params
parent
651eb1bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
src/service/plugins/searchKb.ts
+6
-1
src/service/utils/chat/claude.ts
+1
-1
src/service/utils/chat/openai.ts
+2
-2
No files found.
src/service/plugins/searchKb.ts
View file @
9a0c9262
...
...
@@ -29,6 +29,11 @@ export const searchKb = async ({
}[];
}
>
=>
{
async
function
search
(
textArr
:
string
[]
=
[])
{
const
limitMap
:
Record
<
ModelVectorSearchModeEnum
,
number
>
=
{
[
ModelVectorSearchModeEnum
.
hightSimilarity
]:
15
,
[
ModelVectorSearchModeEnum
.
noContext
]:
15
,
[
ModelVectorSearchModeEnum
.
lowSimilarity
]:
20
};
// 获取提示词的向量
const
{
vectors
:
promptVectors
}
=
await
openaiCreateEmbedding
({
userOpenAiKey
,
...
...
@@ -48,7 +53,7 @@ export const searchKb = async ({
`vector <=> '[
${
promptVector
}
]' <
${
similarity
}
`
],
order
:
[{
field
:
'vector'
,
mode
:
`<=> '[
${
promptVector
}
]'`
}],
limit
:
20
limit
:
limitMap
[
model
.
chat
.
searchMode
]
}).
then
((
res
)
=>
res
.
rows
)
)
);
...
...
src/service/utils/chat/claude.ts
View file @
9a0c9262
...
...
@@ -40,7 +40,7 @@ export const lafClaudChat = async ({
headers
:
{
Authorization
:
apiKey
},
timeout
:
stream
?
4
0000
:
240000
,
timeout
:
stream
?
6
0000
:
240000
,
responseType
:
stream
?
'stream'
:
'json'
}
);
...
...
src/service/utils/chat/openai.ts
View file @
9a0c9262
...
...
@@ -73,7 +73,7 @@ export const chatResponse = async ({
const
filterMessages
=
ChatContextFilter
({
model
,
prompts
:
messages
,
maxTokens
:
Math
.
ceil
(
ChatModelMap
[
model
].
contextMaxToken
*
0.
9
)
maxTokens
:
Math
.
ceil
(
ChatModelMap
[
model
].
contextMaxToken
*
0.
85
)
});
const
adaptMessages
=
adaptChatItem_openAI
({
messages
:
filterMessages
});
...
...
@@ -90,7 +90,7 @@ export const chatResponse = async ({
stop
:
[
'.!?。'
]
},
{
timeout
:
stream
?
4
0000
:
240000
,
timeout
:
stream
?
6
0000
:
240000
,
responseType
:
stream
?
'stream'
:
'json'
,
...
axiosConfig
()
}
...
...
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