From 0621cd920a6461b46778fc5dfc1b02014c494517 Mon Sep 17 00:00:00 2001 From: Gavin Mogan Date: Sun, 16 Feb 2025 09:10:52 -0800 Subject: fix: custom fetch wrapper for ollama inference. Fixes #656 (#1032) * Add configurable fetch timeout for Ollama client * Worker service needs access to the .env file * repair typescript types * Update customFetch.ts * update the config docs --------- Co-authored-by: sbarbett Co-authored-by: Mohamed Bassem --- packages/shared/customFetch.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 packages/shared/customFetch.ts (limited to 'packages/shared/customFetch.ts') diff --git a/packages/shared/customFetch.ts b/packages/shared/customFetch.ts new file mode 100644 index 00000000..e9ac8a89 --- /dev/null +++ b/packages/shared/customFetch.ts @@ -0,0 +1,13 @@ +import serverConfig from "./config"; + +// Custom fetch function with configurable timeout +export function customFetch( + input: Parameters[0], + init?: Parameters[1], +): ReturnType { + const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds + return fetch(input, { + signal: AbortSignal.timeout(timeout), + ...init, + }); +} -- cgit v1.2.3-70-g09d2