package br.com.alura.screenmatch.service;

import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import com.theokanning.openai.completion.chat.ChatMessageRole;
import com.theokanning.openai.service.OpenAiService;

import java.util.ArrayList;
import java.util.List;

public class ConsultaChatGPT {
        public static String obterTraducao(String texto) {
            OpenAiService service = new OpenAiService(System.getenv("OPENAI_APIKEY"));

            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
[((621, 880), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((621, 851), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((621, 813), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((621, 776), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((621, 701), 'com.theokanning.openai.completion.CompletionRequest.builder')]