80 lines
1.6 KiB
TypeScript
80 lines
1.6 KiB
TypeScript
|
|
interface FileInfo {
|
|
id: string;
|
|
file_name: string;
|
|
url: string;
|
|
metadata: Record<string, any>;
|
|
}
|
|
|
|
interface VideoClip {
|
|
clip_id: number;
|
|
start_time: number;
|
|
end_time: number;
|
|
description: string;
|
|
tags: string[];
|
|
composition: string;
|
|
shot_size: string;
|
|
point_of_view: string;
|
|
created_at: string;
|
|
}
|
|
|
|
interface VideoInfo {
|
|
id: string;
|
|
name: string | null;
|
|
description: string | null;
|
|
file_info: FileInfo;
|
|
preview_file_info: FileInfo;
|
|
user_id: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Video {
|
|
video: VideoInfo;
|
|
video_clips: VideoClip[];
|
|
}
|
|
export interface ContentPart {
|
|
type: string;
|
|
text?: string;
|
|
caption?: string;
|
|
url?: string;
|
|
id?: string;
|
|
}
|
|
|
|
|
|
export interface Message {
|
|
id: string;
|
|
content: string | ContentPart[];
|
|
role: typeof User | typeof Assistant;
|
|
timestamp: string;
|
|
// askAgain?: Array<{
|
|
// id: string;
|
|
// text: string;
|
|
// }>;
|
|
}
|
|
|
|
export function getMessageText(message: Message) {
|
|
if (typeof message.content === 'string') {
|
|
return message.content;
|
|
} else {
|
|
return message.content.map((item) => item.text || '').join('');
|
|
}
|
|
}
|
|
|
|
export function isMessageContainMedia(message: Message) {
|
|
if (typeof message.content === 'string') {
|
|
return false;
|
|
} else {
|
|
return message.content.some((item) => item.type === 'image' || item.type === 'video');
|
|
}
|
|
}
|
|
|
|
export const User = 'user';
|
|
export const Assistant = 'assistant';
|
|
|
|
export interface Chat {
|
|
created_at: string;
|
|
session_id: string;
|
|
title: string;
|
|
latest_message: Message;
|
|
} |