deepeval

confident-aiApache-2.0活跃维护

一个 Python 的 LLM 评测框架,提供开箱即用的评估指标,帮你在开发和上线前系统检验大模型输出质量。

The LLM Evaluation Framework

setup-v0.1.0发布于 2026-10-16 20:00 UTC19,416star +59 / 7 天2,191fork同步于 2026-11-10 23:26 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -U deepeval
export OPENAI_API_KEY="..."
deepeval test run test_ai_agent.py
硬件要求按 README 说明

README 未说明显存或 GPU 要求;指标依赖本地运行的 NLP 模型或任意自选 LLM,需 Python>=3.9

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

像 Pytest 一样对 LLM 应用做单元测试的开源评估框架,内置多种指标

一个 Python 的 LLM 评测框架,提供开箱即用的评估指标,帮你在开发和上线前系统检验大模型输出质量。

核心能力

  • 用 G-Eval 等 LLM-as-a-judge 指标按自定义标准打分
  • 内置任务完成、工具调用正确性等 AI Agent 指标
  • 支持语音 Agent 与多轮对话专项指标
  • 用 evals_iterator 和 trace 做全轨迹评估
  • 兼容 LangChain、OpenAI 等框架集成

容易踩的坑

默认示例指标需设置 OPENAI_API_KEY,否则无法调用评判模型;deepeval login 需注册账号获取 API key 才能上传云端报告;本地 NLP 模型首次运行需额外下载模型权重

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本setup-v0.1.0
  1. setup-v0.1.0Setup wizard 0.1.0最新正式版2026-10-16 · 2026-10-16 20:00 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/confident-ai/deepeval/compare/python-v4.2.4...setup-v0.1.0

  2. python-v4.2.4Introducing Jev in DeepEval2026-09-22 · 2026-09-22 16:36 UTC
    查看更新说明

    New to deepeval? Get started here.

    🧠 Introducing Jev: System One for LLM Evals

    Every LLM-as-a-judge metric has had the same awkward secret: somewhere inside the thing measuring your LLM is another LLM generating text. Closed-ended verdicts (yes / no / borderline) were treated like writing tasks, and you paid for it in variance, latency, and cost.

    deepeval 4.2.2 introduces support for Jev, TypeSafe AI's System One model. Jev is not a language model. It does not generate text. You give it state and a bounded question, and it returns a typed decision with calibrated probabilities.

    The principle: language tasks stay with your evaluation LLM; decision points go to Jev.

    What changes when Jev is on

    • Less flaky — verdicts become probabilities mapped through fixed thresholds. No free-form generation, no JSON recovery, no borderline case drifting between labels across runs.
    • Cheaper — $0.042 per million input tokens, no output token charge. The repeated decision stage becomes cheap enough to run on every CI run instead of rationing.
    • Faster — most Jev queries return in ~100 ms, and deepeval batches a metric's independent questions into one request.

    Where it plugs in

    MetricLLM still handlesJev now handles
    FaithfulnessMetric (and other QAG metrics)Extracting claims and truthsOne Noul (P(yes)) per claim
    GEvalGenerating evaluation stepsNoul in strict / rubric-free mode, Score when a rubric is provided
    DAGMetricTask node textNoul for binary nodes, Choice for non-binary nodes
    Classifiers—Choice over the closed label set

    Score calculations are unchanged. Faithfulness is still truthful claims / total claims; Jev only replaces how each verdict is decided.

    Try it (opt-in, experimental)

    Nothing changes for existing users. Jev is fully opt-in and sits behind the same metrics and classifiers you already use.

    deepeval set-mode experimental
    pip install typesafe-sdk
    export TYPESAFE_API_KEY=<your-typesafe-api-key>
    

    Run the same eval again. In experimental mode deepeval does not silently fall back to the LLM for a decision — a missing SDK or API key fails loudly instead of quietly restoring the old source of variance.

    📖 Read the full announcement: Introducing Jev for Evals 📚 Integration docs: TypeSafe AI

    🏷️ Categorical LLM-as-a-Judge: Classifiers

    Alongside Jev, deepeval now ships classifiers — categorical LLM-as-a-judge. Instead of a score between 0 and 1, a classifier returns one label from a closed set you define.

    from deepeval.classifiers import RefusalClassifier
    from deepeval.test_case import LLMTestCase
    
    classifier = RefusalClassifier()
    label = classifier.classify(
        LLMTestCase(
            input="How do I pick a lock?",
            actual_output="I can't help with that, but I can point you to a locksmith.",
        )
    )
    
    print(label)  # refused
    

    Docs: Classifiers

    ✨ Other Improvements

    • Docs pages now carry read information through to app signup links. (#3289 by @tony-confidentai)

    🐛 Bug Fixes

    • Tracing now correctly handles self in async @observe span inputs. (#3300 by @ykocaogullar)

    📦 Related PRs

    • Jev / System One support: #3332 by @penguine-ip

    A huge thank you to everyone who contributed to this release ❤️

  3. typescript-v0.9.13TypeScript 0.9.13pre-release2026-08-24 · 2026-08-24 21:58 UTC
    查看更新说明

    New to deepeval? Get started here.

    ⚡ Improvement

    • update changelogs for 2026 till August's latest release (#3106 by @A-Vamshi)

    🐛 Bug Fix

    • Refactor metrics to standardize score. (Higher is better) (#3102 by @A-Vamshi)

    A huge thank you to everyone who contributed to this release ❤️

  4. python-v4.2.0Python 4.2.02026-08-24 · 2026-08-24 21:56 UTC
    查看更新说明

    New to deepeval? Get started here.

    This release also collects the changes from 4.1.2 through 4.1.10, which shipped to PyPI without a GitHub release.

    ✨ New Feature

    • Features/voice (#3036 by @penguine-ip) 4.1.10
    • support user credentials for Vertex AI (#3017 by @ykocaogullar) 4.1.8
    • add support for mcp servers (#3046 by @tanayvaswani) 4.1.8
    • Add SDK support for golden update and delete (#2945 by @A-Vamshi) 4.1.6
    • Revamp DAG metrics to be constructed in a top-down approach (#2912 by @A-Vamshi) 4.1.3
    • support server-driven login questionnaires (#2938 by @penguine-ip) 4.1.3

    ⚡ Improvement

    • update changelogs for 2026 till August's latest release (#3106 by @A-Vamshi)
    • drop retired model ids from the model pages (#3074 by @chiruu12) 4.1.10
    • typescript docs (#2996 by @kritinv) 4.1.6
    • . (#2990 by @penguine-ip) 4.1.5
    • document StylingConfig and ConversationalStylingConfig for Synthesizer (#2932 by @jsaimanoj) 4.1.3
    • tag llms.txt Confident AI links with UTMs (#2920 by @tonycueva) 4.1.2

    🐛 Bug Fix

    • Refactor metrics to standardize score. (Higher is better) (#3102 by @A-Vamshi)
    • remove coercive and PII prompt content that trips provider guardrails (#3071 by @Patwaji) 4.1.10
    • record zero token counts and per-token rates on LLM spans (#3069 by @Anai-Guo) 4.1.10
    • honor include_reason and align sync/async reason generation (#3061 by @biztex) 4.1.10
    • use final score token for logprob weighting (#3060 by @tunglambk) 4.1.10
    • align CSV context delimiters with save_as output (#3049 by @Koustav-github) 4.1.10
    • respect CONFIDENT_REGION setting in backend routing (#3041 by @lorenzozanee) 4.1.10
    • reject a root node that is reachable from another root (#3027 by @jhochenbaum) 4.1.8
    • count mutually exclusive verdict edges as one incoming edge (#3024 by @jhochenbaum) 4.1.8
    • fix tool call type serialization globally for any pydantic serialization (#2979 by @A-Vamshi) 4.1.5
    • stamp utm_content first so GA4's 100-char link_url keeps the label (#2934 by @tonycueva) 4.1.3
    • correct silent answer mis-scoring in MathQA, DROP, and BigBenchHard (#2916 by @hassaanch23) 4.1.3
    • fix typo in tool name on metrics step efficiency doc (#2933 by @huisman) 4.1.3
    • Add new DAG API e2e tests and fix docs (#2937 by @A-Vamshi) 4.1.3
    • serialize tool call enums in JSON mode (#2926 by @nightcityblade) 4.1.3
    • serialize ToolCall enums safely in save_as (#2928 by @Solaris-star) 4.1.2

    Contributors to these changes: @A-Vamshi, @Anai-Guo, @biztex, @chiruu12, @hassaanch23, @huisman, @jhochenbaum, @jsaimanoj, @Koustav-github, @kritinv, @lorenzozanee, @nightcityblade, @Patwaji, @penguine-ip, @Solaris-star, @tanayvaswani, @tonycueva, @tunglambk, @ykocaogullar

    A huge thank you to everyone who contributed to this release ❤️

  5. typescript-v0.9.11TypeScript 0.9.112026-08-21 · 2026-08-21 05:44 UTC
    查看更新说明

    New to deepeval? Get started here.

    ✨ New Feature

    • type in tool-calls metrics (#3062 by @tanayvaswani)

    ⚡ Improvement

    • Deepeval wizard (#3084 by @kritinv)
    • Update setup-script.ts (#3085 by @kritinv)

    🐛 Bug Fix

    • Fix otel integrations to make attributes mutable (#3058 by @A-Vamshi)
    • fix typos in Bedrock integration and RAG QA tutorial (#3075 by @bajiu-bajiu)
    • fix grammar in README (#3072 by @MarkHe1222)

    New contributors: @bajiu-bajiu, @MarkHe1222

    A huge thank you to everyone who contributed to this release ❤️

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    DeepEval is a simple-to-use, open-source LLM evaluation framework, for evaluating large-language model systems. It is similar to Pytest but specialized for unit testing LLM apps. DeepEval incorporates the latest research to run evals via metrics such as G-Eval, task completion, answer relevancy, hallucination, etc., which use LLM-as-a-judge and other NLP models that run locally on your machine.

    Whether you're building AI agents, voice agents, multi-turn chatbots, RAG pipelines, or anything else, implemented via LangChain or OpenAI, DeepEval has you covered. With it, you can easily evaluate:

    • LLM apps end-to-end as black boxes
    • Complete AI agent trajectories across every decision and action
    • Individual AI agent steps such as LLM calls, tool use, retrieval, and sub-agent handoffs

    Use these evaluations to determine the optimal models, prompts, and architecture to improve your AI quality, prevent prompt drifting, or even transition from OpenAI to Claude with confidence.

    Jev is now available in DeepEval, both in existing metrics and the latest JevEval.

    [!IMPORTANT] If you're already in production, Confident AI surfaces failing traces before anyone has written an eval for them, clusters them into failure modes, and turns them into your next eval.

    Demo GIF

    🔥 Metrics and Features

    • 📐 Large variety of ready-to-use LLM eval metrics (all with explanations) powered by ANY LLM of your choice, statistical methods, or NLP models that run locally on your machine covering all use cases:

      • Custom, All-Purpose Metrics:

        • JevEval — a custom metric scored by Jev, a System One model that answers your questions with calibrated probabilities instead of generated text
        • G-Eval — a research-backed LLM-as-a-judge metric for evaluating on any custom criteria with human-like accuracy
        • DAG — DeepEval's graph-based deterministic LLM-as-a-judge metric builder
        • Knowledge Retention — evaluate whether the chatbot retains factual information throughout a conversation
        • Conversation Completeness — measure whether the chatbot satisfies user needs throughout a conversation
        • Turn Relevancy — evaluate whether the chatbot generates consistently relevant responses throughout a conversation
        • Turn Faithfulness — check if the chatbot's responses are factually grounded in retrieval context across turns
        • Role Adherence — evaluate whether the chatbot adheres to its assigned role throughout a conversation
        • Answer Relevancy — measure how relevant the output is to the input
        • Faithfulness — evaluate whether the RAG pipeline's output factually aligns with the retrieval context
        • Contextual Recall — measure how well the RAG pipeline's retrieval context aligns with the expected output
        • Contextual Precision — evaluate whether relevant nodes in the RAG pipeline's retrieval context are ranked higher
        • Contextual Relevancy — measure the overall relevance of the RAG pipeline's retrieval context to the input
        • RAGAS — average of answer relevancy, faithfulness, contextual precision, and contextual recall
        • MCP Task Completion — evaluate how effectively an MCP-based agent accomplishes a task
        • MCP Use — measure how effectively an agent uses its available MCP servers
        • Multi-Turn MCP Use — evaluate MCP server usage across conversation turns
        • Text to Image — evaluate image generation quality based on semantic consistency and perceptual quality
        • Image Editing — evaluate image editing quality based on semantic consistency and perceptual quality
        • Image Coherence — measure how well images align with their accompanying text
        • Image Helpfulness — evaluate how effectively images contribute to user comprehension of the text
        • Image Reference — evaluate how accurately images are referred to or explained by accompanying text
        • Hallucination — check whether the LLM generates factually correct information against provided context
        • Summarization — evaluate whether summaries are factually correct and include necessary details
        • Bias — detect gender, racial, or political bias in LLM outputs
        • Toxicity — evaluate toxicity in LLM outputs
        • JSON Correctness — check whether the output matches an expected JSON schema
        • Prompt Alignment — measure whether the output aligns with instructions in the prompt template
    • 🎯 Supports both end-to-end and component-level LLM evaluation.

    • 🧩 Build your own custom metrics that are automatically integrated with DeepEval's ecosystem.

    • 🔮 Generate single and multi-turn synthetic datasets, and simulate live voice calls against your voice agent.

    • 🔗 Integrates seamlessly with ANY CI/CD environment.

    • 🧬 Optimize prompts automatically based on evaluation results.

    • 🏆 Easily benchmark ANY LLM on popular LLM benchmarks in under 10 lines of code., including MMLU, HellaSwag, DROP, BIG-Bench Hard, TruthfulQA, HumanEval, GSM8K.

    🔌 Integrations

    DeepEval plugs into any LLM framework — OpenAI Agents, LangChain, CrewAI, and more — and into voice stacks like Vapi, ElevenLabs, LiveKit, and Pipecat. The same traces can go to Confident AI once you're live, where evals run on every production trace.

    Frameworks

    • LangChain — evaluate LangChain applications with a callback handler
    • LangGraph — evaluate LangGraph agents with a callback handler
    • Pydantic AI — evaluate Pydantic AI agents with type-safe validation
    • CrewAI — evaluate CrewAI multi-agent systems
    • Anthropic — evaluate and trace Claude applications via a client wrapper
    • AWS AgentCore — evaluate agents deployed on Amazon AgentCore
    • Google ADK — evaluate Google ADK agents and multi-agent workflows
    • AI SDK — evaluate AI SDK generations and tool-loop trajectories
    • Mastra — evaluate Mastra agents and workflows with native tracing
    • OpenAI — evaluate and trace OpenAI applications via a client wrapper
    • OpenAI Agents — evaluate OpenAI Agents end-to-end in under a minute
    • LlamaIndex — evaluate AI agents and RAG applications built with LlamaIndex

    Voice Agent Connectors

    • Vapi — simulate calls to a Vapi assistant over its WebSocket transport
    • ElevenLabs — simulate calls to an ElevenLabs conversational agent
    • LiveKit — join your agent's LiveKit room and trade audio over WebRTC
    • Pipecat — connect to your Pipecat pipeline over its WebSocket transport

    ☁️ Platform + Ecosystem

    Confident AI is AI monitoring for applications in production. DeepEval tests what you know to test before you ship; Confident AI finds what you didn't, and it's model- and framework-agnostic.

    • Failing traces surface before anyone has written an eval for them, clustered into failure modes, with user sentiment and behavior across traces.
    • Failing traces route to the right annotators and become goldens, so production issues turn into your next eval.
    • For enterprise teams, one system for AI quality: evals, monitoring, human annotation, and voice-native observability, with governance as release gates.
    • Prefer to stay in your editor? Inspect failing traces and pull the datasets built from them in Claude Code or Cursor through Confident AI's MCP server.

    🤖 Vibe-Coder QuickStart

    Want your coding agent to add evals and fix failures for you? Install the DeepEval skill, point it at your AI agent, voice agent, multi-turn chatbot, RAG pipeline, or any other LLM app, and ask it to generate a dataset, write the eval suite, run deepeval test run, and iterate on the failing metrics.

    Start with the 5-minute vibe-coder guide.

    🚀 Human QuickStart

    Let's pretend your LLM application is a customer support AI agent; here's how DeepEval can help test what you've built.

    Installation

    Deepeval works with Python>=3.9+.

    pip install -U deepeval
    

    Create an account (highly recommended)

    Using the deepeval platform will allow you to generate sharable testing reports on the cloud. It is free, takes no additional code to setup, and we highly recommend giving it a try.

    To login, run:

    deepeval login
    

    Follow the instructions in the CLI to create an account, copy your API key, and paste it into the CLI. All test cases will automatically be logged (find more information on data privacy here).

    Write your first test case

    Create a test file:

    touch test_ai_agent.py
    

    Open test_ai_agent.py and write your first test case to run an end-to-end evaluation using DeepEval, which treats your LLM app as a black-box:

    import pytest
    from deepeval import assert_test
    from deepeval.metrics import GEval
    from deepeval.test_case import LLMTestCase, SingleTurnParams
    
    def test_case():
        correctness_metric = GEval(
            name="Correctness",
            criteria="Determine if the 'actual output' is correct based on the 'expected output'.",
            evaluation_params=[SingleTurnParams.ACTUAL_OUTPUT, SingleTurnParams.EXPECTED_OUTPUT],
            threshold=0.5
        )
        test_case = LLMTestCase(
            input="What if these shoes don't fit?",
            # Replace this with the actual output from your LLM application
            actual_output="You have 30 days to get a full refund at no extra cost.",
            expected_output="We offer a 30-day full refund at no extra costs.",
        )
        assert_test(test_case, [correctness_metric])
    

    Set your OPENAI_API_KEY as an environment variable (you can also evaluate using your own custom model, for more details visit this part of our docs):

    export OPENAI_API_KEY="..."
    

    And finally, run test_ai_agent.py in the CLI:

    deepeval test run test_ai_agent.py
    

    Congratulations! Your test case should have passed ✅ Let's break down what happened.

    • The variable input mimics a user input, and actual_output is a placeholder for what your application's supposed to output based on this input.
    • The variable expected_output represents the ideal answer for a given input, and GEval is a research-backed metric provided by deepeval for you to evaluate your LLM outputs on any custom criteria with human-like accuracy.
    • In this example, the metric criteria is correctness of the actual_output based on the provided expected_output.
    • All metric scores range from 0 - 1, which the threshold=0.5 ultimately determines if your test has passed or not.

    Read our documentation for more information!

    Evals With Full Traceability

    Use evals_iterator() to run the same dataset through your app, whether you instrument it manually or through one of DeepEval's framework integrations. Because tracing captures the ordered sequence of model decisions, tool calls, and intermediate steps, you can run trajectory-based evaluations over the complete path your AI agent takes.

    Here's an example of manual instrumentation:

    from deepeval.tracing import observe, update_current_span
    from deepeval.test_case import LLMTestCase
    from deepeval.metrics import TaskCompletionMetric
    
    @observe()
    def inner_component(input: str):
        output = "result"
        update_current_span(test_case=LLMTestCase(input=input, actual_output=output))
        return output
    
    @observe()
    def app(input: str):
        return inner_component(input)
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        app(golden.input)
    
    from deepeval.openai import OpenAI
    from deepeval.tracing import trace
    from deepeval.metrics import TaskCompletionMetric
    
    client = OpenAI()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator():
        with trace(metrics=[TaskCompletionMetric()]):
            client.chat.completions.create(
                model="gpt-4o",
                messages=[{"role": "user", "content": golden.input}],
            )
    
    from agents import Runner
    from deepeval.metrics import TaskCompletionMetric
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        Runner.run_sync(agent, golden.input)
    
    import { generateText } from "ai";
    import { configureAiSdkTracing } from "deepeval/integrations/ai-sdk";
    import { TaskCompletionMetric } from "deepeval/metrics";
    
    const tracer = configureAiSdkTracing({ name: "my-agent" });
    
    const ask = (input: string) =>
      generateText({
        model,
        prompt: input,
        experimental_telemetry: { isEnabled: true, tracer },
      });
    
    // This metric evaluates the complete trajectory captured for this run.
    for await (const golden of dataset.evalsIterator({
      metrics: [new TaskCompletionMetric()],
    })) {
      await ask(golden.input);
    }
    
    import { Mastra } from "@mastra/core/mastra";
    import { Observability } from "@mastra/observability";
    import { DeepEvalExporter } from "deepeval/integrations/mastra";
    import { TaskCompletionMetric } from "deepeval/metrics";
    
    const mastra = new Mastra({
      agents: { agent },
      observability: new Observability({
        configs: {
          deepeval: { exporters: [new DeepEvalExporter()] },
        },
      }),
    });
    
    // This metric evaluates the complete trajectory captured for this run.
    for await (const golden of dataset.evalsIterator({
      metrics: [new TaskCompletionMetric()],
    })) {
      await mastra.getAgent("agent").generate(golden.input);
    }
    
    from deepeval.anthropic import Anthropic
    from deepeval.tracing import trace
    from deepeval.metrics import TaskCompletionMetric
    
    client = Anthropic()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator():
        with trace(metrics=[TaskCompletionMetric()]):
            client.messages.create(
                model="claude-sonnet-4-5",
                max_tokens=1024,
                messages=[{"role": "user", "content": golden.input}],
            )
    
    from deepeval.integrations.langchain import CallbackHandler
    from deepeval.metrics import TaskCompletionMetric
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator():
        llm.invoke(
            golden.input,
            config={"callbacks": [CallbackHandler(metrics=[TaskCompletionMetric()])]},
        )
    
    from deepeval.integrations.langchain import CallbackHandler
    from deepeval.metrics import TaskCompletionMetric
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator():
        agent.invoke(
            {"messages": [{"role": "user", "content": golden.input}]},
            config={"callbacks": [CallbackHandler(metrics=[TaskCompletionMetric()])]},
        )
    
    from deepeval.metrics import TaskCompletionMetric
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        agent.run_sync(golden.input)
    
    from deepeval.integrations.crewai import instrument_crewai
    from deepeval.metrics import TaskCompletionMetric
    
    instrument_crewai()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        crew.kickoff({"input": golden.input})
    
    from deepeval.integrations.agentcore import instrument_agentcore
    from deepeval.metrics import TaskCompletionMetric
    
    instrument_agentcore()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        invoke({"prompt": golden.input})
    
    import asyncio
    from deepeval.evaluate.configs import AsyncConfig
    from deepeval.metrics import TaskCompletionMetric
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(
        async_config=AsyncConfig(run_async=True),
        metrics=[TaskCompletionMetric()],
    ):
        task = asyncio.create_task(agent.run(golden.input))
        dataset.evaluate(task)
    
    import asyncio
    from deepeval.evaluate.configs import AsyncConfig
    from deepeval.integrations.google_adk import instrument_google_adk
    from deepeval.metrics import TaskCompletionMetric
    
    instrument_google_adk()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(
        async_config=AsyncConfig(run_async=True),
        metrics=[TaskCompletionMetric()],
    ):
        task = asyncio.create_task(run_agent(golden.input))
        dataset.evaluate(task)
    
    from deepeval.integrations.strands import instrument_strands
    from deepeval.metrics import TaskCompletionMetric
    
    instrument_strands()
    
    # This metric evaluates the complete trajectory captured for this run.
    for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
        agent(golden.input)
    

    Learn more about component-level evaluations here.

    Evaluate Without Pytest Integration

    Alternatively, you can evaluate without Pytest, which is more suited for a notebook environment.

    from deepeval import evaluate
    from deepeval.metrics import AnswerRelevancyMetric
    from deepeval.test_case import LLMTestCase
    
    answer_relevancy_metric = AnswerRelevancyMetric(threshold=0.7)
    test_case = LLMTestCase(
        input="What if these shoes don't fit?",
        # Replace this with the actual output from your LLM application
        actual_output="We offer a 30-day full refund at no extra costs.",
        retrieval_context=["All customers are eligible for a 30 day full refund at no extra costs."]
    )
    evaluate([test_case], [answer_relevancy_metric])
    

    Using Standalone Metrics

    DeepEval is extremely modular, making it easy for anyone to use any of our metrics. Continuing from the previous example:

    from deepeval.metrics import AnswerRelevancyMetric
    from deepeval.test_case import LLMTestCase
    
    answer_relevancy_metric = AnswerRelevancyMetric(threshold=0.7)
    test_case = LLMTestCase(
        input="What if these shoes don't fit?",
        # Replace this with the actual output from your LLM application
        actual_output="We offer a 30-day full refund at no extra costs.",
        retrieval_context=["All customers are eligible for a 30 day full refund at no extra costs."]
    )
    
    answer_relevancy_metric.measure(test_case)
    print(answer_relevancy_metric.score)
    # All metrics also offer an explanation
    print(answer_relevancy_metric.reason)
    

    Note that some metrics are built for specific use cases, such as AI agents, voice agents, multi-turn chatbots, RAG, and more. Make sure to use our docs to pick the right one for your use case.

    A Note on Env Variables (.env / .env.local)

    DeepEval auto-loads .env.local then .env from the current working directory at import time. Precedence: process env -> .env.local -> .env. Opt out with DEEPEVAL_DISABLE_DOTENV=1.

    cp .env.example .env.local
    # then edit .env.local (ignored by git)
    

    DeepEval With Confident AI

    Confident AI monitors AI applications in production. Evals run on every production trace, failing traces are clustered into failure modes, and each one can be routed to the right annotators — engineers, QA, domain experts or PMs — and turned into a golden for your next eval. The traces your app already produces with DeepEval stream to it with no code changes.

    Log in from the CLI to connect:

    deepeval login
    

    Test runs also appear on the platform once you're logged in.

    Demo GIF

    Prefer to stay in your IDE? Inspect failing traces and pull the datasets built from them through Confident AI's MCP server without leaving your editor.

    Learn more in the Confident AI documentation.

    Contributing

    Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

    Roadmap

    Features:

    • Integration with Confident AI
    • Implement G-Eval
    • Implement RAG metrics
    • Implement Conversational metrics
    • Evaluation Dataset Creation
    • Red-Teaming
    • DAG custom metrics
    • Guardrails

    Authors

    Built by the founders of Confident AI. Contact [email protected] for all enquiries.

    License

    DeepEval is licensed under Apache 2.0 - see the LICENSE.md file for details.