Spaces:
Build error
Build error
Bahareh Kavousi nejad commited on
Commit ·
3cf9169
1
Parent(s): 70c93f7
Initial commit with Streamlit app
Browse files- app.py +16 -2
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,4 +1,18 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load your LLM
|
| 5 |
+
chatbot = pipeline("text-generation", model="gpt2")
|
| 6 |
+
|
| 7 |
+
# Streamlit app interface
|
| 8 |
+
st.title("Chat with LLM")
|
| 9 |
+
|
| 10 |
+
user_input = st.text_input("You: ", placeholder="Type your message here...")
|
| 11 |
+
|
| 12 |
+
if st.button("Send"):
|
| 13 |
+
if user_input.strip():
|
| 14 |
+
with st.spinner("Generating response..."):
|
| 15 |
+
response = chatbot(user_input, max_length=100, num_return_sequences=1)
|
| 16 |
+
st.text_area("AI:", value=response[0]["generated_text"], height=200, max_chars=None)
|
| 17 |
+
else:
|
| 18 |
+
st.warning("Please enter a valid input.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers
|