feat(document-analysis): use separate APIs for document actions
Summary
- Refactored document action system to use dedicated API endpoints
- Document actions (compare, summarize, analyze) now call separate APIs instead of sending everything through the chat messages endpoint
- Frontend sends indexed document IDs, backend retrieves content from database
Changes
Store (document-analysis-store.ts)
- Added
DocumentActionRequestinterface - Added
compareIndexedDocuments()->POST /chat/actions/compare - Added
summarizeIndexedDocument()->POST /chat/actions/summarize - Added
analyzeIndexedDocument()->POST /chat/actions/analyze - Added
addLocalMessages()for displaying results in chat
Components
-
NewChatInterface.tsx: Modified
handleModalSubmitto call appropriate APIs -
view.tsx: Added
onActionResultcallback handling - DocumentActionModal.tsx: Fixed TypeScript type errors
Hook (use-document-analysis-chat.ts)
- Added
addActionMessages()function - Fixed Message type to include 'audio'
API Format
// POST /chat/actions/compare
{ "document_ids": ["uuid-1", "uuid-2"], "query": "..." }
// POST /chat/actions/summarize
{ "document_id": "uuid-1", "options": ["short"] }
// POST /chat/actions/analyze
{ "document_id": "uuid-1", "query": "..." }