diff --git a/src/handlers/ollama.ts b/src/handlers/ollama.ts index 9630b9b..58d56bf 100644 --- a/src/handlers/ollama.ts +++ b/src/handlers/ollama.ts @@ -114,6 +114,12 @@ export async function OllamaHandler( const res = await getOllamaResponse(model, prompt, baseUrl); + if (!res.ok) { + throw new Error( + `Recieved an error with code ${res.status} from Ollama API.`, + ); + } + if (params.stream) { return iterateResponse(res, model, prompt); } diff --git a/src/handlers/ollamaEmbedding.ts b/src/handlers/ollamaEmbedding.ts index 349a0d0..3a9ba17 100644 --- a/src/handlers/ollamaEmbedding.ts +++ b/src/handlers/ollamaEmbedding.ts @@ -30,6 +30,12 @@ export async function OllamaEmbeddingHandler( const model = params.model.split('ollama/')[1]; const baseUrl = params.baseUrl ?? 'http://127.0.0.1:11434'; const response = await getOllamaResponse(model, params.input, baseUrl); + + if (!response.ok) { + throw new Error( + `Recieved an error with code ${response.status} from Ollama API.`, + ); + } const body = (await response.json()) as OllamaEmbeddingsResponseChunk; return {