Interface LLMProvider.LLMRequest

All Superinterfaces:
Serializable
Enclosing interface:
LLMProvider

public static interface LLMProvider.LLMRequest extends Serializable
Represents a request to the LLM containing all necessary context, configuration, and tools. Requests are immutable.
  • Method Details

    • userMessage

      String userMessage()
      Gets the user's message.
      Returns:
      the user message, never null
    • attachments

      List<AIAttachment> attachments()
      Gets the list of file attachments to include with the request. Attachments can be images, PDFs, text files, or other supported formats that the LLM can analyze and reference in its response.
      Returns:
      the list of attachments, never null but may be empty
    • systemPrompt

      String systemPrompt()
      Gets the system prompt for this specific request. The system prompt defines the LLM's behavior, role, and constraints. If null, the provider may use its own internal default system prompt.
      Returns:
      the system prompt, or null if not specified
    • tools

      Object[] tools()
      Gets the tool objects for this request. Tool objects are classes with vendor-specific annotations (e.g., LangChain4j's @Tool, Spring AI's @Tool) that the provider can introspect and convert to native tool definitions.

      These tools are executed by the vendor framework itself, so its own error handling decides what reaches the LLM when a tool throws; the ToolException contract only applies to the tools returned by explicitTools().

      Returns:
      array of tool objects, never null but may be empty
    • explicitTools

      default List<LLMProvider.ToolSpec> explicitTools()
      Gets the explicit tool definitions for this request. Unlike vendor-specific annotated tools returned by tools(), these are framework-agnostic tool definitions provided programmatically (typically by AIController instances).
      Returns:
      list of explicit tool definitions, never null but may be empty
    • sessionContext

      default String sessionContext()
      Gets the session context for this turn: free-form text the application supplies through AIOrchestrator.Builder.withMetadata, such as the current date and time, captured when the user sent the message.

      Send it to the model together with the user message, after the user's text, so that the system prompt and the tool definitions stay identical from turn to turn and an LLM provider that caches the prompt prefix keeps hitting its cache. The built-in providers append it to the user message text in a delimited block. The default returns null.

      Returns:
      the session context for this turn, or null when there is none
      Since:
      25.3
    • metadataSink

      default Consumer<ResponseMetadata> metadataSink()
      Gets the consumer that receives metadata about the model's response, such as the finish reason and token usage. A provider that observes such metadata passes it to this consumer as the turn progresses — each call carries everything observed so far and replaces the value of any earlier call, so a turn that fails midway has still reported what was observed before the failure. A provider that observes no metadata never calls the consumer. The default implementation discards the metadata.
      Returns:
      the metadata consumer, never null
      Since:
      25.3