Spaces:
Build error
Build error
babu
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,15 +5,19 @@ from prometheus_client import Counter, generate_latest, CONTENT_TYPE_LATEST
|
|
| 5 |
from transformers import pipeline
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
-
# β
|
| 9 |
app = FastAPI(title="Incident Triage Bot")
|
| 10 |
|
| 11 |
# π Prometheus metrics
|
| 12 |
triage_requests = Counter("triage_requests_total", "Total triage requests")
|
| 13 |
triage_errors = Counter("triage_errors_total", "Total triage errors")
|
| 14 |
|
| 15 |
-
# π§ Load
|
| 16 |
-
triage_pipeline = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# π₯ Request model
|
| 19 |
class Incident(BaseModel):
|
|
@@ -57,7 +61,7 @@ demo = gr.Interface(
|
|
| 57 |
inputs=gr.Textbox(lines=5, placeholder="Describe the incident..."),
|
| 58 |
outputs="text",
|
| 59 |
title="Incident Triage Bot",
|
| 60 |
-
description="Classify incidents and suggest priority using a
|
| 61 |
)
|
| 62 |
|
| 63 |
@app.get("/gradio")
|
|
|
|
| 5 |
from transformers import pipeline
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
+
# β
FastAPI app
|
| 9 |
app = FastAPI(title="Incident Triage Bot")
|
| 10 |
|
| 11 |
# π Prometheus metrics
|
| 12 |
triage_requests = Counter("triage_requests_total", "Total triage requests")
|
| 13 |
triage_errors = Counter("triage_errors_total", "Total triage errors")
|
| 14 |
|
| 15 |
+
# π§ Load lightweight model (CPU only)
|
| 16 |
+
triage_pipeline = pipeline(
|
| 17 |
+
"text2text-generation",
|
| 18 |
+
model="google/flan-t5-small",
|
| 19 |
+
device=-1 # Force CPU
|
| 20 |
+
)
|
| 21 |
|
| 22 |
# π₯ Request model
|
| 23 |
class Incident(BaseModel):
|
|
|
|
| 61 |
inputs=gr.Textbox(lines=5, placeholder="Describe the incident..."),
|
| 62 |
outputs="text",
|
| 63 |
title="Incident Triage Bot",
|
| 64 |
+
description="Classify incidents and suggest priority using a lightweight Transformers model"
|
| 65 |
)
|
| 66 |
|
| 67 |
@app.get("/gradio")
|