Skip to content

ChiragSW/CAS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CAS - Codebase Agent

This project is a Retrieval-Augmented Generation (RAG) agent designed to understand and interact with codebases. It ingests external repositories, indexes them using vector embeddings, and allows users to query the codebase using a powerful LLM.

Table of Contents

Tech Stack used

Stack Tech
Language Python
Frameworks FastAPI LangChain LangGraph
AI / ML Google Gemini Sentence Transformers
Database ChromaDB
Utilities PyPDF PyMuPDF

Project Structure

RAG/
│
├── add_repo.py                     # Script to ingest external repositories
├── run_app.bat                     # Batch script to run the application
├── requirements.txt                # Project dependencies
├── .env                            # Environment variables (API keys)
│
├── intern/                         # Core internal logic
│   ├── agent/                      # Agent definition
│   │   ├── graph.py                # LangGraph workflow definition
│   │   ├── state.py                # Agent state definition
│   │   └── tools.py                # Custom tools for the agent
│   │
│   ├── app/                        # FastAPI application
│   │   └── main.py                 # API entry point
│   │
│   ├── db/                         # Database handling
│   │
│   └── ingest/                     # Ingestion logic
│       └── ingest_codebase.py      # Logic to ingest code into ChromaDB
│
├── source_code/                    # Directory where ingested repos are stored
│   └── ...
│
├── testfiles/                      # Files for testing
│
└── venv/                           # Virtual environment

How to use?

1. Setup Environment

Ensure you have Python installed. Create a virtual environment and install dependencies.

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Create a .env file in the root directory and add your Google API key:

GOOGLE_API_KEY=your_api_key_here

2. Ingest a Repository

To add a codebase for the agent to understand, use the add_repo.py script. This will copy the repo to source_code/ and ingest it into the vector database.

python add_repo.py /path/to/external/repo

3. Run the Agent

You can start the FastAPI server using the provided batch script or directly with uvicorn.

Using Batch Script:

run_app.bat

Using Uvicorn:

cd intern
uvicorn app.main:app --reload

4. Query the Agent

Once the server is running (default: http://localhost:8000), you can send POST requests to interact with the agent.

Endpoint: POST /

Payload:

{
  "question": "Explain the main logic of the ingested codebase."
}

Author

Chirag Wattamwar

About

CAS is an agent built with LangChain and LangGraph that helps developers query large codebases. It finds files based on their purpose, suggests improvements, and answers questions about a project’s structure and the role of specific files, making complex codebases easier to understand and maintain.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages