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
5be57da4
authored
Jun 24, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: v1 api
parent
057c3411
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
15 deletions
+34
-15
client/src/pages/api/openapi/chat/chat.ts
+33
-15
client/src/service/utils/chat/index.ts
+1
-0
No files found.
client/src/pages/api/openapi/chat/chat.ts
View file @
5be57da4
...
...
@@ -65,10 +65,14 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
const
modelConstantsData
=
ChatModelMap
[
model
.
chat
.
chatModel
];
const
prompt
=
prompts
[
prompts
.
length
-
1
];
const
{
userSystemPrompt
=
[],
quotePrompt
=
[]
}
=
await
(
async
()
=>
{
const
{
userSystemPrompt
=
[],
userLimitPrompt
=
[],
quotePrompt
=
[]
}
=
await
(
async
()
=>
{
// 使用了知识库搜索
if
(
model
.
chat
.
relatedKbs
?.
length
>
0
)
{
const
{
userSystemPrompt
,
quote
Prompt
}
=
await
appKbSearch
({
const
{
quotePrompt
,
userSystemPrompt
,
userLimit
Prompt
}
=
await
appKbSearch
({
model
,
userId
,
fixedQuote
:
[],
...
...
@@ -78,21 +82,29 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
});
return
{
userSystemPrompt
:
userSystemPrompt
?
[
userSystemPrompt
]
:
[],
userSystemPrompt
,
userLimitPrompt
,
quotePrompt
:
[
quotePrompt
]
};
}
if
(
model
.
chat
.
systemPrompt
)
{
return
{
userSystemPrompt
:
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
model
.
chat
.
systemPrompt
}
]
};
}
return
{};
return
{
userSystemPrompt
:
model
.
chat
.
systemPrompt
?
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
model
.
chat
.
systemPrompt
}
]
:
[],
userLimitPrompt
:
model
.
chat
.
limitPrompt
?
[
{
obj
:
ChatRoleEnum
.
Human
,
value
:
model
.
chat
.
limitPrompt
}
]
:
[]
};
})();
// search result is empty
...
...
@@ -102,7 +114,13 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
}
// 读取对话内容
const
completePrompts
=
[...
quotePrompt
,
...
prompts
.
slice
(
0
,
-
1
),
...
userSystemPrompt
,
prompt
];
const
completePrompts
=
[
...
quotePrompt
,
...
userSystemPrompt
,
...
prompts
.
slice
(
0
,
-
1
),
...
userLimitPrompt
,
prompt
];
// 计算温度
const
temperature
=
(
modelConstantsData
.
maxTemperature
*
(
model
.
chat
.
temperature
/
10
)).
toFixed
(
...
...
client/src/service/utils/chat/index.ts
View file @
5be57da4
...
...
@@ -238,6 +238,7 @@ export const V2_StreamResponse = async ({
}
if
(
error
)
{
console
.
log
(
error
);
return
Promise
.
reject
(
error
);
}
...
...
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