feat(api): 实现消息合并 API,支持工具调用显示
- 新增 MergedMessage、ToolCallInfo 类型定义 - 创建 message-merger.ts 消息合并工具 - 更新 sessions 路由使用合并后的消息格式 - 前端新增 ToolCallsDisplay 组件展示工具调用 - 工具调用显示状态、时长,可展开查看参数和结果
This commit is contained in:
@@ -11,11 +11,46 @@ export interface Session {
|
||||
messageCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具调用状态
|
||||
*/
|
||||
export type ToolCallStatus = 'pending' | 'running' | 'completed' | 'error';
|
||||
|
||||
/**
|
||||
* 工具调用信息
|
||||
*/
|
||||
export interface ToolCallInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
arguments: Record<string, unknown>;
|
||||
status: ToolCallStatus;
|
||||
result?: unknown;
|
||||
error?: string;
|
||||
duration?: number; // 执行时长 ms
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息(合并后的格式)
|
||||
*
|
||||
* 助手消息可能包含工具调用信息,将多个原始消息合并为一条
|
||||
*/
|
||||
export interface Message {
|
||||
id: string;
|
||||
role: 'user' | 'assistant' | 'system';
|
||||
content: string;
|
||||
timestamp: string;
|
||||
/** 工具调用列表 */
|
||||
toolCalls?: ToolCallInfo[];
|
||||
/** 是否包含推理过程 */
|
||||
hasReasoning?: boolean;
|
||||
/** 推理内容 */
|
||||
reasoning?: string;
|
||||
/** 元数据 */
|
||||
metadata?: {
|
||||
model?: string;
|
||||
stepCount?: number;
|
||||
totalTokens?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface HealthStatus {
|
||||
|
||||
Reference in New Issue
Block a user