Modularization, some rudimentary cleanup

This commit is contained in:
2026-01-24 03:05:34 +01:00
parent 02d32352d6
commit aaedf7fc15
3 changed files with 124 additions and 154 deletions

22
run-prompt.mjs Normal file
View File

@@ -0,0 +1,22 @@
export async function run_prompt(system_prompt, model, pieces, options = { num_ctx: 16384 }) {
const payload = {
model,
messages: [
{ role: 'system', content: system_prompt }, ...pieces
],
stream: false,
options,
};
const response = await fetch('http://localhost:11434/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (response.ok) {
return { status: response.status, response: await response.json() };
} else {
return { status: response.status, error: await response.text() };
}
}