Skip to content

Make evaluation name optional #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions aimon/decorators/evaluate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps

from datetime import datetime
from aimon import Client
import inspect
import warnings
Expand Down Expand Up @@ -144,8 +144,8 @@ def evaluate(
application_name,
model_name,
dataset_collection_name,
evaluation_name,
headers,
evaluation_name=None,
headers=None,
api_key=None,
aimon_client=None,
config=None
Expand Down Expand Up @@ -222,6 +222,11 @@ def evaluate(
application = Application(name=application_name, stage="evaluation")
model = Model(name=model_name, model_type="text")

# Auto-generate evaluation name if not provided
if not evaluation_name:
timestamp = datetime.utcnow().strftime("%Y%m%dT%H%M%S")
evaluation_name = f"{application_name}-{model_name}-{timestamp}"

# Validata headers to be non-empty and contain atleast the context_docs column
if not headers:
raise ValueError("Headers must be a non-empty list")
Expand Down
44 changes: 43 additions & 1 deletion tests/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,46 @@ def test_evaluate_with_custom_client(self):

except Exception as e:
self.log_info("Test error", str(e))
raise
raise

def test_evaluate_without_evaluation_name(self):
"""Test the evaluate function when no evaluation name is provided."""
if not self.api_key:
pytest.skip("AIMON_API_KEY environment variable not set")

try:
# Create test data
test_data = self.create_test_data()

headers = ["context_docs", "user_query", "output", "prompt", "task_definition"]
config = {'hallucination': {'detector_name': 'default'}}

self.log_info("Starting evaluate test without evaluation_name", {
"Application": self.app_name,
"Model": self.model_name,
"Collection": self.collection_name,
"Headers": headers,
"Config": config
})

# Call evaluate without providing evaluation_name
results = evaluate(
application_name=self.app_name,
model_name=self.model_name,
dataset_collection_name=self.collection_name,
headers=headers, # evaluation_name omitted
api_key=self.api_key,
config=config
)

assert len(results) == 2
assert isinstance(results[0], EvaluateResponse)
assert results[0].output in ["Paris is the capital of France.", "Python is a versatile programming language."]
assert hasattr(results[0].response, 'status')
assert results[0].response.status == 200

self.log_info("Test completed successfully", "Auto-generated evaluation_name handled correctly")

except Exception as e:
self.log_info("Test error", str(e))
raise