Skip to content

FR - support attachments of PDF and Markdown#31

Open
sonofagl1tch wants to merge 1 commit intoibrahimcetin:mainfrom
sonofagl1tch:reins-accept-pdf-markdown-attachments
Open

FR - support attachments of PDF and Markdown#31
sonofagl1tch wants to merge 1 commit intoibrahimcetin:mainfrom
sonofagl1tch:reins-accept-pdf-markdown-attachments

Conversation

@sonofagl1tch
Copy link

Added support for attaching PDF and Markdown files to chat conversations, with automatic text extraction and content integration into prompts.

Feature: PDF and Markdown Document Support

Summary

Added support for attaching PDF and Markdown files to chat conversations, with automatic text extraction and content integration into prompts.

Motivation

Users needed the ability to share document content with their LLMs beyond just images. This feature enables document-based conversations, allowing users to ask questions about PDFs, analyze markdown files, and work with text documents directly in their chats.

Changes

New Features

  • Document Attachment: Users can now attach PDF, Markdown (.md, .markdown), and text files to messages
  • Automatic Text Extraction: Content is automatically extracted from documents and included in the chat context
  • File Type Support: PDF, Markdown, and plain text files up to 10MB
  • Mixed Attachments: Support for both images and documents in the same message
  • Visual Indicators: Document attachments display with appropriate file type icons (📄 for PDF, 📝 for Markdown)

Technical Implementation

  • Added file_picker and syncfusion_flutter_pdf dependencies
  • Created FileService for document handling and text extraction
  • Extended OllamaMessage model with documents field
  • Updated database schema (v2) with migration support for existing installations
  • Enhanced UI with document attachment widget and selection dialog
  • Integrated document content processing into chat provider

User Experience

  1. Tap the attachment button (+) in chat
  2. Select "Document" from the options menu
  3. Choose a PDF or Markdown file from device storage
  4. Document appears as an attachment with file name and icon
  5. Send message - document content is automatically extracted and included in the prompt
  6. LLM receives both the user's text and the document content

Files Changed

New:

  • lib/Services/file_service.dart
  • lib/Pages/chat_page/subwidgets/chat_attachment/chat_attachment_document.dart
  • test/file_service_test.dart

Modified:

  • pubspec.yaml - Dependencies
  • lib/Models/ollama_message.dart - Document field
  • lib/Providers/chat_provider.dart - Content processing
  • lib/Pages/chat_page/chat_page.dart - UI enhancements
  • lib/Services/database_service.dart - Schema migration
  • lib/main.dart - Provider setup

Backward Compatibility

  • Database migration ensures existing installations upgrade seamlessly
  • Existing chats and messages remain unaffected
  • No breaking changes to existing functionality

Limitations

  • Maximum file size: 10MB
  • Supported formats: PDF, Markdown (.md, .markdown), plain text (.txt)
  • Single document per message (can be extended in future)

Testing

  • Tested on iOS, Android, macOS, Linux, and Windows
  • Verified database migration from v1 to v2
  • Confirmed text extraction from various PDF and Markdown files
  • Validated file size limits and error handling

Future Enhancements

  • Support for multiple documents per message
  • Additional file formats (DOCX, RTF, etc.)
  • Document preview/viewer
  • File compression for large documents
  • Cloud storage integration

Fixes #30

…ons, with automatic text extraction and content integration into prompts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR - support attachments of PDF and Markdown

1 participant