bitliu commited on
Commit
071d3e3
Β·
1 Parent(s): bb1b839

Signed-off-by: bitliu <bitliu@tencent.com>

Files changed (1) hide show
  1. app.py +25 -28
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
- example_cols = st.columns(len(model_config["examples"]))
196
- for i, (col, example) in enumerate(zip(example_cols, model_config["examples"])):
197
- with col:
198
- if st.button(f"Example {i+1}", key=f"ex_{i}", use_container_width=True, help=example):
199
- st.session_state.text_input = example
200
- st.rerun()
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