From fd42422d6c981f7a5205f639a80b5dc6b2310c2d Mon Sep 17 00:00:00 2001 From: Anuraag Jain Date: Sat, 6 Jan 2024 15:01:47 +0200 Subject: [PATCH] refac: pullModel api --- src/lib/apis/ollama/index.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts index 10eddc1c1..5b0f98705 100644 --- a/src/lib/apis/ollama/index.ts +++ b/src/lib/apis/ollama/index.ts @@ -249,8 +249,7 @@ export const deleteModel = async (token: string, tagName: string) => { }; export const pullModel = async (token: string, tagName: string) => { - let error = null; - +try { const res = await fetch(`${OLLAMA_API_BASE_URL}/pull`, { method: 'POST', headers: { @@ -260,14 +259,9 @@ export const pullModel = async (token: string, tagName: string) => { body: JSON.stringify({ name: tagName }) - }).catch((err) => { - error = err; - return null; - }); - - if (error) { - throw error; - } - + }) return res; +} catch (error) { + throw error; +} };