import { Injectable } from '@nestjs/common';
import { ImageProviderFactory } from './providers/image-provider.factory';
import { ServiceType, PromptAI, ImageProviderType } from 'src/common/enums';
import { PromptService } from '../prompts/prompt.service';

@Injectable()
export class ImagesService {
  constructor(
    private readonly promptService: PromptService,
    private readonly factory: ImageProviderFactory,
  ) {}

  async create(dto: {
    prompt: string;
    promptAI: PromptAI;
    provider: ImageProviderType;
  }) {
    const prompt = await this.promptService.preparePrompt(
      ServiceType.CREATE_IMAGE,
      dto.promptAI,
      dto.prompt,
    );

    return this.factory.get(dto.provider).createImage(prompt);
  }
}
