Spaces:
Sleeping
Sleeping
Download app.py from jamalinu/DeepPragma: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/jamalinu/DeepPragma/resolve/main/app.py
- Command line
-
hf download hf://spaces/jamalinu/DeepPragma/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jamalinu/DeepPragma/resolve/main/app.py
1.1 kB
| import os | |
| import spaces | |
| import gradio as gr | |
| from src.engine import DeepPragmaEngine | |
| from src.llm_client import GroqClient | |
| from src.knowledge_retriever import DogwhistleRetriever | |
| engine = DeepPragmaEngine() | |
| llm = GroqClient() if os.environ.get("GROQ_API_KEY") else None | |
| retriever = DogwhistleRetriever() | |
| def analyze(phrase): | |
| if not phrase.strip(): | |
| return "", "" | |
| if not llm: | |
| return "GROQ_API_KEY not configured", "" | |
| kb_matches = retriever.retrieve(phrase) | |
| result = llm.classify(phrase, kb_context=kb_matches) | |
| label = result["label"] | |
| reasoning = f"[Confidence: {result['confidence']}] {result['reasoning']}" | |
| return label, reasoning | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🛡️ DeepPragma Classifier") | |
| input_box = gr.Textbox(label="Enter a sentence") | |
| button = gr.Button("Analyze") | |
| output_label = gr.Textbox(label="Classification") | |
| output_reasoning = gr.Textbox(label="Expert validation") | |
| button.click(analyze, input_box, [output_label, output_reasoning]) | |
| demo.launch() |