Code RAG leverages a retrieval-augmented generation (RAG) model to generate code based on your queries. Whether you're building from scratch or using pre-built images, this guide will help you get started with setting up and using Code RAG seamlessly.
We have used the CodeSearchNet dataset in this project. Please cite the following paper if you use the dataset:
@article{husain2019codesearchnet,
title={{CodeSearchNet} challenge: Evaluating the state of semantic code search},
author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc},
journal={arXiv preprint arXiv:1909.09436},
year={2019}
}For more information, visit the CodeSearchNet GitHub repository.
Here is the result for the query: "write code to parse json file in python".
❗ This repository contains original coursework submitted for academic credit. Reuse, reproduction, or redistribution is prohibited without explicit permission.
Follow the instructions below to clone the repository, set up the Docker environment, and start generating code. We recommend using Option 2. Let's get started!
Start by cloning the repository to your local machine. Open your terminal or Git CMD and run the following command:
git clone https://github.com/ABDixit11/Code-RAG.gitThe next step is to build the Docker container. This will automatically install all the required dependencies and set up the environment for the Code RAG model.
Run the following command to build the Docker image:
- Build docker image:
docker build -t coderag:latest .- Run the docker container:
Use the following command :
docker run -d --memory=10g --memory-swap=24g coderag:latest- Get the Container ID:
Use the following command to list all running containers:
docker ps- Exec Into the Docker Container
docker exec -it <container_id> bash- Run shell script
./setup.sh- Run python script
python coderag.py- Write queries for code generation
Generate a Python function to calculate the factorial of a number.To save time, you can use the pre-built Docker image hosted on Docker Hub instead of building the image locally.
Follow these steps to pull and run the pre-built image:
docker pull adixit34/coderag-group-10:latestAfter building or pulling the Docker image, run the following command to start the Docker container:
docker run -d --memory=10g --memory-swap=24g coderag:latestPlease wait until everything is loaded and ready to go.
Now that you are inside the Docker container, you can interact with the Code RAG model. Simply type your programming query in the terminal, and the model will generate the desired code.
For example, you can ask the model:
Generate a Python function to calculate the factorial of a number.- Abhijeet Dixit
- Hrushikesh Mulavekar
- Ritika Sarkar
- Gunika Dhingra
- Nithesh Gowda
- Rachana Kumar
