How vaibhavdhingani/genai_personal_legal_assistant_deepkeekr1_ollama_faiss works
Project type and purpose
• This is a full‑stack Python application providing a Generative AI–powered legal assistant.
• Key features:
• Document ingestion into a vector database (FAISS)
• Retrieval‑augmented generation using DeepSeek R1 and Ollama
• A simple web UI built with Streamlit (or Gradio)
• External API integrations (GROQ, ElevenLabs)
File structure
• No explicit frontend/backend folders; the codebase is a single Python package.
• Core modules:
• GenAILawyerUI.py – the Streamlit/Gradio UI entry point
• learnDocument_vector_database.py – document ingestion & FAISS setup
• laywerResponse_rag_pipeline.py – RAG orchestration (retrieval + LLM call)
• prompt.py – prompt templates and formatting logic
• Configuration:
• .env file (GROQ_API_KEY)
• requirements.txt (Python dependencies)
Extract insights from the README
• UI screenshots show two main flows: Document Review & Legal Analysis.
• Stack: DeepSeek R1, Ollama, FAISS, GROQ, Streamlit
• Run command discrepancy (“gradio_app.py” vs. GenAILawyerUI.py) implies the UI script
handles both Gradio and Streamlit under the same module.
Main components
a. UI Layer
• Streamlit (GenAILawyerUI.py)
• User flows:
• Upload documents
• Enter legal queries
b. Ingestion Layer
• learnDocument_vector_database.py
• FAISS vector store
• Storage of document embeddings
c. Retrieval & Generation Layer
• laywerResponse_rag_pipeline.py
• prompt.py for template management
• RAG flow: query → retrieve top‑k vectors → build prompt → call LLM
d. External Services
• DeepSeek R1 (local or remote model)
• Ollama (local LLM runtime)
• GROQ API (for embeddings or scoring)
• ElevenLabs (optional TTS if used)
e. Configuration & Secrets
• .env (GROQ_API_KEY)
Relationships and data flows
1. User uploads document → UI
2. UI invokes ingestion module → embeddings via FAISS & GROQ
3. User submits query → UI calls RAG pipeline
4. RAG pipeline retrieves similar embeddings from FAISS
5. Retrieved chunks + user query → prompt.py assembles prompt
6. Prompt sent to DeepSeek R1 or Ollama → model generates answer
7. Answer returned to UI → displayed to user
8. (Optional) Answer sent to ElevenLabs for TTS
Architectural patterns & principles
• Separation of concerns: UI vs. ingestion vs. retrieval/generation
• Modular design: each Python script encapsulates one responsibility
• Externalize configuration (.env)
• RAG pattern for combining vector retrieval with LLM inference