Class Audit

java.lang.Object
io.quarkiverse.langchain4j.audit.Audit

public abstract class Audit extends Object
Abstract class to be implemented in order to keep track of whatever information is useful for the application auditing.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Information about the AiService that is being audited
  • Constructor Summary

    Constructors
    Constructor
    Description
    Audit(Audit.CreateInfo createInfo)
    Invoked by AuditService when an AiService is invoked
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addApplicationToLLMMessage(dev.langchain4j.data.message.ToolExecutionResultMessage toolExecutionResultMessage)
    Invoked with a response from an LLM.
    void
    addLLMToApplicationMessage(dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> response)
    Invoked with a response from an LLM.
    void
    addRelevantDocument(List<dev.langchain4j.data.segment.TextSegment> segments, dev.langchain4j.data.message.UserMessage userMessage)
    Invoked if a relevant document was added to the messages to be sent to the LLM
     
    void
    initialMessages(Optional<dev.langchain4j.data.message.SystemMessage> systemMessage, dev.langchain4j.data.message.UserMessage userMessage)
    Invoked when the original user and system messages have been created
    void
    Invoked when the final result of the AiService method has been computed
    void
    Invoked when there was an exception computing the result of the AiService method

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getCreateInfo

      public Audit.CreateInfo getCreateInfo()
      Returns:
      information about the AiService that is being audited
    • initialMessages

      public void initialMessages(Optional<dev.langchain4j.data.message.SystemMessage> systemMessage, dev.langchain4j.data.message.UserMessage userMessage)
      Invoked when the original user and system messages have been created
    • addRelevantDocument

      public void addRelevantDocument(List<dev.langchain4j.data.segment.TextSegment> segments, dev.langchain4j.data.message.UserMessage userMessage)
      Invoked if a relevant document was added to the messages to be sent to the LLM
    • addLLMToApplicationMessage

      public void addLLMToApplicationMessage(dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> response)
      Invoked with a response from an LLM. It is important to note that this can be invoked multiple times when tools exist.
    • addApplicationToLLMMessage

      public void addApplicationToLLMMessage(dev.langchain4j.data.message.ToolExecutionResultMessage toolExecutionResultMessage)
      Invoked with a response from an LLM. It is important to note that this can be invoked multiple times when tools exist.
    • onCompletion

      public void onCompletion(Object result)
      Invoked when the final result of the AiService method has been computed
    • onFailure

      public void onFailure(Exception e)
      Invoked when there was an exception computing the result of the AiService method