Update app.py
Browse files
app.py
CHANGED
|
@@ -14,12 +14,6 @@ st.set_page_config(
|
|
| 14 |
menu_items=None
|
| 15 |
)
|
| 16 |
|
| 17 |
-
#st.logo(
|
| 18 |
-
# "https://dejan.ai/wp-content/uploads/2024/02/dejan-300x103.png",
|
| 19 |
-
# size="large",
|
| 20 |
-
# link="https://dejan.ai/"
|
| 21 |
-
#)
|
| 22 |
-
|
| 23 |
MODEL_ID = "dejanseo/query-grounding"
|
| 24 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 25 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
@@ -38,33 +32,52 @@ def classify(prompt: str):
|
|
| 38 |
confidence = probs[pred].item()
|
| 39 |
return pred, confidence
|
| 40 |
|
| 41 |
-
#
|
| 42 |
st.markdown("""
|
| 43 |
<style>
|
| 44 |
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');
|
| 45 |
|
| 46 |
-
html, body, div, span, input, label, textarea, button, h1, h2, p,table {
|
| 47 |
font-family: 'Montserrat', sans-serif !important;
|
| 48 |
}
|
| 49 |
|
| 50 |
-
/* Streamlit's dynamic classes */
|
| 51 |
[class^="css-"], [class*=" css-"] {
|
| 52 |
font-family: 'Montserrat', sans-serif !important;
|
| 53 |
}
|
| 54 |
|
| 55 |
header {visibility: hidden;}
|
| 56 |
-
|
| 57 |
</style>
|
| 58 |
""", unsafe_allow_html=True)
|
| 59 |
|
| 60 |
-
|
| 61 |
st.title("QDG Classifier")
|
| 62 |
st.write("Built by [**Dejan AI**](https://dejan.ai)")
|
| 63 |
st.write("Google's AI models can request grounding with search to deliver more accurate or up-to-date answers. This tool predicts whether a search query, question, or prompt is likely to be grounded.")
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
if st.button("Classify"):
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
if not prompts:
|
| 69 |
st.warning("Please enter at least one prompt.")
|
| 70 |
else:
|
|
@@ -93,4 +106,8 @@ if st.button("Classify"):
|
|
| 93 |
},
|
| 94 |
hide_index=True,
|
| 95 |
)
|
| 96 |
-
info_box.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
menu_items=None
|
| 15 |
)
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
MODEL_ID = "dejanseo/query-grounding"
|
| 18 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 19 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
| 32 |
confidence = probs[pred].item()
|
| 33 |
return pred, confidence
|
| 34 |
|
| 35 |
+
# Font and style overrides
|
| 36 |
st.markdown("""
|
| 37 |
<style>
|
| 38 |
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');
|
| 39 |
|
| 40 |
+
html, body, div, span, input, label, textarea, button, h1, h2, p, table {
|
| 41 |
font-family: 'Montserrat', sans-serif !important;
|
| 42 |
}
|
| 43 |
|
|
|
|
| 44 |
[class^="css-"], [class*=" css-"] {
|
| 45 |
font-family: 'Montserrat', sans-serif !important;
|
| 46 |
}
|
| 47 |
|
| 48 |
header {visibility: hidden;}
|
|
|
|
| 49 |
</style>
|
| 50 |
""", unsafe_allow_html=True)
|
| 51 |
|
| 52 |
+
# UI
|
| 53 |
st.title("QDG Classifier")
|
| 54 |
st.write("Built by [**Dejan AI**](https://dejan.ai)")
|
| 55 |
st.write("Google's AI models can request grounding with search to deliver more accurate or up-to-date answers. This tool predicts whether a search query, question, or prompt is likely to be grounded.")
|
| 56 |
+
|
| 57 |
+
# Placeholder example prompts
|
| 58 |
+
example_text = """how would a cat describe a dog
|
| 59 |
+
how to reset a Nest thermostat
|
| 60 |
+
write a poem about time
|
| 61 |
+
is there a train strike in London today
|
| 62 |
+
summarize the theory of relativity
|
| 63 |
+
who won the champions league last year
|
| 64 |
+
explain quantum computing to a child
|
| 65 |
+
weather in tokyo tomorrow
|
| 66 |
+
generate a social media post for Earth Day
|
| 67 |
+
what is the latest iPhone model"""
|
| 68 |
+
|
| 69 |
+
user_input = st.text_area(
|
| 70 |
+
"Enter one search query, question, or prompt per line:",
|
| 71 |
+
placeholder=example_text
|
| 72 |
+
)
|
| 73 |
|
| 74 |
if st.button("Classify"):
|
| 75 |
+
raw_input = user_input.strip()
|
| 76 |
+
if raw_input:
|
| 77 |
+
prompts = [line.strip() for line in raw_input.split("\n") if line.strip()]
|
| 78 |
+
else:
|
| 79 |
+
prompts = [line.strip() for line in example_text.split("\n")]
|
| 80 |
+
|
| 81 |
if not prompts:
|
| 82 |
st.warning("Please enter at least one prompt.")
|
| 83 |
else:
|
|
|
|
| 106 |
},
|
| 107 |
hide_index=True,
|
| 108 |
)
|
| 109 |
+
info_box.empty()
|
| 110 |
+
|
| 111 |
+
# Promo message shown only after results
|
| 112 |
+
st.subheader("Working together.")
|
| 113 |
+
st.write("[**Schedule a call**](https://dejan.ai/call/) to see how we can help you.")
|