package br.com.alura.fipeveiculos.service;

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

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

        CompletionRequest requisicao = CompletionRequest.builder()
                .model("gpt-3.5-turbo-instruct")
                .prompt(dados)
                .maxTokens(1000)
                .temperature(0.7)
                .build();

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

com.theokanning.openai.completion.CompletionRequest.builder
[((366, 565), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((366, 540), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((366, 506), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((366, 473), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((366, 442), 'com.theokanning.openai.completion.CompletionRequest.builder')]