Add logging to GitHubTool for function loading and initialization
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class GitHubTool:
|
||||
def __init__(self):
|
||||
@@ -10,12 +14,15 @@ class GitHubTool:
|
||||
|
||||
self.instances = {}
|
||||
self.functions = []
|
||||
logger.debug(f"Initialized GitHubTool with repo: {self.repo}")
|
||||
self._load_functions()
|
||||
|
||||
def _load_functions(self):
|
||||
logger.debug("Starting to load functions")
|
||||
function_dir = os.path.join(os.path.dirname(__file__), "github_tool_functions")
|
||||
for filename in os.listdir(function_dir):
|
||||
if filename.endswith(".py") and filename != "__init__.py":
|
||||
logger.debug(f"Processing file: {filename}")
|
||||
function_name = filename[:-3]
|
||||
module = __import__(f"tools.github_tool_functions.{function_name}", fromlist=[function_name.capitalize()])
|
||||
class_name = getattr(module, function_name.capitalize())
|
||||
@@ -28,6 +35,8 @@ class GitHubTool:
|
||||
if json_start != -1 and json_end != -1:
|
||||
json_def = json.loads(content[json_start:json_end])
|
||||
self.functions.append(json_def)
|
||||
logger.debug(f"Loaded function: {json_def['name']}")
|
||||
logger.debug(f"Loaded {len(self.functions)} functions")
|
||||
|
||||
def execute(self, function_name, **kwargs):
|
||||
if function_name in self.instances:
|
||||
|
||||
Reference in New Issue
Block a user