MCPcopy
hub / github.com/huggingface/smolagents / evaluate_while

Function evaluate_while

src/smolagents/local_python_executor.py:440–459  ·  view source on GitHub ↗
(
    while_loop: ast.While,
    state: dict[str, Any],
    static_tools: dict[str, Callable],
    custom_tools: dict[str, Callable],
    authorized_imports: list[str],
)

Source from the content-addressed store, hash-verified

438
439
440def evaluate_while(
441 while_loop: ast.While,
442 state: dict[str, Any],
443 static_tools: dict[str, Callable],
444 custom_tools: dict[str, Callable],
445 authorized_imports: list[str],
446) -> None:
447 iterations = 0
448 while evaluate_ast(while_loop.test, state, static_tools, custom_tools, authorized_imports):
449 for node in while_loop.body:
450 try:
451 evaluate_ast(node, state, static_tools, custom_tools, authorized_imports)
452 except BreakException:
453 return None
454 except ContinueException:
455 break
456 iterations += 1
457 if iterations > MAX_WHILE_ITERATIONS:
458 raise InterpreterError(f"Maximum number of {MAX_WHILE_ITERATIONS} iterations in While loop exceeded")
459 return None
460
461
462def create_function(

Callers 1

evaluate_astFunction · 0.85

Calls 2

evaluate_astFunction · 0.85
InterpreterErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…