// eslint-disable-next-line import/extensions
import { AISource, IChatMessage } from '../../../Data/source/AISource';
import { IUseCase } from '../base/IUseCase';

export class AIAnswerAssistWithProxyUseCase implements IUseCase<void, string> {
  private textToSend: string;

  private dialogMessages: IChatMessage[];

  private servername: string;

  private api: string;

  private port: string;

  private sessionToken: string;

  private openAIModel: string;

  constructor(
    textToSend: string,
    dialogMessages: IChatMessage[],
    servername: string,
    api: string,
    port: string,
    sessionToken: string,
    openAIModel = 'gpt-3.5-turbo',
  ) {
    console.log('CONSTRUCTOR AIRephraseUseCase');
    this.api = api;
    this.openAIModel = openAIModel;
    this.port = port;
    this.sessionToken = sessionToken;
    this.textToSend = textToSend;
    this.servername = servername;
    this.dialogMessages = dialogMessages;
  }

  async execute(): Promise<string> {
    console.log('execute AIRephraseUseCase');

    const prompt = `You are a customer support chat operator. Your goal is to provide helpful and informative responses to customer inquiries. Give a response to the next user's query, considering the entire conversation context, and use grammar and vocabulary at the A2-B2 level. Answer in the format of simple sentences. Do not include question in answer. Please, provide answer for this issue:"${this.textToSend}"`;

    //
    return AISource.getDataWithProxyServer(
      prompt,
      // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
      this.dialogMessages,
      this.servername,
      this.api,
      this.port,
      this.sessionToken,
      this.openAIModel,
    );
  }
}
