From 54e04a0d16ba89a22d9b2d81afd616be866f2724 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Sat, 19 Oct 2024 00:19:23 -0400 Subject: [PATCH] feat(agents-api): Misc fixes in agents-api Signed-off-by: Diwank Singh Tomer --- agents-api/agents_api/activities/task_steps/log_step.py | 4 +++- agents-api/agents_api/activities/utils.py | 7 ++++++- agents-api/agents_api/common/interceptors.py | 2 ++ agents-api/agents_api/common/utils/template.py | 2 +- agents-api/tests/fixtures.py | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/agents-api/agents_api/activities/task_steps/log_step.py b/agents-api/agents_api/activities/task_steps/log_step.py index b57c624b5..80a61089f 100644 --- a/agents-api/agents_api/activities/task_steps/log_step.py +++ b/agents-api/agents_api/activities/task_steps/log_step.py @@ -21,7 +21,9 @@ async def log_step(context: StepContext) -> StepOutcome: template: str = context.current_step.log output = await render_template( - template, context.model_dump(), skip_vars=["developer_id"] + template, + context.model_dump(include_remote=True), + skip_vars=["developer_id"], ) result = StepOutcome(output=output) diff --git a/agents-api/agents_api/activities/utils.py b/agents-api/agents_api/activities/utils.py index 1fcc6266c..45a264437 100644 --- a/agents-api/agents_api/activities/utils.py +++ b/agents-api/agents_api/activities/utils.py @@ -201,13 +201,18 @@ class stdlib_statistics: "statistics": stdlib_statistics, } +constants = { + "NEWLINE": "\n", +} + @beartype def get_evaluator( names: dict[str, Any], extra_functions: dict[str, Callable] | None = None ) -> SimpleEval: evaluator = EvalWithCompoundTypes( - names=names | stdlib, functions=ALLOWED_FUNCTIONS | (extra_functions or {}) + names=names | stdlib | constants, + functions=ALLOWED_FUNCTIONS | (extra_functions or {}), ) return evaluator diff --git a/agents-api/agents_api/common/interceptors.py b/agents-api/agents_api/common/interceptors.py index f7e062d3f..408005da5 100644 --- a/agents-api/agents_api/common/interceptors.py +++ b/agents-api/agents_api/common/interceptors.py @@ -46,6 +46,7 @@ async def execute_activity(self, input: ExecuteActivityInput): CompleteAsyncError, TemporalError, FailureError, + ApplicationError, ): raise except BaseException as e: @@ -78,6 +79,7 @@ async def execute_workflow(self, input: ExecuteWorkflowInput): CompleteAsyncError, TemporalError, FailureError, + ApplicationError, ): raise except BaseException as e: diff --git a/agents-api/agents_api/common/utils/template.py b/agents-api/agents_api/common/utils/template.py index 2f614fb4f..5a39f6304 100644 --- a/agents-api/agents_api/common/utils/template.py +++ b/agents-api/agents_api/common/utils/template.py @@ -37,7 +37,7 @@ jinja_env.globals["true"] = True jinja_env.globals["false"] = False jinja_env.globals["null"] = None - +jinja_env.globals["NEWLINE"] = "\n" simple_jinja_regex = re.compile(r"{{|{%.+}}|%}", re.DOTALL) diff --git a/agents-api/tests/fixtures.py b/agents-api/tests/fixtures.py index 2a12a43c0..c4856112f 100644 --- a/agents-api/tests/fixtures.py +++ b/agents-api/tests/fixtures.py @@ -178,7 +178,7 @@ def test_doc( client=client, ) - time.sleep(0.1) + time.sleep(0.5) yield doc