| """OSINT routes — reverse image search orchestration.""" | |
| from __future__ import annotations | |
| from typing import List, Optional | |
| from fastapi import APIRouter, Depends | |
| from pydantic import BaseModel | |
| from api.deps import get_osint_service | |
| from models.jobs import JobRequest | |
| from services.osint_service import OSINTService | |
| router = APIRouter() | |
| class OSINTRequest(BaseModel): | |
| image_url: Optional[str] = None | |
| image_base64: Optional[str] = None | |
| providers: List[str] = [] | |
| async def reverse_search(req: OSINTRequest, | |
| svc: OSINTService = Depends(get_osint_service)): | |
| """Run reverse-image-search across all enabled providers + merge results. | |
| Returns a unified OSINTResult with: | |
| - deduplicated matches | |
| - source classification (social/news/forum/marketplace/etc.) | |
| - confidence scores | |
| - source-type breakdown | |
| """ | |
| job_req = JobRequest( | |
| kind=None, # OSINT is not a JobKind — it's a service-level orchestration | |
| image_url=req.image_url, | |
| image_base64=req.image_base64, | |
| providers=req.providers, | |
| ) | |
| # Bypass the kind check — OSINTService doesn't use JobKind | |
| return await svc.reverse_search(job_req) | |