Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Company Brain

Fully local, offline RAG-powered knowledge assistant with role-based access control (RBAC), CEO Strategic Advisor, and Provable Local Gemma Telemetry.

Chat with all internal company documents through a locally-hosted Gemma model. Sensitive information stays strictly restricted by seniority. Zero cloud calls — everything runs on localhost via Ollama.


⚡ Quick Start (3 steps)

1. Install Ollama & Pull Models

Download and install Ollama from ollama.com, then pull the required models:

ollama pull gemma2:6b
ollama pull nomic-embed-text

(The app features dynamic model discovery — you can run gemma2:6b, gemma2, llama3.2:1b, etc.) (The app will automatically pull gemma2:6b on first startup if not available)

Make sure Ollama is running (ollama serve).

2. Install Python Dependencies

pip install -r requirements.txt

3. Ingest Documents & Launch

# Index company documents into persistent ChromaDB
python ingest.py

# Launch the Streamlit application
streamlit run app.py

Open http://localhost:8501 in your browser.


🏆 "Best Use of Gemma" — 5 Provable Local Features

To make the "why Gemma, running locally" architectural choice visible and provable on stage to hackathon judges:

  1. ✈️ Airplane Mode Proof: Click "✈️ Disconnect Network (Live Demo)" in the sidebar. Outbound TCP/HTTP traffic is blocked at the socket level. A prominent status badge confirms the app is offline while chat, vector retrieval, and the Strategic Advisor continue working seamlessly.
  2. 📡 Live Network Traffic Monitor: A live-updating sidebar panel tracking genuine outbound requests vs. local Ollama requests. Throughout the entire demo, external requests stay locked at 0.
  3. ⚙️ Model Efficiency Lab: Benchmarks two local model configurations side-by-side on real company questions. Measures response latency, tokens generated, tokens/sec throughput, and resident memory (RSS), concluding with an auto-generated rule-based technical verdict.
  4. 🔬 Live Spec Sheet per Answer: Every chat answer and Strategic Advisor run features a collapsible monospace readout directly from Ollama's /api/generate telemetry (eval_count, eval_duration, tokens_per_sec, prompt_eval_count, chunks used).
  5. 🎯 Confidence & Evidence Overlay: Collapsible sources under each answer display the retrieved passage text with matching question keywords bolded, ChromaDB match confidence percentage scores, and a ⚠️ Low confidence warning badge if top retrieval is below 60%.

🎬 30-Second Stage Walkthrough for Judges

[0:00 - 0:08] The Offline Proof "Judges, Company Brain runs 100% offline with zero cloud calls. Watch this: I click '✈️ Disconnect Network'. Our socket interceptor blocks all outbound traffic, and the Live Network Traffic Monitor shows 0 external calls."

[0:08 - 0:16] Chat & Vector RBAC "As an Employee, I ask 'What are the CEO salary details?' — 🔒 Access Denied. The ChromaDB vector filter prevented those chunks from ever reaching the prompt. Now I switch to CEO and ask again — instant answer with 87% match confidence and highlighted source evidence."

[0:16 - 0:24] Real Telemetry & Strategic Advisor "Under the answer, our Live Spec Sheet shows real Ollama telemetry: Gemma generated 142 tokens at 168 tokens/second in 0.84 seconds. Now in '📈 Advisor' mode, Gemma synthesizes our burn rate and runway into proactive, board-ready recommendations."

[0:24 - 0:30] Model Efficiency Lab "In our Model Efficiency Lab, we benchmarked Gemma 1B vs 9B locally: Gemma 1B provides 3.1x faster latency for real-time edge deployment with zero cloud egress cost."


📁 Project Structure

company-brain/
├── app.py                  # Streamlit UI (Chat, Advisor, Lab, RBAC Demo)
├── advisor.py              # CEO Strategic Advisor recommendation engine
├── rag_engine.py           # RAG retrieval + Ollama streaming telemetry + RBAC
├── efficiency_lab.py       # Side-by-side local model benchmarking suite
├── traffic_monitor.py      # Real-time socket monitor & Airplane Mode controller
├── ingest.py               # Document ingestion pipeline
├── access_config.json      # RBAC: filename → access level mapping
├── requirements.txt        # Python dependencies
├── test_app.py             # 8-point automated verification suite
├── README.md               # Documentation & pitch script
├── company_docs/           # Source documents (9 realistic files)
│   ├── employee_handbook.md               (Employee)
│   ├── onboarding_guide.md                (Employee)
│   ├── security_policy.md                 (Employee)
│   ├── product_roadmap.csv                (Manager)
│   ├── team_okrs.md                       (Manager)
│   ├── financial_summary.csv              (CEO)
│   ├── q3_board_meeting_notes.txt         (CEO)
│   ├── salary_bands.csv                   (CEO)
│   └── board_meeting_notes_confidential.txt (CEO)
└── chroma_db/              # ChromaDB persistent vector storage

🔐 Role-Based Access Control (RBAC)

Three hierarchical roles — each sees its own level plus everything below:

Role Clearance Level Visible Documents
👤 Employee Employee-level only Handbook, Onboarding Guide, Security Policy
👔 Manager Employee + Manager + Product Roadmap, Team OKRs
👑 CEO Everything + Strategic Advisor + Financial Summary, Board Notes, Salary Bands, Confidential M&A Notes

Security is enforced at the database query layer: ChromaDB's where: {"access_level": {"$in": allowed_levels}} filter excludes restricted chunks before they are retrieved.


🧪 Verification & Testing

Run the automated test suite:

python test_app.py

Outputs 8/8 successful checks across Ollama connectivity, ChromaDB indexing, RBAC gating, Airplane mode, live telemetry, and Model Efficiency Lab.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages