package me.synergy.modules;

import com.theokanning.openai.completion.CompletionChoice;
import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.service.OpenAiService;
import java.time.Duration;
import java.util.List;
import me.synergy.brains.Synergy;

public class OpenAi {
  public List<CompletionChoice> newPrompt(String args) {
    OpenAiService service = new OpenAiService(Synergy.getConfig().getString("openai.token"), Duration.ofSeconds(30L));
    CompletionRequest completionRequest = CompletionRequest.builder()
      .model(Synergy.getConfig().getString("openai.model"))
      .prompt(args)
      .maxTokens(Synergy.getConfig().getInt("openai.response-size"))
      .temperature(Double.valueOf(Synergy.getConfig().getDouble("openai.temperature")))
      .build();
    List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices();
    service.shutdownExecutor();
    return choices;
  }
}

com.theokanning.openai.completion.CompletionRequest.builder
[((411, 456), 'me.synergy.brains.Synergy.getConfig'), ((526, 805), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((526, 790), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((526, 702), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((526, 633), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((526, 613), 'com.theokanning.openai.completion.CompletionRequest.builder'), ((567, 612), 'me.synergy.brains.Synergy.getConfig'), ((651, 701), 'me.synergy.brains.Synergy.getConfig'), ((737, 788), 'me.synergy.brains.Synergy.getConfig')]