// services/prompt-builder.service.ts
import {Injectable} from '@nestjs/common';
import {ContentContext} from '../interfaces/content-context.interface';
import {AIMessage} from '../interfaces/ai-provider.interface';
import {
    buildWriterSystemPrompt,
    buildGenericWriterPrompt,
    buildReviewerPrompt,
    buildBreakingNewsPrompt
} from '../prompts/templates';
import {WriterPromptParams} from "../interfaces/writer-prompt-params.interface";

@Injectable()
export class PromptBuilderService {
    buildWriterMessages(ctx: WriterPromptParams): AIMessage[] {
        console.debug('buildWriterMessages_ctx', ctx);

        const prompts =ctx.style === 'breaking_news' ? buildBreakingNewsPrompt(ctx) : buildGenericWriterPrompt(ctx);

        return [
            {role: 'system', content: prompts.system},
            {role: 'user', content: prompts.user},
        ];
    }

    buildReviewerMessages(draft: string, ctx: ContentContext): AIMessage[] {
        return [
            {role: 'system', content: 'You are a strict social media editor. Return ONLY valid JSON.'},
            {role: 'user', content: buildReviewerPrompt(draft, ctx.platform, ctx.style, ctx.language)},
        ];
    }
}
