diff --git a/README.md b/README.md index 9f9fd80..32af6af 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ Streamlit app that allows you to chat with any webpage using local Llama-3 and R ### 📨 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). +### 📝 Chat with Substack Newsletter +Streamlit app that allows you to chat with a Substack newsletter using OpenAI's API and the Embedchain library. This app leverages GPT-4 to provide accurate answers to questions based on the content of the specified Substack newsletter. + ### 📄 Chat with PDF Engage in intelligent conversation and question-answering based on the content of your PDF documents. Simply upload a PDF document and start asking questions. Chat with PDF will analyze the document, extract relevant information, and generate accurate responses to your queries. diff --git a/chat_with_substack/README.md b/chat_with_substack/README.md new file mode 100644 index 0000000..140444c --- /dev/null +++ b/chat_with_substack/README.md @@ -0,0 +1,28 @@ +## 📝 Chat with Substack Newsletter +Streamlit app that allows you to chat with a Substack newsletter using OpenAI's API and the Embedchain library. This app leverages GPT-4 to provide accurate answers to questions based on the content of the specified Substack newsletter. + +## Features +- Input a Substack blog URL +- Ask questions about the content of the Substack newsletter +- 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. Run the Streamlit App +```bash +streamlit run chat_substack.py +``` \ No newline at end of file diff --git a/chat_with_substack/chat_substack.py b/chat_with_substack/chat_substack.py new file mode 100644 index 0000000..839bb69 --- /dev/null +++ b/chat_with_substack/chat_substack.py @@ -0,0 +1,41 @@ +import streamlit as st +from embedchain import App +import tempfile + +# Define the embedchain_bot function +def embedchain_bot(db_path, api_key): + return App.from_config( + config={ + "llm": {"provider": "openai", "config": {"model": "gpt-4-turbo", "temperature": 0.5, "api_key": api_key}}, + "vectordb": {"provider": "chroma", "config": {"dir": db_path}}, + "embedder": {"provider": "openai", "config": {"api_key": api_key}}, + } + ) + +st.title("Chat with Substack Newsletter 📝") +st.caption("This app allows you to chat with Substack newsletter using OpenAI API") + +# Get OpenAI API key from user +openai_access_token = st.text_input("OpenAI API Key", type="password") + +if openai_access_token: + # Create a temporary directory to store the database + db_path = tempfile.mkdtemp() + # Create an instance of Embedchain App + app = embedchain_bot(db_path, openai_access_token) + + # Get the Substack blog URL from the user + substack_url = st.text_input("Enter Substack Newsletter URL", type="default") + + if substack_url: + # Add the Substack blog to the knowledge base + app.add(substack_url, data_type='substack') + st.success(f"Added {substack_url} to knowledge base!") + + # Ask a question about the Substack blog + query = st.text_input("Ask any question about the substack newsletter!") + + # Query the Substack blog + if query: + result = app.query(query) + st.write(result) diff --git a/chat_with_substack/requirements.txt b/chat_with_substack/requirements.txt new file mode 100644 index 0000000..ca9e4b6 --- /dev/null +++ b/chat_with_substack/requirements.txt @@ -0,0 +1,2 @@ +streamlit +embedchain \ No newline at end of file