Add Streamlit app and requirements
Browse files- app.py +18 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.title("Hugging Face Model Demo")
|
5 |
+
|
6 |
+
|
7 |
+
@st.cache(allow_output_mutation=True)
|
8 |
+
def load_model():
|
9 |
+
return pipeline("text-generation", model="klyang/MentaLLaMA-chat-7B")
|
10 |
+
|
11 |
+
|
12 |
+
model = load_model()
|
13 |
+
|
14 |
+
user_input = st.text_input("Enter your text:")
|
15 |
+
if user_input:
|
16 |
+
with st.spinner("Generating response..."):
|
17 |
+
result = model(user_input)
|
18 |
+
st.success(result[0]["generated_text"])
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|