import { GoogleGenAI } from '@google/genai';
import { PromptProvider } from '../interfaces/prompt-provider.interface';
import { Injectable } from '@nestjs/common';

@Injectable()
export class GeminiProvider implements PromptProvider {
  private client: any;

  constructor() {
    const apiKey = process.env.GEMINI_API_KEY;
    if (!apiKey) {
      throw new Error('GEMINI_API_KEY is not defined');
    }

    this.client = new GoogleGenAI({ apiKey });
  }

  async expandPrompt(
    input: string,
    options?: { mode?: 'partial' },
  ): Promise<string> {
    const prompt =
      options?.mode === 'partial'
        ? `Enhance visuals only: ${input}. Make it concise and keep it useful. Limit to 80 words.`
        : `Detailed artistic description: ${input}. Summarize it in 80 words maximum, keep details useful.`;

    const response = await this.client.models.generateContent({
      model: 'gemini-2.5-flash',
      contents: prompt,
    });

    return response.text;
  }
}
