MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / func_string_to_callable

Function func_string_to_callable

camel/utils/commons.py:385–398  ·  view source on GitHub ↗

r"""Convert a function code string to a callable function object. Args: code (str): The function code as a string. Returns: Callable[..., Any]: The callable function object extracted from the code string.

(code: str)

Source from the content-addressed store, hash-verified

383
384
385def func_string_to_callable(code: str):
386 r"""Convert a function code string to a callable function object.
387
388 Args:
389 code (str): The function code as a string.
390
391 Returns:
392 Callable[..., Any]: The callable function object extracted from the
393 code string.
394 """
395 local_vars: Mapping[str, object] = {}
396 exec(code, globals(), local_vars)
397 func = local_vars.get(Constants.FUNC_NAME_FOR_STRUCTURED_OUTPUT)
398 return func
399
400
401def json_to_function_code(json_obj: Dict) -> str:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected