Skip to content

Commit

Permalink
Bug fixes in base_evaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
HamadaSalhab committed Oct 5, 2024
1 parent 2e0108e commit 34fc2e5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions agents-api/agents_api/activities/task_steps/base_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ async def base_evaluate(
evaluator = get_evaluator(names=values, extra_functions=extra_lambdas)

try:
result = None
match exprs:
case str():
return evaluator.eval(exprs)

result = evaluator.eval(exprs)
case list():
return [evaluator.eval(expr) for expr in exprs]

case dict() as d if all(isinstance(v, dict) for v in d.values()):
return {
result = [evaluator.eval(expr) for expr in exprs]
case dict() as d if all(
isinstance(v, dict) or isinstance(v, str) for v in d.values()
):
result = {
k: {ik: evaluator.eval(iv) for ik, iv in v.items()}
if isinstance(v, dict)
else evaluator.eval(v)
for k, v in d.items()
}

case dict():
return {k: evaluator.eval(v) for k, v in exprs.items()}

case _:
raise ValueError(f"Invalid expression: {exprs}")

return result

except BaseException as e:
if activity.in_activity():
activity.logger.error(f"Error in base_evaluate: {e}")

raise


Expand Down

0 comments on commit 34fc2e5

Please sign in to comment.