LLMonitor (Browser)

Class: LLMonitor

Constructor

  • constructor(): Initializes the LLMonitor instance.

Methods

  • init({ appId, verbose, apiUrl }: { appId?: string, verbose?: boolean, apiUrl?: string }): Initializes the LLMonitor with the provided options.

  • identify(userId: string, userProps: cJSON): Sets the user ID and properties for the LLMonitor.

  • trackEvent(type: string, event: string, data: RunEvent): Tracks an event with the provided type, event name, and data. The data parameter is of type RunEvent, which has the following structure:

    • type: The type of the event. It can be one of the following: "log", "tool", "agent", "llm", "convo", "chain", "retriever", "embed", "chat", "convo".
    • event: The name of the event. It can be one of the following: "start", "end", "error", "info", "warn", "feedback".
    • app: The ID of the app.
    • timestamp: The timestamp of the event.
    • userId: The ID of the user (optional).
    • userProps: The properties of the user (optional).
    • parentRunId: The ID of the parent run (optional).
    • extra: Extra data (optional).
    • tags: Tags associated with the event (optional).
    • runtime: The runtime of the event (optional).
    • error: The error object, if any, with properties message and stack (optional).
    • runId: The ID of the run.
    • input: The input data (optional).
    • output: The output data (optional).
    • tokensUsage: The token usage data (optional).
  • trackFeedback(messageId: string, feedback: cJSON): Tracks feedback for a specific message.

  • startChat() -> Conversation: Starts a new chat conversation and returns a Conversation instance.

Class: Conversation

Constructor

  • constructor(monitor: LLMonitor): Initializes the Conversation instance with a provided LLMonitor.

Methods

  • trackUserMessage(text: string, props?: cJSON, customId?: string) -> string: Tracks a new message from the user and returns the message ID.

  • trackBotMessage(replyToId: string, text: string, props?: cJSON): Tracks a new message from the bot.

(React Specific Exports) Hooks

  • useChatMonitor() -> { restart: Function, trackUserMessage: Function, trackBotMessage: Function, trackFeedback: Function }: A React hook that provides functions for starting a new conversation, tracking user messages, tracking bot messages, and tracking feedback.

  • useMonitorVercelAI(props) -> { ...props, trackFeedback: Function }: A React hook that provides a function for tracking feedback in addition to the properties passed in.

Questions? We're here to help.