MCE Opik Adapter
A Python adapter library that integrates Opik metrics as third-party plugins for the Metric Computation Engine (MCE). This adapter enables seamless use of Opik's LLM evaluation metrics within the MCE framework for evaluating agentic applications.
Installation
Install via MCE extras:
pip install "metrics-computation-engine[opik]"
Prerequisites
- Metric Computation Engine (MCE) installed
- Agentic applications instrumented with AGNTCY's observe SDK
Supported Opik Metrics
The following Opik metrics are supported by this adapter (use with the opik. prefix in service payloads):
| Metric Name | Description |
|---|---|
| Hallucination | Evaluates whether the model response contains hallucinations |
| Sentiment | Measures the sentiment of a model response |
For requests to support additional Opik metrics, please file an issue in our repo: agntcy/telemetry-hub.
Usage
Basic Usage
import asyncio
from mce_opik_adapter.adapter import OpikMetricAdapter
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 Opik metrics
registry = MetricRegistry()
# Method 1: Direct registration with metric name
registry.register_metric(OpikMetricAdapter, "Hallucination")
# Method 2: Using get_metric_class helper with prefix
from metrics_computation_engine.util import get_metric_class
metric, metric_name = get_metric_class("opik.Hallucination")
registry.register_metric(metric, metric_name)
Using with MCE REST API
When using the MCE as a service, include Opik metrics in your API request:
{
"metrics": [
"opik.Hallucination",
"opik.Sentiment"
],
"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:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
Metadata
Release files for mce-opik-adapter 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mce_opik_adapter-0.1.6.tar.gz | 362.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mce_opik_adapter-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 372.1 kB
Release files / mce_opik_adapter-0.1.6.tar.gz
| Download URL | mce_opik_adapter-0.1.6.tar.gz |
|---|---|
| Size | 362.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68f369fd00815941699f04960a1d79555c57256b541e80e8b7abeadd5a146191
|
|
BLAKE2b-256 checksum How to use checksums |
c6d9eb165a5e20d4251f5dee7ffd3f3e22af70fe2aaf92600d9464011f0572db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / mce_opik_adapter-0.1.6-py3-none-any.whl
| Download URL | mce_opik_adapter-0.1.6-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
482988189d4efa73fc8b7eedd55e4019d11bc7fa176ef3a9dee4a90d1e46aadd
|
|
BLAKE2b-256 checksum How to use checksums |
eb9ae2d234eb50ac024cb1ff460b1d7834e7f1a4a84c4f666c05f3022b0cbb34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|