feat(类型): 添加智能摘要功能类型定义
- 定义摘要长度类型 (short/standard/detailed) - 定义摘要风格类型 (bullet/narrative) - 添加摘要状态、数据等接口定义 - 配置摘要长度和风格的默认选项 - 导出模块入口文件
This commit is contained in:
parent
c48d05885a
commit
5d301364fb
31
src/components/features/SummaryGenerator/index.ts
Normal file
31
src/components/features/SummaryGenerator/index.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* 智能摘要功能模块
|
||||||
|
*
|
||||||
|
* 提供 AI 自动生成对话摘要的能力
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 组件导出
|
||||||
|
export { SummaryButton } from './SummaryButton';
|
||||||
|
export { SummaryModal } from './SummaryModal';
|
||||||
|
export { SummaryOptions } from './SummaryOptions';
|
||||||
|
export { SummaryContent } from './SummaryContent';
|
||||||
|
|
||||||
|
// Hook 导出
|
||||||
|
export { useSummary } from './useSummary';
|
||||||
|
|
||||||
|
// 类型导出
|
||||||
|
export type {
|
||||||
|
SummaryLength,
|
||||||
|
SummaryStyle,
|
||||||
|
SummaryOptions as SummaryOptionsType,
|
||||||
|
SummaryStatus,
|
||||||
|
SummaryData,
|
||||||
|
SummaryMessage,
|
||||||
|
GenerateSummaryRequest,
|
||||||
|
GenerateSummaryResponse,
|
||||||
|
UseSummaryReturn,
|
||||||
|
ModalView,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
// 常量导出
|
||||||
|
export { SUMMARY_LENGTH_CONFIG, SUMMARY_STYLE_CONFIG } from './types';
|
||||||
80
src/components/features/SummaryGenerator/types.ts
Normal file
80
src/components/features/SummaryGenerator/types.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* 智能摘要功能类型定义
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 摘要长度选项
|
||||||
|
export type SummaryLength = 'short' | 'standard' | 'detailed';
|
||||||
|
|
||||||
|
// 摘要风格选项
|
||||||
|
export type SummaryStyle = 'bullet' | 'narrative';
|
||||||
|
|
||||||
|
// 摘要生成选项
|
||||||
|
export interface SummaryOptions {
|
||||||
|
length: SummaryLength;
|
||||||
|
style: SummaryStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 摘要长度配置
|
||||||
|
export const SUMMARY_LENGTH_CONFIG: Record<SummaryLength, { label: string; description: string; maxWords: number }> = {
|
||||||
|
short: { label: '简短', description: '约50字的核心要点', maxWords: 50 },
|
||||||
|
standard: { label: '标准', description: '约150字的详细摘要', maxWords: 150 },
|
||||||
|
detailed: { label: '详细', description: '约300字的完整分析', maxWords: 300 },
|
||||||
|
};
|
||||||
|
|
||||||
|
// 摘要风格配置
|
||||||
|
export const SUMMARY_STYLE_CONFIG: Record<SummaryStyle, { label: string; description: string }> = {
|
||||||
|
bullet: { label: '要点式', description: '结构化的要点列表' },
|
||||||
|
narrative: { label: '叙述式', description: '连贯的段落描述' },
|
||||||
|
};
|
||||||
|
|
||||||
|
// 摘要生成状态
|
||||||
|
export type SummaryStatus = 'idle' | 'generating' | 'completed' | 'error';
|
||||||
|
|
||||||
|
// 摘要数据
|
||||||
|
export interface SummaryData {
|
||||||
|
content: string; // 摘要内容(Markdown)
|
||||||
|
generatedAt: Date; // 生成时间
|
||||||
|
messageCount: number; // 分析的消息数
|
||||||
|
options: SummaryOptions; // 生成时使用的选项
|
||||||
|
}
|
||||||
|
|
||||||
|
// 摘要生成请求
|
||||||
|
export interface GenerateSummaryRequest {
|
||||||
|
conversationId: string;
|
||||||
|
options: SummaryOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 摘要生成响应
|
||||||
|
export interface GenerateSummaryResponse {
|
||||||
|
success: boolean;
|
||||||
|
summary?: string;
|
||||||
|
error?: string;
|
||||||
|
messageCount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// useSummary Hook 返回类型
|
||||||
|
export interface UseSummaryReturn {
|
||||||
|
// 状态
|
||||||
|
status: SummaryStatus;
|
||||||
|
summary: SummaryData | null;
|
||||||
|
error: string | null;
|
||||||
|
streamingContent: string;
|
||||||
|
|
||||||
|
// 选项
|
||||||
|
options: SummaryOptions;
|
||||||
|
setOptions: (options: Partial<SummaryOptions>) => void;
|
||||||
|
|
||||||
|
// 操作
|
||||||
|
generate: (conversationId: string, messages: SummaryMessage[]) => Promise<void>;
|
||||||
|
reset: () => void;
|
||||||
|
saveSummary: (conversationId: string) => Promise<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用于摘要生成的消息格式
|
||||||
|
export interface SummaryMessage {
|
||||||
|
role: 'user' | 'assistant';
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modal 状态
|
||||||
|
export type ModalView = 'options' | 'generating' | 'result';
|
||||||
Loading…
Reference in New Issue
Block a user