Spaces:
Sleeping
Sleeping
Download old_1_app.py from DanishShahzad/Sample_ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/DanishShahzad/Sample_ChatBot/resolve/main/old_1_app.py
- Command line
-
hf download hf://spaces/DanishShahzad/Sample_ChatBot/old_1_app.py
-
curl -L -o old_1_app.py https://huggingface.co/spaces/DanishShahzad/Sample_ChatBot/resolve/main/old_1_app.py
854 Bytes
| import streamlit as st | |
| from groq_chat import chat_with_groq | |
| st.set_page_config(page_title="Groq Chatbot", page_icon="💬") | |
| st.title("🤖 Chat with Groq-powered LLaMA 3") | |
| if "history" not in st.session_state: | |
| st.session_state.history = [] | |
| # Display chat history | |
| for msg in st.session_state.history: | |
| with st.chat_message(msg["role"]): | |
| st.markdown(msg["content"]) | |
| # Chat input | |
| prompt = st.chat_input("Say something...") | |
| if prompt: | |
| st.session_state.history.append({"role": "user", "content": prompt}) | |
| with st.chat_message("user"): | |
| st.markdown(prompt) | |
| with st.spinner("Thinking..."): | |
| reply = chat_with_groq(prompt, history=st.session_state.history) | |
| st.session_state.history.append({"role": "assistant", "content": reply}) | |
| with st.chat_message("assistant"): | |
| st.markdown(reply) | |