Modularization, some rudimentary cleanup
This commit is contained in:
22
run-prompt.mjs
Normal file
22
run-prompt.mjs
Normal 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() };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user