Skip to content

Conversation

@mikeldking
Copy link
Collaborator

@mikeldking mikeldking commented Nov 22, 2025

resolves #9125

/* eslint-disable no-console */
import { bindEvaluator, createHallucinationEvaluator } from "../src";

import { openai } from "@ai-sdk/openai";

const model = openai("gpt-4o-mini");

type ExampleType = {
  question: string;
  context: string;
  answer: string;
};
const examples: ExampleType[] = [
  {
    question: "Is Arize Phoenix Open Source?",
    context:
      "Arize Phoenix is a platform for building and deploying AI applications. It is open source.",
    answer: "Arize is not open source.",
  },
  {
    question: "Does Arize Phoenix cost money?",
    context:
      "Arize Phoenix is a platform for building and deploying AI applications. It is free to use.",
    answer: "No, Arize Phoenix is free to use.",
  },
];
async function main() {
  const evaluator = bindEvaluator<ExampleType>(
    createHallucinationEvaluator({
      model,
    }),
    {
      inputMapping: {
        input: "question",
        reference: "context",
        output: "answer",
      },
    }
  );

  for (const example of examples) {
    const result = await evaluator.evaluate(example);
    console.log(result);
  }
}

main().catch(console.error);

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-client@10360
npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-evals@10360
npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-mcp@10360
npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-otel@10360

commit: c186741

@mikeldking mikeldking marked this pull request as ready for review November 22, 2025 01:59
@mikeldking mikeldking requested a review from a team as a code owner November 22, 2025 01:59
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 22, 2025
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: 📘 Todo

Development

Successfully merging this pull request may close these issues.

[ts][evals] input mapping

2 participants