package br.com.alura.screenmatch.services;

import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.service.OpenAiService;

public class ConsultaChatGPT {

        public static String obterTraducao(String texto) {
            OpenAiService service = new OpenAiService("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");

            CompletionRequest requisicao = CompletionRequest.builder()
                    .model("gpt-3.5-turbo-0613")
                    .prompt("Traduza para o português o texto: " + texto)
                    .maxTokens(1000)
                    .temperature(0.7)
                    .build();

            var resposta = service.createCompletion(requisicao);
            return resposta.getChoices().get(0).getText();
        }


}

com.theokanning.openai.completion.CompletionRequest.builder
[((403, 658), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((403, 629), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((403, 591), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((403, 554), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((403, 479), 'com.theokanning.openai.completion.CompletionRequest.builder')]