Skip to main content

Detect

A method for real-time evaluations or continuous monitoring to detect quality issues in LLM-generated text.

Parameters:

  • generatedText (string): The text generated by the LLM that needs to be analyzed.
  • context (array of strings): An array providing relevant context to analyze the generatedText against.
  • userQuery (string, optional): The user query or prompt that resulted in the generatedText.
  • config (object, optional): A dictionary of configuration options for the detector. Default value is { hallucination: { detector_name: 'default' } }.
  • instructions (string, optional): Additional instructions provided to the LLM.
  • asyncMode (boolean, optional): If true, the detect() function will return immediately with a DetectResult object. Default is false.
  • publish (boolean, optional): If true, the payload will be published to AIMon and can be viewed on the AIMon UI. Default is false.
  • applicationName (string, optional): Required if publish is true. Specifies the name of the application in AIMon.
  • modelName (string, optional): Required if publish is true. Specifies the name of the model in AIMon.

Usage Example

import Client from "aimon";

// Create the AIMon client using an API Key (retrievable from the UI in your user profile).
const aimon = new Client({ authHeader: "Bearer API_KEY" });

const runDetect = async () => {
const generatedText = "your_generated_text";
const context = ["your_context"];
const userQuery = "your_user_query";
const config = { hallucination: { detector_name: "default" } };

// Analyze the quality of the generated output using AIMon
const response = await aimon.detect(
generatedText,
context,
userQuery,
config,
undefined, // Optional instructions
false, // asyncMode
true, // publish
"YourApplicationName", // Required if publish is true
"YourModelName" // Required if publish is true
);

console.log("Response from detect:", response);
};

runDetect();