package screensync.api.service;

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 pt-br 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
[((380, 612), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((380, 587), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((380, 553), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((380, 520), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((380, 456), 'com.theokanning.openai.completion.CompletionRequest.builder')]