package br.com.alura.screenmatch.service.impl;

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-instruct")
                .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
[((394, 633), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((394, 608), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((394, 574), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((394, 541), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((394, 470), 'com.theokanning.openai.completion.CompletionRequest.builder')]