100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
Add new demo
ShubhamSaboo8af748b4c445
diff --git a/local_chatgpt_clone/README.md b/local_chatgpt_clone/README.mdnew file mode 100644index 00000000..f3701b73--- /dev/null+++ b/local_chatgpt_clone/README.md@@ -0,0 +1,29 @@+## π¦π¬ ChatGPT Clone using Llama-3+This project demonstrates how to build a ChatGPT clone using the Llama-3 model running locally on your computer. The application is built using Python and Streamlit, providing a user-friendly interface for interacting with the language model. Best of all, it's 100% free and doesn't require an internet connection!++### Features+- Runs locally on your computer without the need for an internet connection and completely free to use.+- Utilizes the Llama-3 instruct model for generating responses+- Provides a chat-like interface for seamless interaction++### 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. Download and install the [LM Studio desktop app](https://lmstudio.ai/). Download the Llama-3 instruct model.++4. Expose the Llama-3 model as an OpenAI API by starting the server in LM Studio. Watch this [video walkthrough](https://x.com/Saboo_Shubham_/status/1783715814790549683).++5. Run the Streamlit App+```bash+streamlit run chatgpt_clone_llama3.py+```+diff --git a/local_chatgpt_clone/chatgpt_clone_llama3.py b/local_chatgpt_clone/chatgpt_clone_llama3.pynew file mode 100644index 00000000..9afa65ab--- /dev/null+++ b/local_chatgpt_clone/chatgpt_clone_llama3.py@@ -0,0 +1,36 @@+import streamlit as st+from openai import OpenAI++# Set up the Streamlit App+st.title("ChatGPT Clone using Llama-3 π¦")+st.caption("Chat with locally hosted Llama-3 using the LM Studio π―")++# Point to the local server setup using LM Studio+client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")++# Initialize the chat history+if "messages" not in st.session_state:+ st.session_state.messages = []++# Display the chat history+for message in st.session_state.messages:+ with st.chat_message(message["role"]):+ st.markdown(message["content"])++# Accept user input+if prompt := st.chat_input("What is up?"):+ # Add user message to chat history+ st.session_state.messages.append({"role": "user", "content": prompt})+ # Display user message in chat message container+ with st.chat_message("user"):+ st.markdown(prompt)+ # Generate response+ response = client.chat.completions.create(+ model="lmstudio-community/Meta-Llama-3-8B-Instruct-GGUF",+ messages=st.session_state.messages, temperature=0.7+ )+ # Add assistant response to chat history+ st.session_state.messages.append({"role": "assistant", "content": response.choices[0].message.content})+ # Display assistant response in chat message container+ with st.chat_message("assistant"):+ st.markdown(response.choices[0].message.content)diff --git a/local_chatgpt_clone/requirements.txt b/local_chatgpt_clone/requirements.txtnew file mode 100644index 00000000..959b0d72--- /dev/null+++ b/local_chatgpt_clone/requirements.txt@@ -0,0 +1,2 @@+streamlit+openai\ No newline at end of file