Add Git Commit Agent UI
Browse files- index.html +90 -18
index.html
CHANGED
|
@@ -1,19 +1,91 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Developer Git Commit Agent</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: monospace; background-color: #121212; color: #ffffff; padding: 40px; margin: 0; }
|
| 9 |
+
.container { max-width: 800px; margin: 0 auto; }
|
| 10 |
+
h1 { border-bottom: 1px solid #333; padding-bottom: 10px; color: #00ff66; }
|
| 11 |
+
textarea { width: 100%; height: 200px; background-color: #1e1e1e; color: #00ff66; border: 1px solid #333; padding: 10px; font-family: monospace; box-sizing: border-box; resize: vertical; }
|
| 12 |
+
button { background-color: #00ff66; color: #121212; border: none; padding: 12px 20px; font-weight: bold; cursor: pointer; margin-top: 15px; width: 100%; font-family: monospace; }
|
| 13 |
+
button:hover { background-color: #00cc55; }
|
| 14 |
+
.output-box { margin-top: 30px; background-color: #1e1e1e; border-left: 4px solid #00ff66; padding: 15px; white-space: pre-wrap; display: none; }
|
| 15 |
+
.loading { color: #ffaa00; margin-top: 15px; display: none; }
|
| 16 |
+
</style>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
|
| 20 |
+
<div class="container">
|
| 21 |
+
<h1>🤖 Developer Git Commit Agent</h1>
|
| 22 |
+
<p>Paste your code adjustments or Git diff block below to generate a standardized commit message using the free serverless API.</p>
|
| 23 |
+
|
| 24 |
+
<textarea id="gitDiff" placeholder="Example: - const port = 3000; + const port = process.env.PORT || 5000;"></textarea>
|
| 25 |
+
|
| 26 |
+
<button onclick="generateCommit()">Generate Commit Message</button>
|
| 27 |
+
|
| 28 |
+
<div id="loadingStatus" class="loading">⚙️ Processing diff via Serverless Inference API (this can take a moment if the model is waking up)...</div>
|
| 29 |
+
<div id="outputBox" class="output-box"></div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<script>
|
| 33 |
+
async function generateCommit() {
|
| 34 |
+
// Configured automatically with your username
|
| 35 |
+
const MODEL_ID = "nivethitha1703/developer-git-commit-agent";
|
| 36 |
+
|
| 37 |
+
const diffText = document.getElementById("gitDiff").value;
|
| 38 |
+
const outputBox = document.getElementById("outputBox");
|
| 39 |
+
const loadingStatus = document.getElementById("loadingStatus");
|
| 40 |
+
|
| 41 |
+
if (!diffText.trim()) {
|
| 42 |
+
alert("Please paste a git diff first!");
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
outputBox.style.display = "none";
|
| 47 |
+
loadingStatus.style.display = "block";
|
| 48 |
+
|
| 49 |
+
// Construct the instruction format for your fine-tuned chat model
|
| 50 |
+
const prompt = `<|im_start|>system\nYou are an expert software engineer agent. Write a concise, professional Git commit message based on the provided code diff.<|im_end|>\n<|im_start|>user\nCode Diff:\n${diffText}<|im_end|>\n<|im_start|>assistant\n`;
|
| 51 |
+
|
| 52 |
+
try {
|
| 53 |
+
const response = await fetch(`https://huggingface.co{MODEL_ID}`, {
|
| 54 |
+
method: "POST",
|
| 55 |
+
headers: {
|
| 56 |
+
"Content-Type": "application/json"
|
| 57 |
+
},
|
| 58 |
+
body: JSON.stringify({
|
| 59 |
+
inputs: prompt,
|
| 60 |
+
parameters: { max_new_tokens: 60, temperature: 0.4 }
|
| 61 |
+
})
|
| 62 |
+
});
|
| 63 |
+
|
| 64 |
+
const data = await response.json();
|
| 65 |
+
loadingStatus.style.display = "none";
|
| 66 |
+
|
| 67 |
+
if (data.error) {
|
| 68 |
+
outputBox.innerText = "API Error: " + data.error;
|
| 69 |
+
} else if (Array.isArray(data) && data[0] && data[0].generated_text) {
|
| 70 |
+
let result = data[0].generated_text;
|
| 71 |
+
result = result.replace(prompt, "").trim();
|
| 72 |
+
outputBox.innerText = result;
|
| 73 |
+
} else if (data.generated_text) {
|
| 74 |
+
let result = data.generated_text;
|
| 75 |
+
result = result.replace(prompt, "").trim();
|
| 76 |
+
outputBox.innerText = result;
|
| 77 |
+
} else {
|
| 78 |
+
outputBox.innerText = JSON.stringify(data);
|
| 79 |
+
}
|
| 80 |
+
outputBox.style.display = "block";
|
| 81 |
+
|
| 82 |
+
} catch (error) {
|
| 83 |
+
loadingStatus.style.display = "none";
|
| 84 |
+
outputBox.innerText = "Error calling Inference API: " + error.message;
|
| 85 |
+
outputBox.style.display = "block";
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
</script>
|
| 89 |
+
|
| 90 |
+
</body>
|
| 91 |
</html>
|