-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.py
More file actions
21 lines (19 loc) · 849 Bytes
/
query.py
File metadata and controls
21 lines (19 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from fastapi import APIRouter
from datetime import datetime
from ..schemas.schemas import AIQueryRequest, AIQueryResponse
from ai_module.analyzer import SecurityAnalyzer
router = APIRouter()
analyzer = SecurityAnalyzer()
@router.post("/", response_model=AIQueryResponse)
def query_ai(request: AIQueryRequest):
"""AI query endpoint using the advanced SecurityAnalyzer logic."""
res = analyzer.query_response(request.query_text)
# Map SecurityAnalyzer response to AIQueryResponse schema if necessary
# For now, we'll return a structured response as defined in schemas
return AIQueryResponse(
id=1,
query_text=request.query_text,
ai_response=res["summary"],
sources=res["source_attribution"], # Note: schema says List[str], res has List[Dict]. Need to align.
timestamp=datetime.now()
)