MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / function_or_method_to_string

Function function_or_method_to_string

autoagent/flow/utils.py:31–44  ·  view source on GitHub ↗
(func_or_method: Callable)

Source from the content-addressed store, hash-verified

29
30
31def function_or_method_to_string(func_or_method: Callable) -> str:
32 is_method = inspect.ismethod(func_or_method)
33 is_function = inspect.isfunction(func_or_method)
34 if not is_method and not is_function:
35 raise ValueError("Input must be a function or method")
36 module = func_or_method.__module__
37 source = inspect.getsource(func_or_method)
38 line_number = inspect.getsourcelines(func_or_method)[1]
39
40 if is_method:
41 class_name = func_or_method.__self__.__class__.__name__
42 return f"{module}.l_{line_number}.{class_name}\n{source}".strip()
43 else:
44 return f"{module}.l_{line_number}\n{source}".strip()
45
46
47def string_to_md5_hash(string: str) -> str:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected