All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.newrelic.api.agent.AiMonitoring Maven / Gradle / Ivy

There is a newer version: 8.16.0
Show newest version
package com.newrelic.api.agent;

import java.util.Map;

/**
 * This interface defines methods for recording LlmFeedbackMessage events and setting a callback for token calculation.
 */
public interface AiMonitoring {
    /**
     * Records an LlmFeedbackMessage event.
     *
     * @param llmFeedbackEventAttributes A map containing the attributes of an LlmFeedbackMessage event. To construct
     *                                   the llmFeedbackEventAttributes map, use
     *                                   {@link LlmFeedbackEventAttributes.Builder}
     *                                   

The map must include:

*
    *
  • "traceId" (String): Trace ID where the chat completion related to the * feedback event occurred
  • *
  • "rating" (Integer/String): Rating provided by an end user
  • *
*

Optional attributes: *

    *
  • "category" (String): Category of the feedback as provided by the end user
  • *
  • "message" (String): Freeform text feedback from an end user
  • *
  • "metadata" (Map<String, String>): Set of key-value pairs to store * additional data to submit with the feedback event
  • *
* * */ void recordLlmFeedbackEvent(Map llmFeedbackEventAttributes); /** * Sets the callback function for calculating LLM tokens. * * @param llmTokenCountCallback The callback function to be invoked for counting LLM tokens. * Example usage: *
{@code
     *                              LlmTokenCountCallback llmTokenCountCallback = new LlmTokenCountCallback() {
     *                                  {@literal @}Override
     *                                  public Integer calculateLlmTokenCount(String model, String content) {
     *                                      // Token calculation based on model and content goes here
     *                                      // Return the calculated token count
     *                                  }
     *                               };
     *
     *                               // Set the created callback instance
     *                               NewRelic.getAgent().getAiMonitoring().setLlmTokenCountCallback(llmTokenCountCallback);
     *                               }
*/ void setLlmTokenCountCallback(LlmTokenCountCallback llmTokenCountCallback); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy