-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #485 from julep-ai/f/transition-stream
- Loading branch information
Showing
31 changed files
with
567 additions
and
231 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
30 changes: 0 additions & 30 deletions
30
agents-api/agents_api/activities/task_steps/prompt_step.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
37 changes: 37 additions & 0 deletions
37
agents-api/agents_api/activities/task_steps/set_value_step.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,37 @@ | ||
from typing import Any | ||
|
||
from beartype import beartype | ||
from temporalio import activity | ||
|
||
from ...activities.utils import simple_eval_dict | ||
from ...common.protocol.tasks import StepContext, StepOutcome | ||
from ...env import testing | ||
|
||
|
||
@beartype | ||
async def set_value_step( | ||
context: StepContext, | ||
additional_values: dict[str, Any] = {}, | ||
override_expr: dict[str, str] | None = None, | ||
) -> StepOutcome: | ||
try: | ||
expr = override_expr if override_expr is not None else context.current_step.set | ||
|
||
values = context.model_dump() | additional_values | ||
output = simple_eval_dict(expr, values) | ||
result = StepOutcome(output=output) | ||
|
||
return result | ||
|
||
except BaseException as e: | ||
activity.logger.error(f"Error in set_value_step: {e}") | ||
return StepOutcome(error=str(e) or repr(e)) | ||
|
||
|
||
# Note: This is here just for clarity. We could have just imported set_value_step directly | ||
# They do the same thing, so we dont need to mock the set_value_step function | ||
mock_set_value_step = set_value_step | ||
|
||
set_value_step = activity.defn(name="set_value_step")( | ||
set_value_step if not testing else mock_set_value_step | ||
) |
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
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
Oops, something went wrong.