Initial commit: Ajarbot with optimizations
Features: - Multi-platform bot (Slack, Telegram) - Memory system with SQLite FTS - Tool use capabilities (file ops, commands) - Scheduled tasks system - Dynamic model switching (/sonnet, /haiku) - Prompt caching for cost optimization Optimizations: - Default to Haiku 4.5 (12x cheaper) - Reduced context: 3 messages, 2 memory results - Optimized SOUL.md (48% smaller) - Automatic caching when using Sonnet (90% savings) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
85
example_custom_pulse.py
Normal file
85
example_custom_pulse.py
Normal file
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
Example: Pulse & Brain with ONLY YOUR chosen checks.
|
||||
|
||||
By default, pulse_brain.py includes example checks.
|
||||
This shows how to start with a CLEAN SLATE and only add what YOU want.
|
||||
"""
|
||||
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from agent import Agent
|
||||
from pulse_brain import BrainTask, CheckType, PulseCheck, PulseBrain
|
||||
|
||||
|
||||
def check_my_file() -> dict:
|
||||
"""Check if the important data file exists."""
|
||||
file = Path("important_data.json")
|
||||
return {
|
||||
"status": "ok" if file.exists() else "error",
|
||||
"message": f"File exists: {file.exists()}",
|
||||
}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
agent = Agent(provider="claude", enable_heartbeat=False)
|
||||
|
||||
# Create Pulse & Brain with NO automatic checks
|
||||
pb = PulseBrain(agent, pulse_interval=60)
|
||||
|
||||
# Remove all default checks (start clean)
|
||||
pb.pulse_checks = []
|
||||
pb.brain_tasks = []
|
||||
|
||||
print(
|
||||
"Starting with ZERO checks. "
|
||||
"You have complete control.\n"
|
||||
)
|
||||
|
||||
# Add ONLY the checks you want
|
||||
pb.pulse_checks.append(
|
||||
PulseCheck(
|
||||
"my-file", check_my_file,
|
||||
interval_seconds=300,
|
||||
),
|
||||
)
|
||||
|
||||
pb.brain_tasks.append(
|
||||
BrainTask(
|
||||
name="file-recovery",
|
||||
check_type=CheckType.CONDITIONAL,
|
||||
prompt_template=(
|
||||
"The file important_data.json is missing. "
|
||||
"What should I do to recover it?"
|
||||
),
|
||||
condition_func=lambda data: (
|
||||
data.get("status") == "error"
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
print("Added 1 pulse check: my-file")
|
||||
print("Added 1 brain task: file-recovery")
|
||||
print("\nThe agent will ONLY:")
|
||||
print(
|
||||
" 1. Check if important_data.json exists "
|
||||
"(every 5 min, zero cost)"
|
||||
)
|
||||
print(
|
||||
" 2. Ask for recovery help IF it's missing "
|
||||
"(costs tokens)"
|
||||
)
|
||||
print("\nNothing else. You have complete control.\n")
|
||||
|
||||
pb.start()
|
||||
|
||||
try:
|
||||
print("Running... Press Ctrl+C to stop\n")
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
pb.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user