From 007be7234514da26d30d85f73b0a98ec079225b6 Mon Sep 17 00:00:00 2001 From: ShubhamSaboo Date: Sat, 4 May 2024 22:25:52 -0500 Subject: [PATCH] Added new example --- README.md | 3 ++ chat_with_github/README.md | 48 +++++++++++++++++++++++++++++++ chat_with_github/chat_github.py | 36 +++++++++++++++++++++++ chat_with_github/requirements.txt | 2 ++ 4 files changed, 89 insertions(+) create mode 100644 chat_with_github/README.md create mode 100644 chat_with_github/chat_github.py create mode 100644 chat_with_github/requirements.txt diff --git a/README.md b/README.md index 32af6af..da0779d 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ A curated collection of awesome LLM apps using RAG with OpenAI, Anthropic, Gemin ### 💻 Local Lllama-3 with RAG Streamlit app that allows you to chat with any webpage using local Llama-3 and Retrieval Augmented Generation (RAG). This app runs entirely on your computer, making it 100% free and without the need for an internet connection. +### 💬 Chat with GitHub Repo +Engage in natural conversations with your GitHub repositories using GPT-4. Uncover valuable insights and documentation effortlessly, as if you were chatting with your codebase itself. + ### 📨 Chat with Gmail Interact with your Gmail inbox using natural language. Get accurate answers to your questions based on the content of your emails with Retrieval Augmented Generation (RAG). diff --git a/chat_with_github/README.md b/chat_with_github/README.md new file mode 100644 index 0000000..423c6fb --- /dev/null +++ b/chat_with_github/README.md @@ -0,0 +1,48 @@ +## 💬 Chat with GitHub Repo + +LLM app with RAG to chat with GitHub Repo in just 30 lines of Python Code. The app uses Retrieval Augmented Generation (RAG) to provide accurate answers to questions based on the content of the specified GitHub repository. + +### Features + +- Provide the name of GitHub Repository as input +- Ask questions about the content of the GitHub repository +- Get accurate answers using OpenAI's API and Embedchain + +### How to get Started? + +1. Clone the GitHub repository + +```bash +git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git +``` +2. Install the required dependencies: + +```bash +pip install -r requirements.txt +``` +3. Get your OpenAI API Key + +- Sign up for an [OpenAI account](https://platform.openai.com/) (or the LLM provider of your choice) and obtain your API key. + +4. Get your GitHub Access Token + +- Create a [personal access token](https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token) with the necessary permissions to access the desired GitHub repository. + +4. Run the Streamlit App +```bash +streamlit run chat_github.py +``` + +### How it Works? + +- The app prompts the user to enter their OpenAI API key, which is used to authenticate requests to the OpenAI API. + +- It initializes an instance of the Embedchain App class and a GithubLoader with the provided GitHub Access Token. + +- The user is prompted to enter a GitHub repository URL, which is then added to the Embedchain app's knowledge base using the GithubLoader. + +- The user can ask questions about the GitHub repository using the text input. + +- When a question is asked, the app uses the chat method of the Embedchain app to generate an answer based on the content of the GitHub repository. + +- The app displays the generated answer to the user. diff --git a/chat_with_github/chat_github.py b/chat_with_github/chat_github.py new file mode 100644 index 0000000..fa01901 --- /dev/null +++ b/chat_with_github/chat_github.py @@ -0,0 +1,36 @@ +# Import the required libraries +from embedchain.pipeline import Pipeline as App +from embedchain.loaders.github import GithubLoader +import streamlit as st +import os + +loader = GithubLoader( + config={ + "token":"Your GitHub Token", + } + ) + +# Create Streamlit app +st.title("Chat with GitHub Repository 💬") +st.caption("This app allows you to chat with a GitHub Repo using OpenAI API") + +# Get OpenAI API key from user +openai_access_token = st.text_input("OpenAI API Key", type="password") + +# If OpenAI API key is provided, create an instance of App +if openai_access_token: + os.environ["OPENAI_API_KEY"] = openai_access_token + # Create an instance of Embedchain App + app = App() + # Get the GitHub repo from the user + git_repo = st.text_input("Enter the GitHub Repo", type="default") + if git_repo: + # Add the repo to the knowledge base + app.add("repo:" + git_repo + " " + "type:repo", data_type="github", loader=loader) + st.success(f"Added {git_repo} to knowledge base!") + # Ask a question about the Github Repo + prompt = st.text_input("Ask any question about the GitHub Repo") + # Chat with the GitHub Repo + if prompt: + answer = app.chat(prompt) + st.write(answer) \ No newline at end of file diff --git a/chat_with_github/requirements.txt b/chat_with_github/requirements.txt new file mode 100644 index 0000000..b9431cd --- /dev/null +++ b/chat_with_github/requirements.txt @@ -0,0 +1,2 @@ +streamlit +embedchain[github] \ No newline at end of file