Forráskód Böngészése

refac: pullModel api

Anuraag Jain 1 éve
szülő
commit
fd42422d6c
1 módosított fájl, 5 hozzáadás és 11 törlés
  1. 5 11
      src/lib/apis/ollama/index.ts

+ 5 - 11
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;
+}
 };