Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,34 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
return "π Jenkins restarted successfully."
|
| 9 |
-
elif "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return "π Deployment triggered via CI/CD pipeline."
|
| 11 |
-
elif "check logs" in query:
|
| 12 |
-
return "π Logs retrieved: No errors found."
|
| 13 |
-
elif "disk usage" in query:
|
| 14 |
-
return "π½ Disk usage: 72% used, 28% free."
|
| 15 |
else:
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
gr.Interface(
|
| 19 |
-
fn=
|
| 20 |
-
inputs=gr.Textbox(lines=2, placeholder="
|
| 21 |
outputs="text",
|
| 22 |
-
title="π οΈ DevOps AI Agent",
|
| 23 |
-
description="
|
| 24 |
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load open-source LLM (distilled for speed)
|
| 5 |
+
qa_model = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
|
| 6 |
+
|
| 7 |
+
# Simulated DevOps context (can be replaced with real logs or docs)
|
| 8 |
+
devops_context = """
|
| 9 |
+
Kubernetes pods are running across three nodes. Jenkins is configured with two pipelines: build and deploy.
|
| 10 |
+
Disk usage on node-1 is 72%. Recent logs show no errors. Deployment is triggered via GitHub Actions.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
def devops_qa_agent(query):
|
| 14 |
+
# Rule-based fallback
|
| 15 |
+
if "restart jenkins" in query.lower():
|
| 16 |
return "π Jenkins restarted successfully."
|
| 17 |
+
elif "pod status" in query.lower():
|
| 18 |
+
return "β
All Kubernetes pods are running."
|
| 19 |
+
elif "disk usage" in query.lower():
|
| 20 |
+
return "π½ Disk usage: 72% used on node-1."
|
| 21 |
+
elif "deploy" in query.lower():
|
| 22 |
return "π Deployment triggered via CI/CD pipeline."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
else:
|
| 24 |
+
# LLM-powered Q&A
|
| 25 |
+
result = qa_model(question=query, context=devops_context)
|
| 26 |
+
return f"π€ LLM Answer: {result['answer']}"
|
| 27 |
|
| 28 |
gr.Interface(
|
| 29 |
+
fn=devops_qa_agent,
|
| 30 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask a DevOps question..."),
|
| 31 |
outputs="text",
|
| 32 |
+
title="π οΈ DevOps AI Agent with Open-Source LLM",
|
| 33 |
+
description="Hybrid rule-based + LLM-powered Q&A agent. No API keys needed. Runs locally on Hugging Face Spaces."
|
| 34 |
).launch()
|