refactor: improve run-agent/run-agent scripts (#160)

This commit is contained in:
sigoden
2025-02-10 14:47:37 +08:00
committed by GitHub
parent e4f85a056c
commit fad2c60605
4 changed files with 12 additions and 28 deletions
+5 -8
View File
@@ -94,14 +94,11 @@ def load_env(file_path):
def run(agent_name, agent_path, agent_func, agent_data):
try:
spec = importlib.util.spec_from_file_location(
os.path.basename(agent_path), agent_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
except:
raise Exception(f"Unable to load agent tools at '{agent_path}'")
spec = importlib.util.spec_from_file_location(
os.path.basename(agent_path), agent_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
if not hasattr(mod, agent_func):
raise Exception(f"Not module function '{agent_func}' at '{agent_path}'")