fix: wire image uploads into correct chat endpoint (unified_chat_service)

The frontend calls /ai-sessions/{id}/chat (unified_chat_service), not
/assistant/chats/{id}/messages (assistant_chat_service). The previous
commit wired images into the wrong backend. This fixes it:

- ai_session.py schema: add upload_ids to ChatMessageRequest
- ai_sessions.py endpoint: fetch images via _fetch_upload_images
- unified_chat_service: accept and forward images to _call_ai

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-24 05:02:34 +00:00
parent 1c0f912cf6
commit 36ca830481
3 changed files with 14 additions and 0 deletions

View File

@@ -280,6 +280,12 @@ async def send_chat_message(
user_id = current_user.id
account_id = current_user.account_id
# Fetch attached images from S3 (if any)
images = None
if data.upload_ids:
from app.api.endpoints.assistant_chat import _fetch_upload_images
images = await _fetch_upload_images(data.upload_ids, account_id, db) or None
try:
ai_content, suggested_flows, session = await unified_chat_service.send_chat_message(
session_id=session_id,
@@ -287,6 +293,7 @@ async def send_chat_message(
account_id=account_id,
message=data.message,
db=db,
images=images,
)
except ValueError as e:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))