import { ILogger } from '../../../types/common';
import { VertexProviderConfig, VertexModel } from './types';

export class VertexConfig {
  private config: VertexProviderConfig;
  private logger: ILogger;

  constructor(config: VertexProviderConfig, logger: ILogger) {
    this.config = config;
    this.logger = logger;
  }

  get projectId(): string {
    return this.config.projectId;
  }

  get location(): string {
    return this.config.location;
  }

  get model(): string {
    return this.config.model;
  }

  get credentials(): any {
    return this.config.credentials;
  }

  getApiUrl(): string {
    return `https://${this.location}-aiplatform.googleapis.com/v1/projects/${this.projectId}/locations/${this.location}/publishers/google/models/${this.model}:predict`;
  }

  isGeminiModel(): boolean {
    return this.model.startsWith('gemini-');
  }

  isClaudeModel(): boolean {
    return this.model.startsWith('claude-');
  }

  getModelType(): VertexModel {
    switch (this.model) {
      case 'gemini-pro':
        return VertexModel.GEMINI_PRO;
      case 'gemini-pro-vision':
        return VertexModel.GEMINI_PRO_VISION;
      case 'claude-3-sonnet-20240229':
        return VertexModel.CLAUDE_3_SONNET;
      case 'claude-3-opus-20240229':
        return VertexModel.CLAUDE_3_OPUS;
      default:
        throw new Error(`Unsupported model: ${this.model}`);
    }
  }
}