refactor: improve run-agent/run-agent scripts (#160)
This commit is contained in:
+5
-8
@@ -89,14 +89,11 @@ def load_env(file_path):
|
||||
|
||||
|
||||
def run(tool_name, tool_path, tool_func, tool_data):
|
||||
try:
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
os.path.basename(tool_path), tool_path
|
||||
)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
except:
|
||||
raise Exception(f"Unable to load tool at '{tool_path}'")
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
os.path.basename(tool_path), tool_path
|
||||
)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
|
||||
if not hasattr(mod, tool_func):
|
||||
raise Exception(f"Not module function '{tool_func}' at '{tool_path}'")
|
||||
|
||||
Reference in New Issue
Block a user