-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Diwank Singh Tomer <[email protected]>
- Loading branch information
Showing
22 changed files
with
267 additions
and
133 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
109 changes: 109 additions & 0 deletions
109
agents-api/migrations/migrate_1725323734_make_transition_output_optional.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,109 @@ | ||
# /usr/bin/env python3 | ||
|
||
MIGRATION_ID = "make_transition_output_optional" | ||
CREATED_AT = 1725323734.591567 | ||
|
||
|
||
def run(client, queries): | ||
joiner = "}\n\n{" | ||
|
||
query = joiner.join(queries) | ||
query = f"{{\n{query}\n}}" | ||
client.run(query) | ||
|
||
|
||
make_transition_output_optional_query = dict( | ||
up=""" | ||
?[ | ||
execution_id, | ||
transition_id, | ||
output, | ||
type, | ||
current, | ||
next, | ||
task_token, | ||
metadata, | ||
created_at, | ||
updated_at, | ||
] := | ||
*transitions { | ||
execution_id, | ||
transition_id, | ||
output, | ||
type, | ||
current, | ||
next, | ||
task_token, | ||
metadata, | ||
created_at, | ||
updated_at, | ||
} | ||
:replace transitions { | ||
execution_id: Uuid, | ||
transition_id: Uuid, | ||
=> | ||
type: String, | ||
current: (String, Int), | ||
next: (String, Int)?, | ||
output: Json?, # <--- this is the only change; output is now optional | ||
task_token: String? default null, | ||
metadata: Json default {}, | ||
created_at: Float default now(), | ||
updated_at: Float default now(), | ||
} | ||
""", | ||
down=""" | ||
?[ | ||
execution_id, | ||
transition_id, | ||
output, | ||
type, | ||
current, | ||
next, | ||
task_token, | ||
metadata, | ||
created_at, | ||
updated_at, | ||
] := | ||
*transitions { | ||
execution_id, | ||
transition_id, | ||
output, | ||
type, | ||
current, | ||
next, | ||
task_token, | ||
metadata, | ||
created_at, | ||
updated_at, | ||
} | ||
:replace transitions { | ||
execution_id: Uuid, | ||
transition_id: Uuid, | ||
=> | ||
type: String, | ||
current: (String, Int), | ||
next: (String, Int)?, | ||
output: Json, | ||
task_token: String? default null, | ||
metadata: Json default {}, | ||
created_at: Float default now(), | ||
updated_at: Float default now(), | ||
} | ||
""", | ||
) | ||
|
||
|
||
queries = [ | ||
make_transition_output_optional_query, | ||
] | ||
|
||
|
||
def up(client): | ||
run(client, [q["up"] for q in queries]) | ||
|
||
|
||
def down(client): | ||
run(client, [q["down"] for q in reversed(queries)]) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.