package br.com.alura.screenmatch.service;

import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.service.OpenAiService;
import org.springframework.beans.factory.annotation.Value;

public class ConsultaChatGPT {
    @Value("${OPEN_AI_TOKEN}")
    private static String senha;
    public static String obterTraducao(String texto) {
        OpenAiService service = new OpenAiService(senha);

        CompletionRequest requisicao = CompletionRequest.builder()
                .model("text-davinci-003")
                .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
[((464, 697), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((464, 672), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((464, 638), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((464, 605), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((464, 534), 'com.theokanning.openai.completion.CompletionRequest.builder')]