Sample_ChatBot / old_1_app.py
DanishShahzad's picture
Rename old1_app.py to old_1_app.py
e585b88 verified
Raw History Blame Contribute Delete
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)