How ddmpriza/ai-document-assistant works
AI Document Assistant accepts PDF uploads and document questions through a Streamlit interface backed by a FastAPI service. The API extracts page text, chunks it, embeds the chunks, persists document content in SQLite, and builds an in-memory FAISS index. For questions, it embeds the query, searches the index, and passes retrieved context to a configured LLM provider; answers include source references, or a fallback when no relevant chunks are found. The README documents persistence and provider options; links among components are limited to shown calls or documented behavior.
Main entry points: main.py REST API · factory.py LLM selection · ollama_provider.py Ollama answers · openai_provider.py OpenAI answers
Components 21
User interface
- Streamlit UI
ui/streamlit_app.py
API orchestration
- REST API
app/main.py - API schemas
app/schemas.py - Domain models
app/models.py
Document and retrieval
- PDF extraction
app/services/pdf_parser.py - Text chunking
app/services/text_chunker.py - Document persistence
app/services/document_store.py - FAISS index
app/services/faiss_vector_store.py - In-memory vector store
app/services/in_memory_vector_store.py - Cosine retrieval
app/services/retrieval.py
Model providers
- Embedding selection
app/providers/embeddings/factory.py - Embedding interface
app/providers/embeddings/base.py - Ollama embeddings
app/providers/embeddings/ollama_provider.py - LLM selection
app/providers/factory.py - LLM interface
app/providers/base.py - Ollama answers
app/providers/ollama_provider.py - OpenAI answers
app/providers/openai_provider.py - Mock answers
app/providers/mock_provider.py
Other components
- Document user
- Ollama service
- OpenAI service
Connections 21
- Document user → Streamlit UI: uses
README.md - Streamlit UI → REST API: sends requests
README.md - REST API → API schemas: validates and responds
app/main.py - REST API → PDF extraction: extracts pages
app/main.py - REST API → Text chunking: creates chunks
app/main.py - REST API → Embedding selection: selects embeddings
app/main.py - Embedding selection → Ollama embeddings: creates
app/providers/embeddings/factory.py - Ollama embeddings → Embedding interface: implements
app/providers/embeddings/ollama_provider.py - REST API → Document persistence: stores and loads
app/main.py - Document persistence → Domain models: builds records
app/services/document_store.py - REST API → FAISS index: indexes and searches
app/main.py - REST API → LLM selection: selects provider
app/main.py - LLM selection → Ollama answers: creates
app/providers/factory.py - LLM selection → OpenAI answers: creates
app/providers/factory.py - LLM selection → Mock answers: creates
app/providers/factory.py - Ollama answers → LLM interface: implements
app/providers/ollama_provider.py - OpenAI answers → LLM interface: implements
app/providers/openai_provider.py - Mock answers → LLM interface: implements
app/providers/mock_provider.py - Ollama answers → Ollama service: calls
app/providers/ollama_provider.py - OpenAI answers → OpenAI service: calls
app/providers/openai_provider.py - REST API → Domain models: builds context
app/main.py