Skip to content
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

fix template name #1013

Merged
merged 2 commits into from
Dec 7, 2023
Merged
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
42 changes: 26 additions & 16 deletions agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,33 @@ async def add_testset_to_app_variant(
**kwargs (dict): Additional keyword arguments
"""

app_db = await get_app_instance_by_id(app_id)
org_db = await get_organization_object(org_id)
user_db = await get_user(user_uid=kwargs["uid"])

if template_name == "single_prompt":
json_path = (
f"{PARENT_DIRECTORY}/resources/default_testsets/single_prompt_testsets.json"
try:
app_db = await get_app_instance_by_id(app_id)
org_db = await get_organization_object(org_id)
user_db = await get_user(user_uid=kwargs["uid"])

json_path = os.path.join(
PARENT_DIRECTORY,
"resources",
"default_testsets",
f"{template_name}_testset.json",
)
csvdata = get_json(json_path)
testset = {
"name": f"{app_name}_testset",
"app_name": app_name,
"created_at": datetime.now().isoformat(),
"csvdata": csvdata,
}
testset = TestSetDB(**testset, app=app_db, user=user_db, organization=org_db)
await engine.save(testset)

if os.path.exists(json_path):
csvdata = get_json(json_path)
testset = {
"name": f"{app_name}_testset",
"app_name": app_name,
"created_at": datetime.now().isoformat(),
"csvdata": csvdata,
}
testset_db = TestSetDB(
**testset, app=app_db, user=user_db, organization=org_db
)
await engine.save(testset_db)

except Exception as e:
print(f"An error occurred in adding the default testset: {e}")


async def get_image(app_variant: AppVariant, **kwargs: dict) -> ImageExtended:
Expand Down
Loading