Skip to main content
Glama
Arize-ai

@arizeai/phoenix-mcp

Official
by Arize-ai
createHallucinationEvaluator.ts2.1 kB
import { HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG } from "../__generated__/default_templates"; import { CreateClassificationEvaluatorArgs } from "../types/evals"; import { ClassificationEvaluator } from "./ClassificationEvaluator"; import { createClassificationEvaluator } from "./createClassificationEvaluator"; export interface HallucinationEvaluatorArgs< RecordType extends Record<string, unknown> = HallucinationEvaluationRecord, > extends Omit< CreateClassificationEvaluatorArgs<RecordType>, "promptTemplate" | "choices" | "optimizationDirection" | "name" > { optimizationDirection?: CreateClassificationEvaluatorArgs<RecordType>["optimizationDirection"]; name?: CreateClassificationEvaluatorArgs<RecordType>["name"]; choices?: CreateClassificationEvaluatorArgs<RecordType>["choices"]; promptTemplate?: CreateClassificationEvaluatorArgs<RecordType>["promptTemplate"]; } /** * A record to be evaluated by the hallucination evaluator. */ export type HallucinationEvaluationRecord = { input: string; output: string; context?: string; }; /** * Creates a function that evaluates whether an answer is factual or hallucinated based on a query and reference text. * * @param args - The arguments for creating the hallucination evaluator. * @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text. */ export function createHallucinationEvaluator< RecordType extends Record<string, unknown> = HallucinationEvaluationRecord, >( args: HallucinationEvaluatorArgs<RecordType> ): ClassificationEvaluator<RecordType> { const { choices = HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.choices, promptTemplate = HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.template, optimizationDirection = HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.optimizationDirection, name = HALLUCINATION_CLASSIFICATION_EVALUATOR_CONFIG.name, ...rest } = args; return createClassificationEvaluator<RecordType>({ ...rest, promptTemplate, choices, optimizationDirection, name, }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arize-ai/phoenix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server