-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agents-api): Transitions stream SSE endpoint
Signed-off-by: Diwank Singh Tomer <[email protected]>
- Loading branch information
Showing
11 changed files
with
175 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
agents-api/agents_api/models/execution/lookup_temporal_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Any, TypeVar | ||
from uuid import UUID | ||
|
||
from beartype import beartype | ||
from fastapi import HTTPException | ||
from pycozo.client import QueryException | ||
from pydantic import ValidationError | ||
|
||
from ..utils import ( | ||
cozo_query, | ||
partialclass, | ||
rewrap_exceptions, | ||
verify_developer_id_query, | ||
verify_developer_owns_resource_query, | ||
wrap_in_class, | ||
) | ||
|
||
ModelT = TypeVar("ModelT", bound=Any) | ||
T = TypeVar("T") | ||
|
||
|
||
@rewrap_exceptions( | ||
{ | ||
QueryException: partialclass(HTTPException, status_code=400), | ||
ValidationError: partialclass(HTTPException, status_code=400), | ||
TypeError: partialclass(HTTPException, status_code=400), | ||
} | ||
) | ||
@wrap_in_class(dict, one=True) | ||
@cozo_query | ||
@beartype | ||
def lookup_temporal_data( | ||
*, | ||
developer_id: UUID, | ||
execution_id: UUID, | ||
) -> tuple[list[str], dict]: | ||
developer_id = str(developer_id) | ||
execution_id = str(execution_id) | ||
|
||
temporal_query = """ | ||
?[id] := | ||
execution_id = to_uuid($execution_id), | ||
*temporal_executions_lookup { | ||
id, execution_id, run_id, first_execution_run_id, result_run_id | ||
} | ||
""" | ||
|
||
queries = [ | ||
verify_developer_id_query(developer_id), | ||
verify_developer_owns_resource_query( | ||
developer_id, | ||
"executions", | ||
execution_id=execution_id, | ||
parents=[("agents", "agent_id"), ("tasks", "task_id")], | ||
), | ||
temporal_query, | ||
] | ||
|
||
return ( | ||
queries, | ||
{ | ||
"execution_id": str(execution_id), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||