Add Ollama setup helpers and database backup
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user