Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python Groq FAISS Streamlit

πŸ‘οΈ Oxeye

Codebase Q&A with Context-Aware RAG

Oxeye is an intelligent code assistant that answers questions about your codebase using Retrieval-Augmented Generation (RAG). It parses code into semantic chunks, understands relationships, and provides accurate answers with file references.


✨ Features

Feature Description
🌳 AST Parsing Uses Tree-sitter for accurate code parsing across languages
οΏ½ Semantic Chunking Preserves function/class boundaries instead of arbitrary splits
οΏ½ Hybrid Search Combines dense (embedding) + sparse (BM25) retrieval
⚑ Cross-Encoder Reranking Improves precision with contextual re-scoring
πŸ€– Free LLM Uses Groq's free API (Llama 3.3 70B) - no cost!
πŸ’¬ Streaming Chat Real-time responses with file citations
πŸ™ GitHub Support Clone and index repos directly from URL
🎨 Modern UI Dark theme with glassmorphism effects

πŸš€ Quick Start

1. Clone & Setup

git clone https://github.com/yourusername/oxeye.git
cd oxeye

# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Linux/Mac

# Install dependencies
pip install -r requirements.txt

2. Configure API Key

Get a free Groq API key at console.groq.com

# Copy the example config
copy .env.example .env

# Edit .env and add your key
GROQ_API_KEY=your_api_key_here

3. Run Oxeye

streamlit run oxeye/ui/streamlit_app.py

Open http://localhost:8502 and start asking questions!


πŸ“ Project Structure

oxeye/
β”œβ”€β”€ oxeye/
β”‚   β”œβ”€β”€ __init__.py          # Package init
β”‚   β”œβ”€β”€ config.py             # Settings management
β”‚   β”‚
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ parser/
β”‚   β”‚   β”‚   β”œβ”€β”€ ast_parser.py # Tree-sitter AST parsing
β”‚   β”‚   β”‚   └── chunker.py    # Semantic code chunking
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ embeddings/
β”‚   β”‚   β”‚   └── encoder.py    # Sentence-transformers embeddings
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ retrieval/
β”‚   β”‚   β”‚   β”œβ”€β”€ hybrid.py     # Dense + BM25 fusion
β”‚   β”‚   β”‚   β”œβ”€β”€ reranker.py   # Cross-encoder reranking
β”‚   β”‚   β”‚   └── context.py    # Context builder for LLM
β”‚   β”‚   β”‚
β”‚   β”‚   └── llm/
β”‚   β”‚       β”œβ”€β”€ client.py     # Groq API client
β”‚   β”‚       └── chains.py     # RAG chain orchestration
β”‚   β”‚
β”‚   β”œβ”€β”€ ingestion/
β”‚   β”‚   β”œβ”€β”€ crawler.py        # File discovery
β”‚   β”‚   └── pipeline.py       # End-to-end ingestion
β”‚   β”‚
β”‚   β”œβ”€β”€ storage/
β”‚   β”‚   └── vector_store.py   # FAISS vector storage
β”‚   β”‚
β”‚   └── ui/
β”‚       └── streamlit_app.py  # Chat interface
β”‚
β”œβ”€β”€ requirements.txt          # Dependencies
β”œβ”€β”€ pyproject.toml           # Package config
β”œβ”€β”€ .env.example             # Environment template
└── README.md

πŸ”§ How It Works

graph LR
    A[πŸ“‚ Codebase] --> B[🌳 AST Parser]
    B --> C[🧩 Chunker]
    C --> D[πŸ”’ Embedder]
    D --> E[(πŸ’Ύ FAISS)]
    
    F[❓ Question] --> G[πŸ” Hybrid Search]
    E --> G
    G --> H[⚑ Reranker]
    H --> I[πŸ“ Context Builder]
    I --> J[πŸ€– LLM]
    J --> K[πŸ’¬ Answer]
Loading

Pipeline Steps

  1. Crawl - Find source files (Python, JS, etc.)
  2. Parse - Extract functions, classes, docstrings via AST
  3. Chunk - Split into semantic units preserving context
  4. Embed - Generate vectors via sentence-transformers (local)
  5. Store - Save to FAISS for fast similarity search
  6. Search - Combine dense + BM25 with RRF fusion
  7. Rerank - Boost precision with cross-encoder
  8. Generate - Stream answer from Groq LLM

βš™οΈ Configuration

All settings in .env:

Variable Default Description
GROQ_API_KEY Required Your Groq API key
LLM_MODEL llama-3.3-70b-versatile Groq model to use
EMBEDDING_MODEL all-MiniLM-L6-v2 Local embedding model
TOP_K_RETRIEVAL 10 Chunks to retrieve
TOP_K_RERANK 5 Chunks after reranking
GITHUB_TOKEN Optional For private repos

πŸ› οΈ Tech Stack

Component Technology
LLM Groq (Llama 3.3 70B)
Embeddings sentence-transformers (local)
Vector Store FAISS
AST Parsing Tree-sitter
Sparse Search BM25 (rank-bm25)
Reranking Cross-encoders
UI Streamlit
Config Pydantic Settings

πŸ“ Usage Examples

Ingest a Local Codebase

from oxeye.ingestion.pipeline import IngestionPipeline

pipeline = IngestionPipeline(collection_name="my_project")
stats = pipeline.ingest("./path/to/codebase")
print(f"Indexed {stats.chunks_created} chunks")

Ask Questions

from oxeye.core.llm.chains import RAGChain

chain = RAGChain(collection_name="my_project")
answer = chain.ask("How does authentication work?")
print(answer)

Streaming Responses

for chunk in chain.stream("Explain the database models"):
    print(chunk, end="", flush=True)

🎯 Best Practices

  • βœ… Be specific - "How does UserService.create_user validate email?" works better than "how does it work?"
  • βœ… Reference files - "What does auth.py do?" helps narrow context
  • βœ… Ask about patterns - "What design patterns are used in the API layer?"
  • βœ… Debug with context - "Why might login fail in auth_controller.py?"

🀝 Contributing

Contributions welcome! Feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

πŸ“„ License

MIT License - see LICENSE for details.


Made with ❀️ by Shaan

Releases

Packages

Contributors

Languages