deepseek reasoner

Closes #3322
This commit is contained in:
Cohee
2025-01-20 23:31:40 +02:00
parent d87b925488
commit d7bb92be54
5 changed files with 77 additions and 22 deletions

View File

@ -220,6 +220,21 @@ async function* parseStreamData(json) {
}
return;
}
else if (typeof json.choices[0].delta.reasoning_content === 'string' && json.choices[0].delta.reasoning_content.length > 0) {
for (let j = 0; j < json.choices[0].delta.reasoning_content.length; j++) {
const str = json.choices[0].delta.reasoning_content[j];
const isLastSymbol = j === json.choices[0].delta.reasoning_content.length - 1;
const choiceClone = structuredClone(json.choices[0]);
choiceClone.delta.reasoning_content = str;
choiceClone.delta.content = isLastSymbol ? choiceClone.delta.content : '';
const choices = [choiceClone];
yield {
data: { ...json, choices },
chunk: str,
};
}
return;
}
else if (typeof json.choices[0].delta.content === 'string' && json.choices[0].delta.content.length > 0) {
for (let j = 0; j < json.choices[0].delta.content.length; j++) {
const str = json.choices[0].delta.content[j];