Add new demo

This commit is contained in:
ShubhamSaboo 2024-06-02 18:37:49 -05:00
parent f349d3c365
commit 8af748b4c4
3 changed files with 67 additions and 0 deletions

View file

@ -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
```

View file

@ -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)

View file

@ -0,0 +1,2 @@
streamlit
openai