// content-writer.controller.ts
import {Body, Controller, Get, NotFoundException, Post, Query} from '@nestjs/common';
import {ContentWriterService} from './content-writer.service';
import {CommentWriterService} from './services/comment-writer.service';
import {GenerateContentDto} from './dto/generate-content.dto';
import {GenerateCommentDto} from './dto/generate-comment.dto';
import {IAIGrokProvider} from "./interfaces/ai-provider.interface";

@Controller('content-writer')
export class ContentWriterController {
    constructor(
        private readonly writerService: ContentWriterService,
        private readonly commentService: CommentWriterService,
    ) {
    }

    @Get('grok/test')
    async grokWrite(@Query('q') q: string) {
        const provider = await this.writerService.getGrokAI() as IAIGrokProvider;
        if (!q) {
            throw new NotFoundException('Not Found querystring.');
        }
        return provider.enrichXContext(q);
    }

    @Post('generate')
    generate(@Body() dto: GenerateContentDto) {
        return this.writerService.generate(dto);
    }

    @Post('comment')
    generateComment(@Body() dto: GenerateCommentDto) {
        return this.commentService.generateComment(dto);
    }

    @Post('comment/variants')
    generateCommentVariants(@Body() dto: GenerateCommentDto) {
        // return this.commentService.generateVariants(dto, 3);
    }
}
