Class LLMResponse

java.lang.Object
com.tnsai.integration.scop.LLMResponse

public class LLMResponse extends Object
Wrapper for LLM responses (TEXT, TOOL_CALLS, or ERROR).
  • Method Details

    • text

      public static LLMResponse text(String content, org.json.JSONObject rawMessage)
    • toolCalls

      public static LLMResponse toolCalls(org.json.JSONArray toolCalls, org.json.JSONObject rawMessage)
    • error

      public static LLMResponse error(String errorMessage)
    • error

      public static LLMResponse error(String diagnosticMessage, Exception failure)
      Retains a diagnostic message and the original failure locally. Neither is public display text; use getSafeErrorMessage() at that boundary. getErrorMessage() and getDisplayContent() keep their existing diagnostic behaviour.
      Since:
      0.17.5
    • getType

      public LLMResponse.Type getType()
    • getContent

      public String getContent()
    • getToolCalls

      public org.json.JSONArray getToolCalls()
    • getRawMessage

      public org.json.JSONObject getRawMessage()
    • getErrorMessage

      public String getErrorMessage()
    • getException

      @JSONPropertyIgnore public Exception getException()
      Original local failure; never serialize it into a public response. @since 0.17.5
    • getSafeErrorMessage

      public String getSafeErrorMessage()
      Fixed display text derived only from a typed LLMException category, never from diagnostics; a generic message when no typed failure is retained. null for non-ERROR responses.
      Since:
      0.17.5
    • isSuccess

      public boolean isSuccess()
    • hasToolCalls

      public boolean hasToolCalls()
    • hasText

      public boolean hasText()
    • getDisplayContent

      public String getDisplayContent()
      Gets displayable content (text content or error message).