mirror of
https://github.com/JamesTheGiblet/BuddAI.git
synced 2026-01-08 21:58:40 +00:00
- Added `ModelFineTuner` class for preparing training data and fine-tuning models based on user corrections. - Introduced `CodeValidator` class to validate generated code against various hardware and style rules, including safety checks and function naming conventions. - Developed skills for calculator operations, system information retrieval, weather fetching, and timer functionality. - Implemented a self-diagnostic skill to run unit tests and report results. - Created a dynamic skill loading mechanism to discover and register skills from the current directory. - Added unit tests for skills to ensure functionality and reliability.
41 lines
No EOL
1.5 KiB
Python
41 lines
No EOL
1.5 KiB
Python
import importlib
|
|
import pkgutil
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
# Configure local logger
|
|
logger = logging.getLogger("BuddAI-Skills")
|
|
|
|
def load_registry():
|
|
"""
|
|
Dynamically discovers and loads skill modules from the current directory.
|
|
Returns a dictionary mapping skill IDs to their executable functions and metadata.
|
|
"""
|
|
registry = {}
|
|
package_dir = Path(__file__).parent
|
|
|
|
# Iterate over all .py files in this directory
|
|
for _, name, _ in pkgutil.iter_modules([str(package_dir)]):
|
|
try:
|
|
# Import the module relative to this package
|
|
module = importlib.import_module(f".{name}", __package__)
|
|
|
|
# Verify the Skill Interface (must have 'meta' and 'run')
|
|
if hasattr(module, "meta") and hasattr(module, "run"):
|
|
metadata = module.meta()
|
|
skill_id = name
|
|
|
|
registry[skill_id] = {
|
|
"name": metadata.get("name", skill_id),
|
|
"triggers": metadata.get("triggers", []),
|
|
"description": metadata.get("description", "No description provided."),
|
|
"run": module.run
|
|
}
|
|
logger.info(f"🧩 Skill Loaded: {metadata.get('name')} [{skill_id}]")
|
|
else:
|
|
logger.debug(f"Skipping {name}: Does not implement Skill Interface.")
|
|
|
|
except Exception as e:
|
|
logger.error(f"❌ Error loading skill '{name}': {e}")
|
|
|
|
return registry |