Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -3,7 +3,7 @@ title: Jenkins Error Explainer
|
|
| 3 |
emoji: 🔧
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
-
sdk:
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
---
|
|
|
|
| 3 |
emoji: 🔧
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
---
|
app.py
CHANGED
|
@@ -1,31 +1,100 @@
|
|
| 1 |
-
# app.py - Entry point for HuggingFace Spaces (
|
| 2 |
import sys
|
| 3 |
sys.path.insert(0, ".")
|
| 4 |
|
| 5 |
-
|
| 6 |
from explain_error import explain_error
|
| 7 |
|
| 8 |
-
|
| 9 |
-
"""Explain Jenkins error from log text."""
|
| 10 |
-
if not log_text.strip():
|
| 11 |
-
return "Please provide a Jenkins error log."
|
| 12 |
-
result = explain_error(log_text)
|
| 13 |
-
return f"""**Error Category:** {result['error_category']}
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
outputs=gr.Markdown(label="Explanation"),
|
| 27 |
-
title="Jenkins Error Explainer",
|
| 28 |
-
description="AI-powered Jenkins pipeline error diagnosis using RAG"
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
# app.py - Entry point for HuggingFace Spaces (FastAPI)
|
| 2 |
import sys
|
| 3 |
sys.path.insert(0, ".")
|
| 4 |
|
| 5 |
+
from fastapi import FastAPI
|
| 6 |
from explain_error import explain_error
|
| 7 |
|
| 8 |
+
app = FastAPI(title="Jenkins Error Explainer")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
@app.get("/", response_class=str)
|
| 11 |
+
async def home():
|
| 12 |
+
return """<!DOCTYPE html>
|
| 13 |
+
<html lang="en">
|
| 14 |
+
<head>
|
| 15 |
+
<meta charset="UTF-8">
|
| 16 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 17 |
+
<title>Jenkins Error Explainer</title>
|
| 18 |
+
<style>
|
| 19 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 20 |
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; padding: 20px; }
|
| 21 |
+
.container { max-width: 800px; margin: 0 auto; }
|
| 22 |
+
h1 { color: #333; margin-bottom: 10px; }
|
| 23 |
+
.description { color: #666; margin-bottom: 20px; }
|
| 24 |
+
textarea { width: 100%; height: 200px; padding: 15px; border: 1px solid #ddd; border-radius: 8px; font-family: monospace; font-size: 14px; resize: vertical; }
|
| 25 |
+
button { background: #4CAF50; color: white; border: none; padding: 12px 24px; font-size: 16px; border-radius: 8px; cursor: pointer; margin-top: 10px; }
|
| 26 |
+
button:hover { background: #45a049; }
|
| 27 |
+
#result { margin-top: 20px; padding: 20px; background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
| 28 |
+
.error-category { color: #e74c3c; font-weight: bold; font-size: 18px; }
|
| 29 |
+
.summary { margin: 15px 0; line-height: 1.6; }
|
| 30 |
+
.causes ul { margin-left: 20px; }
|
| 31 |
+
.references { margin-top: 15px; font-size: 14px; color: #666; }
|
| 32 |
+
</style>
|
| 33 |
+
</head>
|
| 34 |
+
<body>
|
| 35 |
+
<div class="container">
|
| 36 |
+
<h1>🔧 Jenkins Error Explainer</h1>
|
| 37 |
+
<p class="description">AI-powered Jenkins pipeline error diagnosis using RAG</p>
|
| 38 |
+
|
| 39 |
+
<textarea id="logInput" placeholder="Paste your Jenkins error log here..."></textarea>
|
| 40 |
+
<br>
|
| 41 |
+
<button onclick="explainError()" id="submitBtn">Explain Error</button>
|
| 42 |
+
|
| 43 |
+
<div id="result"></div>
|
| 44 |
+
</div>
|
| 45 |
|
| 46 |
+
<script>
|
| 47 |
+
async function explainError() {
|
| 48 |
+
const logText = document.getElementById('logInput').value;
|
| 49 |
+
const resultDiv = document.getElementById('result');
|
| 50 |
+
const btn = document.getElementById('submitBtn');
|
| 51 |
+
|
| 52 |
+
if (!logText.trim()) {
|
| 53 |
+
resultDiv.innerHTML = '<p>Please provide a Jenkins error log.</p>';
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
btn.disabled = true;
|
| 58 |
+
btn.textContent = 'Analyzing...';
|
| 59 |
+
resultDiv.innerHTML = '<p>Analyzing your Jenkins error...</p>';
|
| 60 |
+
|
| 61 |
+
try {
|
| 62 |
+
const response = await fetch('/explain', {
|
| 63 |
+
method: 'POST',
|
| 64 |
+
headers: { 'Content-Type': 'application/json' },
|
| 65 |
+
body: JSON.stringify({ log_text: logText })
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
const data = await response.json();
|
| 69 |
+
|
| 70 |
+
resultDiv.innerHTML = `
|
| 71 |
+
<p class="error-category">Error Category: ${data.error_category}</p>
|
| 72 |
+
<p class="summary"><strong>Summary:</strong> ${data.summary}</p>
|
| 73 |
+
<div class="causes">
|
| 74 |
+
<strong>Likely Causes:</strong>
|
| 75 |
+
<ul>${data.likely_causes.map(c => `<li>${c}</li>`).join('')}</ul>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="references">
|
| 78 |
+
<strong>References:</strong><br>
|
| 79 |
+
${data.references.join('<br>')}
|
| 80 |
+
</div>
|
| 81 |
+
`;
|
| 82 |
+
} catch (e) {
|
| 83 |
+
resultDiv.innerHTML = '<p>Error connecting to API. Please try again.</p>';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
btn.disabled = false;
|
| 87 |
+
btn.textContent = 'Explain Error';
|
| 88 |
+
}
|
| 89 |
+
</script>
|
| 90 |
+
</body>
|
| 91 |
+
</html>"""
|
| 92 |
|
| 93 |
+
@app.post("/explain")
|
| 94 |
+
async def explain(payload: dict):
|
| 95 |
+
log_text = payload.get("log_text", "")
|
| 96 |
+
return explain_error(log_text)
|
| 97 |
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
import uvicorn
|
| 100 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|