// ────────── Chat ──────────

export interface Message {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string;
}

export interface ChatParams {
  model?: string;
  messages: Message[];
  stream?: boolean;
  maxTokens?: number;
  temperature?: number;
  topP?: number;
  responseFormat?: Record<string, unknown>;
  tools?: unknown[];
  toolChoice?: unknown;
}

export interface ChoiceMessage {
  role?: string;
  content?: string;
  reasoningContent?: string;
  toolCalls?: unknown[];
}

export interface Choice {
  message?: ChoiceMessage;
  delta?: ChoiceMessage;
  finishReason?: string;
}

export interface Usage {
  promptTokens?: number;
  completionTokens?: number;
  totalTokens?: number;
}

export interface ChatResponse {
  id?: string;
  model?: string;
  success?: boolean;
  errorMessage?: string;
  choices: Choice[];
  usage?: Usage;
}

// ────────── Image ──────────

export interface ImageParams {
  model?: string;
  prompt: string;
  imageUrlList?: string[];
  size?: string;
  quantityGenerated?: number;
  watermark?: boolean;
  resolution?: string;
  pollingWaitTime?: number;
}

export interface ImageResult {
  success: boolean;
  data?: {
    imageType?: string;
    imageList?: string[];
    watermark?: boolean;
  };
  errorMessage?: string;
}

// ────────── Video ──────────

export interface VideoParameters {
  resolution?: string;
  aspectRatio?: string;
  duration?: number;
  frames?: number;
  generateAudio?: boolean;
  watermark?: boolean;
  enhancePrompt?: boolean;
  seed?: number;
  draft?: boolean;
  serviceTier?: string;
}

export interface VideoParams {
  model?: string;
  taskId?: string;
  prompt?: string;
  firstFrame?: string;
  lastFrame?: string;
  referenceImages?: unknown[];
  audioUrl?: string;
  videoUrl?: string;
  parameters?: VideoParameters;
  callbackUrl?: string;
}

export interface VideoItem {
  videoUrl?: string;
  duration?: number;
  frames?: number;
  fps?: number;
  resolution?: string;
  aspectRatio?: string;
  hasAudio?: boolean;
}

export interface VideoUsage {
  videoCount?: number;
  totalTokens?: number;
  resolution?: string;
  duration?: number;
  audio?: boolean;
  frames?: number;
}

export interface VideoResponse {
  success: boolean;
  model?: string;
  errorMessage?: string;
  requestId?: string;
  taskId?: string;
  /** pending | running | succeeded | failed | cancelled | expired */
  status?: string;
  statusMessage?: string;
  videos?: VideoItem[];
  videoUsage?: VideoUsage;
}

export interface VideoTaskResult {
  success: boolean;
  data?: VideoResponse;
  errorMessage?: string;
}

// ────────── AI Search ──────────

export interface AiSearchParams {
  model?: string;
  query: string;
  stream?: boolean;
  freshness?: string;
}

export interface AiSearchMessage {
  type?: string;
  contentType?: string;
  content?: string;
  role?: string;
}

export interface AiSearchResponse {
  success: boolean;
  isFinish?: boolean;
  index?: number;
  message?: AiSearchMessage;
  messages?: AiSearchMessage[];
  errorMessage?: string;
}

export interface AiSearchResult {
  success: boolean;
  data?: AiSearchResponse;
  errorMessage?: string;
}

// ────────── Rerank ──────────

export interface RerankParams {
  model?: string;
  query: string;
  documents: string[];
  topN?: number;
  returnDocument?: boolean;
}

export interface RerankItem {
  relevanceScore?: number;
  index?: number;
  paragraph?: string;
  document?: unknown;
}

export interface RerankResponse {
  success: boolean;
  data?: RerankItem[];
  errorMessage?: string;
}