Skip to content

Commit

Permalink
Merge pull request #1289 from Agenta-AI/1283-sub-issue-forward-errors…
Browse files Browse the repository at this point in the history
…-in-llm-app

Update - modified agenta sdk handle_exception
  • Loading branch information
mmabrouk authored Jan 27, 2024
2 parents 75154ac + 93cc642 commit b367d71
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,23 @@ async def migrate_old_auto_evaluation_scenario_to_new_auto_evaluation_scenario(
EvaluationScenarioResult(
evaluator_config=PydanticObjectId(evaluator_config),
result=Result(
type="number"
if isinstance(old_scenario.score, int)
else "number"
if isinstance(old_scenario.score, float)
else "string"
if isinstance(old_scenario.score, str)
else "boolean"
if isinstance(old_scenario.score, bool)
else "any",
type=(
"number"
if isinstance(old_scenario.score, int)
else (
"number"
if isinstance(old_scenario.score, float)
else (
"string"
if isinstance(old_scenario.score, str)
else (
"boolean"
if isinstance(old_scenario.score, bool)
else "any"
)
)
)
),
value=old_scenario.score,
),
)
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/models/converters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Converts db models to pydantic models
"""

import json
from typing import List
from agenta_backend.services import db_manager
Expand Down
16 changes: 10 additions & 6 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,16 @@ async def create_app_and_variant_from_template(
app_variant_db = await app_manager.add_variant_based_on_image(
app=app,
variant_name="app.default",
docker_id_or_template_uri=template_db.template_uri
if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]
else template_db.digest,
tags=f"{image_name}"
if os.environ["FEATURE_FLAG"] not in ["cloud", "ee"]
else None,
docker_id_or_template_uri=(
template_db.template_uri
if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]
else template_db.digest
),
tags=(
f"{image_name}"
if os.environ["FEATURE_FLAG"] not in ["cloud", "ee"]
else None
),
base_name="app",
config_name="default",
is_template_image=True,
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/services/app_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main Business logic
"""

import os
import logging
from urllib.parse import urlparse
Expand Down
8 changes: 5 additions & 3 deletions agenta-backend/agenta_backend/tasks/evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ def evaluate(
name=input_item["name"],
type="text",
value=data_point[
input_item["name"]
if input_item["type"] != "messages"
else "chat"
(
input_item["name"]
if input_item["type"] != "messages"
else "chat"
)
], # TODO: We need to remove the hardcoding of chat as name for chat inputs from the FE
)
for input_item in list_inputs
Expand Down
4 changes: 3 additions & 1 deletion agenta-cli/agenta/sdk/agenta_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The code for the Agenta SDK"""

import os
import sys
import time
Expand Down Expand Up @@ -184,9 +185,10 @@ async def execute_function(
def handle_exception(e: Exception) -> JSONResponse:
"""Handle exceptions and return a JSONResponse."""

status_code: int = e.status_code if hasattr(e, "status_code") else 500
traceback_str = traceback.format_exception(e, value=e, tb=e.__traceback__)
return JSONResponse(
status_code=500,
status_code=status_code,
content={"error": str(e), "traceback": "".join(traceback_str)},
)

Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "agenta"
version = "0.8.2"
version = "0.8.3"
description = "The SDK for agenta is an open-source LLMOps platform."
readme = "README.md"
authors = ["Mahmoud Mabrouk <[email protected]>"]
Expand Down

0 comments on commit b367d71

Please sign in to comment.