23 lines
581 B
JavaScript
23 lines
581 B
JavaScript
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() };
|
|
}
|
|
}
|