Spaces:
Running
Running
bitliu
commited on
Commit
Β·
071d3e3
1
Parent(s):
bb1b839
init
Browse filesSigned-off-by: bitliu <bitliu@tencent.com>
app.py
CHANGED
|
@@ -5,6 +5,24 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification, Auto
|
|
| 5 |
|
| 6 |
# ============== Model Configurations ==============
|
| 7 |
MODELS = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"π‘οΈ Fact Check": {
|
| 9 |
"id": "LLM-Semantic-Router/halugate-sentinel",
|
| 10 |
"description": "Determines whether a prompt requires external factual verification.",
|
|
@@ -29,24 +47,6 @@ MODELS = {
|
|
| 29 |
"What's the weather like today?",
|
| 30 |
],
|
| 31 |
},
|
| 32 |
-
"π Category Classifier": {
|
| 33 |
-
"id": "LLM-Semantic-Router/category_classifier_modernbert-base_model",
|
| 34 |
-
"description": "Classifies prompts into academic/professional categories.",
|
| 35 |
-
"type": "sequence",
|
| 36 |
-
"labels": {
|
| 37 |
-
0: ("biology", "π§¬"), 1: ("business", "πΌ"), 2: ("chemistry", "π§ͺ"),
|
| 38 |
-
3: ("computer science", "π»"), 4: ("economics", "π"), 5: ("engineering", "βοΈ"),
|
| 39 |
-
6: ("health", "π₯"), 7: ("history", "π"), 8: ("law", "βοΈ"),
|
| 40 |
-
9: ("math", "π’"), 10: ("other", "π¦"), 11: ("philosophy", "π€"),
|
| 41 |
-
12: ("physics", "βοΈ"), 13: ("psychology", "π§ "),
|
| 42 |
-
},
|
| 43 |
-
"examples": [
|
| 44 |
-
"What is photosynthesis and how does it work?",
|
| 45 |
-
"Explain the concept of supply and demand in economics",
|
| 46 |
-
"What are the key principles of contract law?",
|
| 47 |
-
"How do neural networks learn from data?",
|
| 48 |
-
],
|
| 49 |
-
},
|
| 50 |
"π PII Detector": {
|
| 51 |
"id": "LLM-Semantic-Router/pii_classifier_modernbert-base_model",
|
| 52 |
"description": "Detects the primary type of PII in the text.",
|
|
@@ -190,17 +190,14 @@ def main():
|
|
| 190 |
st.subheader("π Input")
|
| 191 |
text_input = st.text_area("Enter text to analyze:", height=120, placeholder="Type your text here...", key="input_area")
|
| 192 |
|
| 193 |
-
# Examples section - clickable buttons
|
| 194 |
st.markdown("**π‘ Try an example:**")
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
# Show example text preview
|
| 203 |
-
st.caption("Hover over buttons to preview examples")
|
| 204 |
|
| 205 |
st.markdown("---")
|
| 206 |
|
|
|
|
| 5 |
|
| 6 |
# ============== Model Configurations ==============
|
| 7 |
MODELS = {
|
| 8 |
+
"π Category Classifier": {
|
| 9 |
+
"id": "LLM-Semantic-Router/category_classifier_modernbert-base_model",
|
| 10 |
+
"description": "Classifies prompts into academic/professional categories.",
|
| 11 |
+
"type": "sequence",
|
| 12 |
+
"labels": {
|
| 13 |
+
0: ("biology", "π§¬"), 1: ("business", "πΌ"), 2: ("chemistry", "π§ͺ"),
|
| 14 |
+
3: ("computer science", "π»"), 4: ("economics", "π"), 5: ("engineering", "βοΈ"),
|
| 15 |
+
6: ("health", "π₯"), 7: ("history", "π"), 8: ("law", "βοΈ"),
|
| 16 |
+
9: ("math", "π’"), 10: ("other", "π¦"), 11: ("philosophy", "π€"),
|
| 17 |
+
12: ("physics", "βοΈ"), 13: ("psychology", "π§ "),
|
| 18 |
+
},
|
| 19 |
+
"examples": [
|
| 20 |
+
"What is photosynthesis and how does it work?",
|
| 21 |
+
"Explain the concept of supply and demand in economics",
|
| 22 |
+
"What are the key principles of contract law?",
|
| 23 |
+
"How do neural networks learn from data?",
|
| 24 |
+
],
|
| 25 |
+
},
|
| 26 |
"π‘οΈ Fact Check": {
|
| 27 |
"id": "LLM-Semantic-Router/halugate-sentinel",
|
| 28 |
"description": "Determines whether a prompt requires external factual verification.",
|
|
|
|
| 47 |
"What's the weather like today?",
|
| 48 |
],
|
| 49 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
"π PII Detector": {
|
| 51 |
"id": "LLM-Semantic-Router/pii_classifier_modernbert-base_model",
|
| 52 |
"description": "Detects the primary type of PII in the text.",
|
|
|
|
| 190 |
st.subheader("π Input")
|
| 191 |
text_input = st.text_area("Enter text to analyze:", height=120, placeholder="Type your text here...", key="input_area")
|
| 192 |
|
| 193 |
+
# Examples section - clickable buttons with actual content
|
| 194 |
st.markdown("**π‘ Try an example:**")
|
| 195 |
+
for i, example in enumerate(model_config["examples"]):
|
| 196 |
+
# Truncate long examples for button display
|
| 197 |
+
display_text = example if len(example) <= 60 else example[:57] + "..."
|
| 198 |
+
if st.button(display_text, key=f"ex_{i}", use_container_width=True):
|
| 199 |
+
st.session_state.text_input = example
|
| 200 |
+
st.rerun()
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
st.markdown("---")
|
| 203 |
|