demeter

Autonomous Hydroponic Intelligence

agent/sub_agents/test_pipeline.py (1434B)


 1import sys
 2import os
 3# --- PATH FIX: Add project root to system path ---
 4# This ensures Python can see 'agent', 'Qdrant', 'Sentinel' from anywhere
 5current_dir = os.path.dirname(os.path.abspath(__file__))
 6project_root = os.path.abspath(os.path.join(current_dir, '../../'))
 7sys.path.append(project_root)
 8# -------------------------------------------------
 9
10from agent.sub_agents.Researcher import ResearcherAgent
11from agent.sub_agents.Supervisor import SupervisorAgent
12
13# 1. Setup Agents
14print("🌱 Waking up Agents...")
15researcher = ResearcherAgent()
16supervisor = SupervisorAgent(researcher)
17
18# 2. Seed some dummy knowledge (Run this once)
19print("📚 Ingesting Knowledge...")
20researcher.ingest_text(
21    "Lettuce in vegetative stage requires pH between 5.5 and 6.5. "
22    "Yellowing leaves often indicate Nitrogen deficiency or low pH lockout."
23)
24
25# 3. Mock Data (Simulate what the Backend would send)
26mock_fmu = {
27    "metadata": {"crop": "Lettuce", "stage": "Vegetative"},
28    "payload": {"sensors": {"pH": 4.2, "EC": 1.2}}
29}
30mock_similar_fmus = [
31    {"score": 0.88, "payload": {"outcome": "Recovered after adding pH Up"}}
32]
33mock_sub_agents = {
34    "nutrient_analysis": "Critical Low pH detected.",
35    "resource_status": "Water tank at 15%."
36}
37
38# 4. Run Reasoning
39print("🧠 Supervisor is thinking...")
40decision = supervisor.reason(mock_fmu, mock_similar_fmus, mock_sub_agents)
41
42print("\n=== FINAL DECISION ===")
43print(decision)