新增: anthropic 思维链解析入库与思考卡展示
- 流式与非流式 thinking 块接入 reasoning 通道 - 签名与密文块合规静默,请求侧零改动 - 历史映射透传 reasoning_content - 思考卡数据源真推理文本优先
This commit is contained in:
@@ -527,6 +527,12 @@ export interface AiMessage {
|
||||
id: MessageId
|
||||
role: 'user' | 'assistant' | 'tool' | 'system'
|
||||
content: string
|
||||
/**
|
||||
* 推理过程文本(DeepSeek reasoning_content / Anthropic thinking 同通道,后端落库
|
||||
* ai_messages.reasoning_content)。undefined=该轮无思考内容。历史消息 reload 时
|
||||
* 由 useAiConversations parseConvMessages 透传;思考 pill 以此为数据源,content 兜底。
|
||||
*/
|
||||
reasoning_content?: string
|
||||
isError?: boolean
|
||||
/**
|
||||
* 流式重试过渡标记(AiStreamRetry 推送的过渡气泡,前端内存专用不落库)。
|
||||
|
||||
@@ -758,9 +758,11 @@ function toggleThink(id: string): void {
|
||||
expandedThinkIds.value = next
|
||||
}
|
||||
|
||||
/** 轮次思考纯文本(压平 markdown 换行;空内容回退「过程记录」,纯工具轮也有锚点) */
|
||||
/** 轮次思考纯文本:reasoning_content 优先(DeepSeek/Anthropic thinking 同通道),content 兜底;
|
||||
* 压平 markdown 换行;两者皆空回退「过程记录」占位(纯工具轮也有锚点) */
|
||||
function thinkPlainText(m: AiMessage): string {
|
||||
return (m.content || '').replace(/\s+/g, ' ').trim()
|
||||
const src = m.reasoning_content || m.content || ''
|
||||
return src.replace(/\s+/g, ' ').trim()
|
||||
}
|
||||
/** pill 单行文本:纯文本截断 + 空轮回退文案(title 承载全文,此处只管单行) */
|
||||
function thinkSnippet(m: AiMessage): string {
|
||||
|
||||
@@ -176,6 +176,8 @@ function parseConvMessages(rawMsgs: any[], fallbackPrefix: string): AiMessage[]
|
||||
id: (m.id && m.id !== '') ? m.id : `${fallbackPrefix}-${i}`,
|
||||
role: m.role,
|
||||
content: m.content || '',
|
||||
// 推理过程透传(DeepSeek/Anthropic thinking 同通道落库字段),undefined 保持缺省
|
||||
reasoning_content: m.reasoning_content || undefined,
|
||||
model: m.model,
|
||||
// 用后端持久化的真实时间;老数据无 timestamp 字段回退 Date.now()
|
||||
timestamp: typeof m.timestamp === 'number' ? m.timestamp : Date.now(),
|
||||
|
||||
Reference in New Issue
Block a user