Add Ollama setup helpers and database backup

This commit is contained in:
2026-03-23 14:27:53 -04:00
parent 3bc8550f12
commit 28c5ad959f
8 changed files with 167 additions and 4 deletions

View File

@@ -71,6 +71,31 @@ export async function getOllamaStatus(): Promise<OllamaStatus> {
}
}
export async function pullConfiguredOllamaModel() {
const { baseUrl, model } = getOllamaConfig();
let response: Response;
try {
response = await fetch(`${baseUrl}/api/pull`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model, stream: false }),
});
} catch {
throw new OllamaUnavailableError("Ollama is not reachable at the configured URL.");
}
if (!response.ok) {
throw new OllamaUnavailableError(`Ollama pull failed with status ${response.status}.`);
}
return {
model,
message: `${model} is available for offline use.`,
};
}
export async function generateOllamaJson<T>({ prompt, model }: GenerateJsonInput): Promise<T> {
const { baseUrl, model: configuredModel } = getOllamaConfig();
const selectedModel = model ?? configuredModel;