Update fusion_engine.py
Browse files- fusion_engine.py +29 -1
fusion_engine.py
CHANGED
|
@@ -28,6 +28,7 @@ from dotenv import load_dotenv
|
|
| 28 |
from session_manager import session_manager
|
| 29 |
from orchestrator import orchestrator
|
| 30 |
from mission_engine import buffer_manager, mission_evaluator, ObservationEvent
|
|
|
|
| 31 |
|
| 32 |
# ── Paths ──
|
| 33 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -767,7 +768,34 @@ async def analyze_multimodal(
|
|
| 767 |
else:
|
| 768 |
break
|
| 769 |
|
| 770 |
-
# ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
# situational_report is now sourced directly from the refined phased result
|
| 772 |
situational_report = phased_result.get("fusion_caption") or "Analysis complete."
|
| 773 |
|
|
|
|
| 28 |
from session_manager import session_manager
|
| 29 |
from orchestrator import orchestrator
|
| 30 |
from mission_engine import buffer_manager, mission_evaluator, ObservationEvent
|
| 31 |
+
from tactical_specialists import tactical_specialists
|
| 32 |
|
| 33 |
# ── Paths ──
|
| 34 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 768 |
else:
|
| 769 |
break
|
| 770 |
|
| 771 |
+
# --- TACTICAL TOOLS ENDPOINTS ---
|
| 772 |
+
|
| 773 |
+
class IdentifyRequest(BaseModel):
|
| 774 |
+
session_id: str
|
| 775 |
+
image_b64: str # The cropped image in base64
|
| 776 |
+
|
| 777 |
+
@app.post("/api/tools/identify")
|
| 778 |
+
async def identify_target(req: IdentifyRequest):
|
| 779 |
+
"""Manual identification tool for user-provided crops."""
|
| 780 |
+
try:
|
| 781 |
+
# 1. Decode base64 to PIL
|
| 782 |
+
header, encoded = req.image_b64.split(",", 1) if "," in req.image_b64 else (None, req.image_b64)
|
| 783 |
+
image_data = base64.b64decode(encoded)
|
| 784 |
+
image = Image.open(io.BytesIO(image_data)).convert("RGB")
|
| 785 |
+
|
| 786 |
+
# 2. Process with Florence-2 (Tactical Specialist)
|
| 787 |
+
identification = tactical_specialists.identify_region(image)
|
| 788 |
+
|
| 789 |
+
return {
|
| 790 |
+
"status": "success",
|
| 791 |
+
"identification": identification,
|
| 792 |
+
"timestamp": time.time()
|
| 793 |
+
}
|
| 794 |
+
except Exception as e:
|
| 795 |
+
logger.error(f"[API] Identification tool error: {e}")
|
| 796 |
+
return {"status": "error", "message": str(e)}
|
| 797 |
+
|
| 798 |
+
# --- CORE ROUTES ---
|
| 799 |
# situational_report is now sourced directly from the refined phased result
|
| 800 |
situational_report = phased_result.get("fusion_caption") or "Analysis complete."
|
| 801 |
|