Clone the repository
Project repo: https://github.com/
conda create -n llmapp python=3.8 -y
conda activate llmapp
pip install -r requirements.txt
OPENAI_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Finally run the following command
python app.py
Now,
open up localhost:
This project is a powerful integration of multiple technologies and tools for analyzing and interacting with GitHub repositories. It allows users to input a GitHub repository URL and ask questions about the repository. The system processes the repository's content and provides relevant answers based on the repository's data.
- Flask: Web framework for serving the user interface and handling requests.
- LangChain: Framework for combining language models with a memory system and a retriever to provide coherent answers.
- Chroma: Vector database for storing and retrieving embeddings.
- OpenAI Embeddings: Pre-trained embeddings from OpenAI for document representation.
- GitPython: Library for interacting with Git repositories.
The user interface consists of a simple HTML page (index.html
) served by Flask. The user can input a GitHub repository URL and ask questions about the repository.
The Flask server handles user requests and serves the interface. It includes two main routes:
/chatbot
: Handles POST requests with a GitHub repository URL./get
: Handles POST requests with user messages for the chatbot.
- Accepts Repository URL: The user submits a GitHub repository URL.
- Calls
repo_ingestion
: Therepo_ingestion
function inhelper.py
is called to clone the repository. - Calls
store_index.py
: This script processes the cloned repository to prepare it for question-answering by performing the following steps:- Load Repo Files: Uses
GenericLoader
to load Python files from the cloned repository. - Text Splitter: Splits the loaded files into smaller chunks for better processing.
- Load Embeddings: Loads pre-trained embeddings from OpenAI.
- Store Vectors: Stores the processed vectors in a vector database (Chroma).
- Load Repo Files: Uses
- Accepts User Message: The user submits a question about the repository.
- Processes Message with QA Chain: Uses the
ConversationalRetrievalChain
to process the user's question. This chain retrieves relevant information from the vector database and generates an answer.
repo_ingestion
: Clones the provided GitHub repository into a local directory.load_repo
: Loads the cloned repository's files into documents.text_splitter
: Splits the loaded documents into smaller chunks.load_embedding
: Loads pre-trained embeddings for the documents.
This script prepares the repository files for the QA system:
- Loads the repository files.
- Splits the text into manageable chunks.
- Loads embeddings for the chunks.
- Stores the embeddings in a vector database (Chroma) for later retrieval during QA.
This component of LangChain combines language models with a memory system and a retriever to provide coherent answers based on the repository's content.
- User opens the web interface and submits a GitHub repository URL.
- User asks questions about the repository.
- Flask server handles the URL submission, calls
repo_ingestion
to clone the repository, and runsstore_index.py
to prepare the data. store_index.py
loads, splits, and embeds the repository's content, storing it in a vector database.
- Flask server handles user questions, using the QA chain to retrieve and generate answers based on the processed repository data.
The system returns the answer to the user's question, displayed in the web interface.
- Automated Reviews: Enhance the system to perform automated code reviews, providing suggestions for improvements, detecting potential bugs, and ensuring coding standards are met.
- Collaborative Reviews: Integrate with platforms like GitHub to assist in collaborative code reviews by summarizing changes and providing insights.
- Generate Documentation: Automatically generate documentation from code comments and docstrings, helping maintain up-to-date and comprehensive documentation.
- Interactive Docs: Allow developers to interactively ask questions about the codebase and receive explanations and usage examples.
- Learning Tool: Serve as an educational tool for new developers to understand the architecture, design patterns, and implementation details of a project.
- Guided Tours: Provide guided tours of the codebase, highlighting key components and their interactions.
- Enhanced Search: Enable advanced search capabilities within the codebase, allowing developers to find specific functions, classes, or patterns quickly.
- Contextual Search: Offer context-aware search results, showing not only the code snippets but also related documentation and usage examples.
- Refactoring Support: Assist in understanding and refactoring legacy code by providing summaries, detecting code smells, and suggesting modern alternatives.
- Migration Assistance: Help in migrating codebases to new technologies or frameworks by identifying dependencies and suggesting migration paths.
If you like this project, please follow and give a star โญ!