Skip to main content

MCE Ragas Adapter

A Python adapter library that integrates Ragas metrics as third-party plugins for the Metric Computation Engine (MCE). This adapter enables seamless use of Ragas's LLM evaluation metrics within the MCE framework for evaluating agentic applications.

Installation

Install via MCE extras:

pip install "metrics-computation-engine[ragas]"

Prerequisites

Supported Ragas Metrics

The following Ragas metrics are supported by this adapter (use with the ragas. prefix in service payloads):

Metric Name Description
TopicAdherenceScore Evaluates whether the model response adheres to the intended topic

For requests to support additional Ragas metrics, please file an issue in our repo: agntcy/telemetry-hub.

Usage

Basic Usage

import asyncio
from mce_ragas_adapter.adapter import RagasMetricAdapter
from metrics_computation_engine.models.requests import LLMJudgeConfig
from metrics_computation_engine.registry import MetricRegistry

# Initialize LLM configuration
llm_config = LLMJudgeConfig(
    LLM_BASE_MODEL_URL="https://api.openai.com/v1",
    LLM_MODEL_NAME="gpt-4o",
    LLM_API_KEY="your-api-key-here"
)

# Create registry and register Ragas metrics
registry = MetricRegistry()

# Method 1: Direct registration with metric name
registry.register_metric(RagasMetricAdapter, "TopicAdherenceScore")

# Method 2: Using get_metric_class helper with prefix
from metrics_computation_engine.util import get_metric_class
metric, metric_name = get_metric_class("ragas.TopicAdherenceScore")
registry.register_metric(metric, metric_name)

Using with MCE REST API

When using the MCE as a service, include Ragas metrics in your API request:

{
  "metrics": [
    "ragas.TopicAdherenceScore"
  ],
  "llm_judge_config": {
    "LLM_API_KEY": "your-api-key",
    "LLM_MODEL_NAME": "gpt-4o",
    "LLM_BASE_MODEL_URL": "https://api.openai.com/v1"
  },
  "data_fetching_infos": {
    "batch_config": {
      "time_range": { "start": "2024-01-01T00:00:00Z", "end": "2024-12-31T23:59:59Z" }
    },
    "session_ids": []
  }
}

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.

Metadata

Release files for mce-ragas-adapter 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mce-ragas-adapter 0.1.3
File Size Uploaded Provenance Actions
mce_ragas_adapter-0.1.3.tar.gz 223.2 kB Without provenance Details for mce_ragas_adapter-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mce-ragas-adapter 0.1.3
File Interpreter ABI Platform Actions
mce_ragas_adapter-0.1.3-py3-none-any.whl Python 3 none any Details for mce_ragas_adapter-0.1.3-py3-none-any.whl

Total release size: 236.6 kB

Release files / mce_ragas_adapter-0.1.3.tar.gz

Download URL mce_ragas_adapter-0.1.3.tar.gz
Size 223.2 kB
Tags Source
SHA-256 checksum
How to use checksums
37751f8d54a378509f94c981216b0f60dcef5f53e4038a0d5e07ba96f294c1f9
BLAKE2b-256 checksum
How to use checksums
88a4ea1f4eac168f11ad078882fe216f344a308dc03c6e8dc45f8172abeacfea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / mce_ragas_adapter-0.1.3-py3-none-any.whl

Download URL mce_ragas_adapter-0.1.3-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0141e46441153e81ff7feb3da3633283fbc0f5d73f582416683e5a3ad43316c4
BLAKE2b-256 checksum
How to use checksums
443e12b1a9d140a8bbad97da4cc48e0148521e0eb0c764c1261a5bda86b12ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for mce-ragas-adapter 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page