This project is an AI-powered chatbot that can ingest code repositories (Python, JavaScript, etc.), index and retrieve code, and answer questions about code logic, flow, and suggest improvements. It uses LangChain, OpenAI or SentenceTransformers, and ChromaDB/FAISS for vector search, with a Streamlit UI frontend.
- Ingests and indexes code repositories
- Splits and embeds code for retrieval
- Answers questions about code logic and functions
- Explains code flow in natural language
- Suggests optimizations or bug fixes
- Simple Streamlit UI for interaction
-
Clone the repository and install dependencies:
pip install -r requirements.txt
-
Configure API Keys:
- Add your OpenAI API key to
backend/config.yaml:OPENAI_API_KEY: "your-openai-api-key-here"
- Add your OpenAI API key to
-
Run the App:
streamlit run app.py
-
Usage:
- Enter the path to your code directory in the UI.
- Click "Build/Reload Index" to index your codebase.
- Ask questions about your codebase in the chat box.
Do NOT commit your OpenAI API key to the repository.
Instead, set your API key as an environment variable before running the app:
Windows (PowerShell):
$env:OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Linux/Mac:
export OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Then run:
streamlit run app.py
Your app will automatically read the API key from the environment.
This keeps your secret safe and ensures you can push your code to GitHub without exposing sensitive information.
├── app.py # Streamlit UI entry point
├── backend/
│ ├── code_loader.py # Loads and splits code files
│ ├── indexer.py # Handles embeddings and vector DB
│ ├── qa_chain.py # LangChain pipeline for Q&A
│ └── config.yaml # Configurations (API keys, paths, etc.)
├── requirements.txt
├── README.md
└── data/
└── (indexed DB, code files, etc.)
- "Explain the function
fooin my codebase." - "What does the main loop do?"
- "Suggest improvements for the data loader."
- "Are there any bugs in the authentication logic?"
- For offline embeddings, SentenceTransformers is used by default. To use OpenAI embeddings, modify
indexer.pyaccordingly. - For large codebases, ensure you have sufficient RAM and disk space.