Class LLMClient

java.lang.Object
com.amalgamasimulation.llm.LLMClient

public class LLMClient extends Object
A client for interacting with Large Language Model (LLM) APIs. This class provides methods to send prompts to an LLM service and receive responses asynchronously. It handles the HTTP communication, request formatting, and response parsing for LLM API calls.
  • Constructor Details

  • Method Details

    • response

      public CompletableFuture<String> response(String prompt)
      Sends a prompt to the LLM service and returns the response asynchronously allowing to wait for not longer than 10 seconds.
      Parameters:
      prompt - the text prompt to send to the LLM service
      Returns:
      a CompletableFuture that will complete with the LLM's response text as a String
    • response

      public CompletableFuture<String> response(String prompt, Duration timeout)
      Sends a prompt to the LLM service and returns the response asynchronously allowing to wait for not longer than the specified timeout.
      Parameters:
      prompt - the text prompt to send to the LLM service
      timeout - the maximum time to wait for the LLM service response
      Returns:
      a CompletableFuture that will complete with the LLM's response text as a String