Agent¶
Компоненты для построения автономных AI-агентов.
Модули¶
| Модуль | Описание |
|---|---|
| Base Agent | Базовый класс агента и EventBus |
| Decision Engine | Адаптивный выбор и скоринг |
| Watcher | Система мониторинга с сенсорами |
Архитектура¶
┌─────────────────────────────────────────────┐
│ Agent │
│ ┌─────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Sensors │→ │ Decision │→ │ Actions │ │
│ │(Watcher)│ │ Engine │ │ │ │
│ └─────────┘ └──────────┘ └─────────────┘ │
│ ↑ │ │
│ └────────── EventBus ────────┘ │
└─────────────────────────────────────────────┘
Быстрый пример¶
from kit.agent import BaseAgent, EventBus
from kit.agent.decision import DecisionEngine, Candidate
from kit.agent.watcher import Watcher, Sensor
# Event-driven коммуникация
bus = EventBus()
@bus.on("alert")
async def handle_alert(data):
print(f"Alert: {data}")
await bus.emit("alert", {"level": "warning", "message": "CPU high"})
# Decision making
engine = DecisionEngine(min_quality_threshold=0.3)
candidates = [
Candidate(id="option_a", score=0.8),
Candidate(id="option_b", score=0.6),
Candidate(id="option_c", score=0.4),
]
selected = engine.select(candidates)
print(f"Selected: {selected[0].candidate.id}") # option_a
# Monitoring
watcher = Watcher()
watcher.add_sensor(CPUSensor())
watcher.add_sensor(MemorySensor())
await watcher.start()