mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-04 03:40:33 +08:00
feat: add better support for openrouter thinking format
This commit is contained in:
parent
35279982b9
commit
5400e9a73c
@ -209,7 +209,10 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
let hasReasoningContent = false
|
let hasReasoningContent = false
|
||||||
let lastChunk = ''
|
let lastChunk = ''
|
||||||
const isReasoningJustDone = (
|
const isReasoningJustDone = (
|
||||||
delta: OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta & { reasoning_content?: string }
|
delta: OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta & {
|
||||||
|
reasoning_content?: string
|
||||||
|
reasoning?: string
|
||||||
|
}
|
||||||
) => {
|
) => {
|
||||||
if (!delta?.content) return false
|
if (!delta?.content) return false
|
||||||
|
|
||||||
@ -222,12 +225,12 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有reasoning_content,说明是在思考中
|
// 如果有reasoning_content或reasoning,说明是在思考中
|
||||||
if (delta?.reasoning_content) {
|
if (delta?.reasoning_content || delta?.reasoning) {
|
||||||
hasReasoningContent = true
|
hasReasoningContent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果之前有reasoning_content,现在有普通content,说明思考结束
|
// 如果之前有reasoning_content或reasoning,现在有普通content,说明思考结束
|
||||||
if (hasReasoningContent && delta.content) {
|
if (hasReasoningContent && delta.content) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -285,7 +288,7 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
|
|
||||||
const delta = chunk.choices[0]?.delta
|
const delta = chunk.choices[0]?.delta
|
||||||
|
|
||||||
if (delta?.reasoning_content) {
|
if (delta?.reasoning_content || delta?.reasoning) {
|
||||||
hasReasoningContent = true
|
hasReasoningContent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user