forked from Rockachopa/Timmy-time-dashboard
feat: code quality audit + autoresearch integration + infra hardening (#150)
This commit is contained in:
committed by
GitHub
parent
fd0ede0d51
commit
ae3bb1cc21
@@ -27,12 +27,13 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["chat-api"])
|
||||
|
||||
_UPLOAD_DIR = os.path.join("data", "chat-uploads")
|
||||
_UPLOAD_DIR = str(Path(settings.repo_root) / "data" / "chat-uploads")
|
||||
_MAX_UPLOAD_SIZE = 50 * 1024 * 1024 # 50 MB
|
||||
|
||||
|
||||
# ── POST /api/chat ────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@router.post("/chat")
|
||||
async def api_chat(request: Request):
|
||||
"""Accept a JSON chat payload and return the agent's reply.
|
||||
@@ -65,7 +66,8 @@ async def api_chat(request: Request):
|
||||
# Handle multimodal content arrays — extract text parts
|
||||
if isinstance(content, list):
|
||||
text_parts = [
|
||||
p.get("text", "") for p in content
|
||||
p.get("text", "")
|
||||
for p in content
|
||||
if isinstance(p, dict) and p.get("type") == "text"
|
||||
]
|
||||
last_user_msg = " ".join(text_parts).strip()
|
||||
@@ -109,6 +111,7 @@ async def api_chat(request: Request):
|
||||
|
||||
# ── POST /api/upload ──────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@router.post("/upload")
|
||||
async def api_upload(file: UploadFile = File(...)):
|
||||
"""Accept a file upload and return its URL.
|
||||
@@ -147,6 +150,7 @@ async def api_upload(file: UploadFile = File(...)):
|
||||
|
||||
# ── GET /api/chat/history ────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@router.get("/chat/history")
|
||||
async def api_chat_history():
|
||||
"""Return the in-memory chat history as JSON."""
|
||||
@@ -165,6 +169,7 @@ async def api_chat_history():
|
||||
|
||||
# ── DELETE /api/chat/history ──────────────────────────────────────────────────
|
||||
|
||||
|
||||
@router.delete("/chat/history")
|
||||
async def api_clear_history():
|
||||
"""Clear the in-memory chat history."""
|
||||
|
||||
Reference in New Issue
Block a user