Skip to content

Commit

Permalink
hotfix(agents-api): Session APIs throw Internal Server Error
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Dec 31, 2024
1 parent 3c6c86e commit ad8dd18
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion agents-api/agents_api/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def get_handler(system: SystemDef) -> Callable:
from ..models.docs.list_docs import list_docs as list_docs_query
from ..models.entry.get_history import get_history as get_history_query
from ..models.session.create_session import create_session as create_session_query
from ..models.session.delete_session import delete_session as delete_session_query
from ..models.session.get_session import get_session as get_session_query
from ..models.session.list_sessions import list_sessions as list_sessions_query
from ..models.session.update_session import update_session as update_session_query
Expand Down
8 changes: 4 additions & 4 deletions agents-api/agents_api/metrics/counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
INF,
)
counter = Counter(
f"db_query_counter",
f"Number of db calls",
"db_query_counter",
"Number of db calls",
labelnames=labelnames,
)
summary = Summary(
f"db_query_latency_summary",
"db_query_latency_summary",
"Database query latency summary",
labelnames=labelnames,
)
hist = Histogram(
f"db_query_latency_hist",
"db_query_latency_hist",
"Database query latency histogram",
labelnames=labelnames,
buckets=buckets,
Expand Down
8 changes: 7 additions & 1 deletion agents-api/agents_api/models/session/list_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
TypeError: partialclass(HTTPException, status_code=400),
}
)
@wrap_in_class(make_session)
@wrap_in_class(
make_session,
transform=lambda d: {
"updated_at": d.pop("updated_at") / (1000000.0),
**d,
},
)
@cozo_query
@beartype
def list_sessions(
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/models/session/patch_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
one=True,
transform=lambda d: {
"id": d["session_id"],
"updated_at": d.pop("updated_at")[0],
"updated_at": d.pop("updated_at")[0] / (1000000.0),
"jobs": [],
**d,
},
Expand Down
7 changes: 6 additions & 1 deletion agents-api/agents_api/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,12 @@ def _return_data(df: pd.DataFrame):
transform = transform or (lambda x: x)

if one:
assert len(data) >= 1, "Expected one result, got none"
resource_name = cls.__name__ if isinstance(cls, type) else "Resource"
if len(data) < 1:
raise HTTPException(
status_code=404, detail=f"{resource_name} not found"
)

obj: ModelT = cls(**transform(data[0]))
return obj

Expand Down
3 changes: 1 addition & 2 deletions agents-api/agents_api/routers/healthz/check_health.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from uuid import UUID

from ...autogen.openapi_model import Agent, ListResponse
from ...models.agent.list_agents import list_agents as list_agents_query
from .router import router

Expand All @@ -10,7 +9,7 @@
async def check_health() -> dict:
try:
# Check if the database is reachable
agents = list_agents_query(
list_agents_query(
developer_id=UUID("00000000-0000-0000-0000-000000000000"),
)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion sdks/python-sdk
Submodule python-sdk updated 54 files
+1 −1 .release-please-manifest.json
+2 −2 .stats.yml
+148 −0 CHANGELOG.md
+25 −14 README.md
+14 −0 api.md
+4 −1 mypy.ini
+3 −3 pyproject.toml
+5 −3 requirements-dev.lock
+2 −2 requirements.lock
+2 −1 src/julep/__init__.py
+8 −4 src/julep/_base_client.py
+69 −58 src/julep/_client.py
+3 −5 src/julep/_compat.py
+5 −5 src/julep/_constants.py
+3 −0 src/julep/_models.py
+10 −10 src/julep/_response.py
+2 −4 src/julep/_types.py
+1 −0 src/julep/_utils/__init__.py
+40 −50 src/julep/_utils/_sync.py
+5 −0 src/julep/_utils/_transform.py
+30 −1 src/julep/_utils/_typing.py
+1 −1 src/julep/_version.py
+1 −5 src/julep/lib/__init__.py
+14 −0 src/julep/resources/__init__.py
+348 −0 src/julep/resources/files.py
+16 −0 src/julep/resources/sessions.py
+2 −0 src/julep/types/__init__.py
+136 −20 src/julep/types/agents/tool_create_params.py
+135 −19 src/julep/types/agents/tool_list_response.py
+127 −11 src/julep/types/agents/tool_patch_params.py
+136 −20 src/julep/types/agents/tool_update_params.py
+90 −18 src/julep/types/chat_response.py
+360 −52 src/julep/types/entry.py
+26 −0 src/julep/types/file.py
+18 −0 src/julep/types/file_create_params.py
+45 −6 src/julep/types/message_param.py
+23 −1 src/julep/types/session.py
+135 −19 src/julep/types/session_chat_params.py
+47 −8 src/julep/types/session_chat_response.py
+23 −1 src/julep/types/session_create_or_update_params.py
+23 −1 src/julep/types/session_create_params.py
+23 −1 src/julep/types/session_patch_params.py
+23 −1 src/julep/types/session_update_params.py
+1,808 −316 src/julep/types/task.py
+3,024 −1,518 src/julep/types/task_create_or_update_params.py
+3,024 −1,518 src/julep/types/task_create_params.py
+20 −20 tests/api_resources/agents/test_docs.py
+263 −0 tests/api_resources/test_files.py
+106 −370 tests/api_resources/test_sessions.py
+26 −442 tests/api_resources/test_tasks.py
+20 −20 tests/api_resources/users/test_docs.py
+70 −32 tests/test_client.py
+25 −1 tests/test_models.py
+4 −0 tests/utils.py

0 comments on commit ad8dd18

Please sign in to comment.