Spaces:
Sleeping
Sleeping
Initial commit
Browse files- app.py +27 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from intent_classifier.model import IntentClassifier
|
| 4 |
+
from consts import FLAN_T5_SMALL, FLAN_T5_BASE
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@st.cache_resource
|
| 8 |
+
def load_model(model_name="Serj/intent-classifier", device=None):
|
| 9 |
+
st.write(f"model path: {model_name}")
|
| 10 |
+
m = IntentClassifier(model_name=model_name, device=device)
|
| 11 |
+
return m
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
model = load_model()
|
| 15 |
+
|
| 16 |
+
# text = "Hey, I want to stop my subscription. Can I do that?"
|
| 17 |
+
text = "I was expecting my card to get this week and I'm wandering why didn't I receive it yet?"
|
| 18 |
+
input = st.text_area("text", value=text)
|
| 19 |
+
prompt_options_values = " # how do I locate my card # my card hasn't arrived yet # I would like to reactivate my card # where do I link my card? # How do I re add my card? # how do I add the card to my account? # status of the card order "
|
| 20 |
+
prompt_options = st.text_area("prompt_options", value=prompt_options_values)
|
| 21 |
+
is_clicked = st.button("Submit")
|
| 22 |
+
if is_clicked:
|
| 23 |
+
output = model.structured_predict(input, prompt_options, print_input=True)
|
| 24 |
+
st.write(output)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
git+https://github.com/SerjSmor/intent_classification
|
| 2 |
+
streamlit
|