fix(thinking): Claude think label recognition error problem
This commit is contained in:
parent
a1568808d4
commit
123362b493
@ -173,7 +173,7 @@ export const TEXT_TO_IMAGE_REGEX = /flux|diffusion|stabilityai|sd-|dall|cogview|
|
|||||||
|
|
||||||
// Reasoning models
|
// Reasoning models
|
||||||
export const REASONING_REGEX =
|
export const REASONING_REGEX =
|
||||||
/^(o\d+(?:-[\w-]+)?|.*\b(?:reasoner|thinking)\b.*|.*-[rR]\d+.*|.*\bqwq(?:-[\w-]+)?\b.*|.*\bhunyuan-t1(?:-[\w-]+)?\b.*)$/i
|
/^(o\d+(?:-[\w-]+)?|.*\b(?:reasoner|thinking)\b.*|.*-[rR]\d+.*|.*\bqwq(?:-[\w-]+)?\b.*|.*\bhunyuan-t1(?:-[\w-]+)?\b.*|.*\bglm-zero-preview\b.*)$/i
|
||||||
|
|
||||||
// Embedding models
|
// Embedding models
|
||||||
export const EMBEDDING_REGEX =
|
export const EMBEDDING_REGEX =
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { isReasoningModel } from '@renderer/config/models'
|
import { isReasoningModel } from '@renderer/config/models'
|
||||||
|
import { getAssistantById } from '@renderer/services/AssistantService'
|
||||||
import { Message } from '@renderer/types'
|
import { Message } from '@renderer/types'
|
||||||
|
|
||||||
export function escapeDollarNumber(text: string) {
|
export function escapeDollarNumber(text: string) {
|
||||||
@ -91,11 +92,8 @@ const glmZeroPreviewProcessor: ThoughtProcessor = {
|
|||||||
canProcess: (content: string, message?: Message) => {
|
canProcess: (content: string, message?: Message) => {
|
||||||
if (!message) return false
|
if (!message) return false
|
||||||
|
|
||||||
const model = message.model
|
|
||||||
if (!model || !isReasoningModel(model)) return false
|
|
||||||
|
|
||||||
const modelId = message.modelId || ''
|
const modelId = message.modelId || ''
|
||||||
const modelName = model.name || ''
|
const modelName = message.model?.name || ''
|
||||||
const isGLMZeroPreview =
|
const isGLMZeroPreview =
|
||||||
modelId.toLowerCase().includes('glm-zero-preview') || modelName.toLowerCase().includes('glm-zero-preview')
|
modelId.toLowerCase().includes('glm-zero-preview') || modelName.toLowerCase().includes('glm-zero-preview')
|
||||||
|
|
||||||
@ -117,9 +115,6 @@ const thinkTagProcessor: ThoughtProcessor = {
|
|||||||
canProcess: (content: string, message?: Message) => {
|
canProcess: (content: string, message?: Message) => {
|
||||||
if (!message) return false
|
if (!message) return false
|
||||||
|
|
||||||
const model = message.model
|
|
||||||
if (!model || !isReasoningModel(model)) return false
|
|
||||||
|
|
||||||
return content.startsWith('<think>') || content.includes('</think>')
|
return content.startsWith('<think>') || content.includes('</think>')
|
||||||
},
|
},
|
||||||
process: (content: string) => {
|
process: (content: string) => {
|
||||||
@ -162,6 +157,15 @@ export function withMessageThought(message: Message) {
|
|||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const model = message.model
|
||||||
|
if (!model || !isReasoningModel(model)) return message
|
||||||
|
|
||||||
|
const isClaude37Sonnet = model.id.includes('claude-3-7-sonnet') || model.id.includes('claude-3.7-sonnet')
|
||||||
|
if (isClaude37Sonnet) {
|
||||||
|
const assistant = getAssistantById(message.assistantId)
|
||||||
|
if (!assistant?.settings?.reasoning_effort) return message
|
||||||
|
}
|
||||||
|
|
||||||
const content = message.content.trim()
|
const content = message.content.trim()
|
||||||
const processors: ThoughtProcessor[] = [glmZeroPreviewProcessor, thinkTagProcessor]
|
const processors: ThoughtProcessor[] = [glmZeroPreviewProcessor, thinkTagProcessor]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user