mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-20 20:50:17 +09:00
Merge pull request #3 from SolarifyDev/deepseek-r1-clean-assistant-content
Deepseek r1 clean assistant content
This commit is contained in:
commit
e65a33d801
@ -85,7 +85,7 @@ async function request(req: NextRequest) {
|
|||||||
fetchOptions.body = clonedBody;
|
fetchOptions.body = clonedBody;
|
||||||
|
|
||||||
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
||||||
|
console.log(jsonBody);
|
||||||
// not undefined and is false
|
// not undefined and is false
|
||||||
if (
|
if (
|
||||||
isModelNotavailableInServer(
|
isModelNotavailableInServer(
|
||||||
|
@ -65,13 +65,24 @@ export class DeepSeekApi implements LLMApi {
|
|||||||
|
|
||||||
async chat(options: ChatOptions) {
|
async chat(options: ChatOptions) {
|
||||||
const messages: ChatOptions["messages"] = [];
|
const messages: ChatOptions["messages"] = [];
|
||||||
for (const v of options.messages) {
|
if (options.config.model === "deepseek-reasoner") {
|
||||||
if (v.role === "assistant") {
|
// Only take the last message
|
||||||
const content = getMessageTextContentWithoutThinking(v);
|
const lastMessage = options.messages[options.messages.length - 1];
|
||||||
messages.push({ role: v.role, content });
|
const content =
|
||||||
} else {
|
lastMessage.role === "assistant"
|
||||||
const content = getMessageTextContent(v);
|
? getMessageTextContentWithoutThinking(lastMessage)
|
||||||
messages.push({ role: v.role, content });
|
: getMessageTextContent(lastMessage);
|
||||||
|
messages.push({ role: lastMessage.role, content });
|
||||||
|
} else {
|
||||||
|
// Process all messages
|
||||||
|
for (const v of options.messages) {
|
||||||
|
if (v.role === "assistant") {
|
||||||
|
const content = getMessageTextContentWithoutThinking(v);
|
||||||
|
messages.push({ role: v.role, content });
|
||||||
|
} else {
|
||||||
|
const content = getMessageTextContent(v);
|
||||||
|
messages.push({ role: v.role, content });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user