import { Body, Controller, Post } from '@nestjs/common';
import { PromptProviderFactory } from './providers/prompt-provider.factory';
import { PromptAI } from 'src/common/enums';

class ExpandPromptDto {
  input: string;
  type: 'chatgpt' | 'gemini';
  mode?: 'partial';
}

@Controller('prompt')
export class PromptController {
  constructor(private readonly factory: PromptProviderFactory) {}

  @Post('expand')
  async expandPrompt(@Body() dto: ExpandPromptDto) {
    const providerType = dto.type === 'gemini' ? PromptAI.GEMINI : PromptAI.CHATGPT;

    const provider = this.factory.get(providerType);

    const result = await provider.expandPrompt(dto.input, { mode: dto.mode });

    return {
      input: dto.input,
      type: dto.type,
      mode: dto.mode || 'full',
      output: result,
    };
  }
}
