geo/frontend/lib/api/content.ts

63 lines
1.8 KiB
TypeScript

import { fetchWithAuth } from "./client";
// ── 类型定义 ────────────────────────────────────────────────────────────────────
export interface ContentGenerateRequest {
target_keyword: string;
target_platform?: string;
knowledge_base_ids?: string[];
content_style?: string;
word_count?: number;
brand_name?: string;
brand_description?: string;
run_deai?: boolean;
run_geo?: boolean;
}
export interface PipelineStage {
stage: string;
status: string;
word_count?: number;
}
export interface ContentGenerateResponse {
status: string;
content: string;
optimized_content: string;
seo_score: number | null;
topics: Record<string, unknown>[];
pipeline_stages: PipelineStage[];
}
export interface TopicItem {
title: string;
reason?: string;
[key: string]: unknown;
}
export interface GenerateTopicsResponse {
status: string;
topics: TopicItem[];
}
// ── API ────────────────────────────────────────────────────────────────────────
export const contentGenerationApi = {
generateContent: (token?: string, params?: ContentGenerateRequest) =>
fetchWithAuth(
"/api/v1/content/generate",
{ method: "POST", body: JSON.stringify(params) },
token
) as Promise<ContentGenerateResponse>,
generateTopics: (
token?: string,
params?: Pick<ContentGenerateRequest, "target_keyword" | "target_platform" | "brand_name" | "brand_description">
) =>
fetchWithAuth(
"/api/v1/content/generate-topics",
{ method: "POST", body: JSON.stringify(params) },
token
) as Promise<GenerateTopicsResponse>,
};