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.
44 lines
No EOL
1.2 KiB
Python
44 lines
No EOL
1.2 KiB
Python
import time
|
|
import re
|
|
import threading
|
|
|
|
def meta():
|
|
"""
|
|
Metadata for the Timer skill.
|
|
"""
|
|
return {
|
|
"name": "Timer",
|
|
"description": "Sets a non-blocking timer (background thread).",
|
|
"triggers": ["timer", "sleep", "wait for"]
|
|
}
|
|
|
|
def run(payload):
|
|
"""
|
|
Executes the blocking sleep.
|
|
"""
|
|
prompt = payload if isinstance(payload, str) else payload.get("prompt", "")
|
|
|
|
# Regex to capture number and optional unit (e.g., "5", "5s", "5 minutes")
|
|
match = re.search(r'(\d+)\s*(seconds?|secs?|s|minutes?|mins?|m)?', prompt.lower())
|
|
|
|
if not match:
|
|
return None # Fallback to LLM if no time found
|
|
|
|
amount = int(match.group(1))
|
|
unit = match.group(2)
|
|
|
|
duration = amount
|
|
if unit and unit.startswith('m'):
|
|
duration *= 60
|
|
|
|
if duration > 3600:
|
|
return f"❌ Timer too long ({duration}s). Max 1 hour."
|
|
|
|
def _timer_thread():
|
|
time.sleep(duration)
|
|
print(f"\n\n⏰ 🔔 BEEP! Timer finished ({duration}s).\n")
|
|
|
|
t = threading.Thread(target=_timer_thread, daemon=True)
|
|
t.start()
|
|
|
|
return f"⏰ Timer started for {duration} seconds (running in background)..." |