2025-08-23 19:11:16 +08:00

132 lines
3.3 KiB
TypeScript

export type Role = "user" | "assistant" | "system";
export type MessageStatus = 'pending' | 'success' | 'error';
export type IntentType = 'chat' | 'function_call' | 'procedure';
export type MessageBlock =
| { type: "text"; text: string }
| { type: "image"; url: string; alt?: string }
| { type: "video"; url: string; poster?: string }
| { type: "audio"; url: string }
| { type: "progress"; value: number; total?: number; label?: string };
export interface ChatMessage {
id: string;
role: Role;
blocks: MessageBlock[];
createdAt: number;
chatType: IntentType;
status: MessageStatus;
}
export interface MessagesState {
messages: ChatMessage[];
isLoading: boolean;
error: Error | null;
hasMore: boolean;
loadMoreMessages: () => Promise<void>;
backToLatest: () => void;
isViewingHistory: boolean;
}
export interface MessagesActions {
sendMessage: (blocks: MessageBlock[]) => Promise<void>;
clearMessages: () => void;
retryMessage: (messageId: string) => Promise<void>;
}
export interface SystemPushState {
enabled: boolean;
toggle: () => void;
}
export interface ChatConfig {
projectId: string;
userId: number;
}
export interface FetchMessagesRequest {
session_id: string;
limit: number;
offset: number;
}
export interface SendMessageRequest {
session_id: string;
user_input: string;
image_url?: string;
project_id: string;
user_id: number;
}
export interface ApiResponse<T> {
code: number;
message: string;
data: T;
}
export interface MessagesResponse {
session_id: string;
total_count: number;
messages: RealApiMessage[];
has_more: boolean;
current_page: {
offset: number;
limit: number;
count: number;
};
}
type ContentType = "text" | "image" | "video" | "audio";
export type MessageType = "project_init" | "script_summary" | "character_generation" | "sketch_generation" | "shot_sketch_generation";
export type FunctionName = "create_project" | "generate_script_summary" | "generate_character" | "generate_sketch" | "generate_shot_sketch";
// 项目创建
export interface ProjectInit {
project_data: {
script: string; // 原始剧本
}
}
// 剧本总结
export interface ScriptSummary {
summary: string; // 剧本总结
}
// 角色生成
export interface CharacterGeneration {
character_name: string; // 角色名称
image_path: string; // 角色图片
count: number; // 生成数量
total_count: number; // 总数量
}
// 场景草图生成
export interface SketchGeneration {
sketch_name: string; // 场景草图名称
image_path: string; // 场景草图图片
count: number; // 生成数量
total_count: number; // 总数量
}
// 分镜草图生成
export interface ShotSketchGeneration {
shot_type: string; // 分镜镜头类型
atmosphere: string; // 氛围描述
key_action: string; // 关键动作描述
url: string; // 分镜草图图片
count: number; // 生成数量
total_count: number; // 总数量
}
export interface ApiMessageContent {
type: ContentType;
content: string;
}
export interface RealApiMessage {
created_at: string;
id: number;
role: Role;
content: string;
message_type?: MessageType;
function_name?: FunctionName;
custom_data?: ProjectInit | ScriptSummary | CharacterGeneration | SketchGeneration | ShotSketchGeneration;
status: MessageStatus;
intent_type: IntentType;
}