Spaces:
Running
Running
File size: 760 Bytes
94de7c5 3b08189 94de7c5 c9ab972 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import streamlit as st
import streamlit.components.v1 as components
from infer_intent import IntentClassifier
import matplotlib.pyplot as plt
st.title("Intent classifier")
@st.cache_resource
def get_intent_classifier():
cls = IntentClassifier()
return cls
cls = get_intent_classifier()
query = st.text_input("Enter a query", value="What is the weather today")
pred_result, proba_result = cls.find_intent(query)
st.markdown(f"prediction = :green[{pred_result}]")
keys = list(proba_result.keys())
values = list(proba_result.values())
# Creating the bar plot
fig, ax = plt.subplots()
ax.barh(keys, values)
# Adding labels and title
ax.set_xlabel('probability score')
ax.set_ylabel('Intents')
ax.set_title('Intents probability score')
st.pyplot(fig)
|