Skip to content

Commit

Permalink
create new human eval service updated to add revision
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Jan 23, 2024
1 parent 607459e commit efa25ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
18 changes: 7 additions & 11 deletions agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async def fetch_app_variant_by_id(


async def fetch_app_variant_revision_by_variant(
app_variant_id: str, revision: int = None
app_variant_id: str, revision: int
) -> AppVariantRevisionsDB:
"""Fetches app variant revision by variant id and revision
Expand All @@ -205,16 +205,12 @@ async def fetch_app_variant_revision_by_variant(
AppVariantRevisionDB
"""
assert app_variant_id is not None, "app_variant_id cannot be None"
if revision:
app_variant_revision = await AppVariantRevisionsDB.find_one(
AppVariantRevisionsDB.variant.id == ObjectId(app_variant_id),
AppVariantRevisionsDB.revision == revision,
)
else:
app_variant_revision = await AppVariantRevisionsDB.find(
AppVariantRevisionsDB.variant.id == ObjectId(app_variant_id),
fetch_links=True,
).to_list()
assert revision is not None, "revision cannot be None"
app_variant_revision = await AppVariantRevisionsDB.find_one(
AppVariantRevisionsDB.variant.id == ObjectId(app_variant_id),
AppVariantRevisionsDB.revision == revision,
)

if app_variant_revision is None:
raise Exception(
f"app variant revision for app_variant {app_variant_id} and revision {revision} not found"
Expand Down
7 changes: 7 additions & 0 deletions agenta-backend/agenta_backend/services/evaluation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,20 @@ async def create_new_human_evaluation(

testset = await db_manager.fetch_testset_by_id(testset_id=payload.testset_id)
# Initialize and save evaluation instance to database
variant_revisions = [
await db_manager.fetch_app_variant_revision_by_variant(
str(variant.id), int(variant.revision)
)
for variant in variants
]
eval_instance = HumanEvaluationDB(
app=app,
organization=app.organization, # Assuming user has an organization_id attribute
user=user,
status=payload.status,
evaluation_type=payload.evaluation_type,
variants=variants,
variant_revisions=variant_revisions,
testset=testset,
created_at=current_time,
updated_at=current_time,
Expand Down

0 comments on commit efa25ba

Please sign in to comment.