Skip to content

Commit 354dfbe

Browse files
authored
Merge pull request #60 from Yanyutin753/master
refactor(chat): 优化思考过程的格式
2 parents af34655 + 6bce6df commit 354dfbe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/api/controllers/chat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,14 @@ async function receiveStream(model: string, stream: any, refConvId?: string): Pr
569569
if (result.choices[0].delta.type === "thinking") {
570570
if (!thinking && isThinkingModel && !isSilentModel) {
571571
thinking = true;
572-
data.choices[0].message.content += isFoldModel ? "<details><summary>思考过程</summary><pre>" : "[思考开始]";
572+
data.choices[0].message.content += isFoldModel ? "<details><summary>思考过程</summary><pre>" : "[思考开始]\n";
573573
}
574574
if (isSilentModel)
575575
return;
576576
}
577577
else if (thinking && isThinkingModel && !isSilentModel) {
578578
thinking = false;
579-
data.choices[0].message.content += isFoldModel ? "</pre></details>" : "[思考结束]";
579+
data.choices[0].message.content += isFoldModel ? "</pre></details>" : "\n\n[思考结束]\n";
580580
}
581581
if (result.choices[0].delta.content)
582582
data.choices[0].message.content += result.choices[0].delta.content;
@@ -671,7 +671,7 @@ function createTransStream(model: string, stream: any, refConvId: string, endCal
671671
choices: [
672672
{
673673
index: 0,
674-
delta: { role: "assistant", content: isFoldModel ? "<details><summary>思考过程</summary><pre>" : "[思考开始]" },
674+
delta: { role: "assistant", content: isFoldModel ? "<details><summary>思考过程</summary><pre>" : "[思考开始]\n" },
675675
finish_reason: null,
676676
},
677677
],
@@ -690,7 +690,7 @@ function createTransStream(model: string, stream: any, refConvId: string, endCal
690690
choices: [
691691
{
692692
index: 0,
693-
delta: { role: "assistant", content: isFoldModel ? "</pre></details>" : "[思考结束]" },
693+
delta: { role: "assistant", content: isFoldModel ? "</pre></details>" : "\n\n[思考结束]\n" },
694694
finish_reason: null,
695695
},
696696
],

0 commit comments

Comments
 (0)