import { Injectable } from '@nestjs/common';
import OpenAI from 'openai';

@Injectable()
export class ChatGPTProvider {
  private client: OpenAI;

  constructor() {
    this.client = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY,
    });
  }

  async expandPrompt(
    input: string,
    options?: { mode?: 'partial' },
  ): Promise<string> {
    let prompt: string;

    if (options?.mode === 'partial') {
      prompt = `Improve this without changing identity: ${input}`;
    } else {
      prompt = `Create a full cinematic description: ${input}`;
    }

    const response = await this.client.responses.create({
      model: 'gpt-4.1', 
      input: prompt,
    });

    return response.output_text; 
  }
}
