diff options
| author | Gavin Mogan <github@gavinmogan.com> | 2025-02-16 09:10:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 17:10:52 +0000 |
| commit | 0621cd920a6461b46778fc5dfc1b02014c494517 (patch) | |
| tree | db31239c2d403fe097fa988b842cfe2a70d45b96 /packages/shared/customFetch.ts | |
| parent | 602e938d32ae2920e7928377cde11eee4de921dd (diff) | |
| download | karakeep-0621cd920a6461b46778fc5dfc1b02014c494517.tar.zst | |
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 <shane@barbetta.me>
Co-authored-by: Mohamed Bassem <me@mbassem.com>
Diffstat (limited to 'packages/shared/customFetch.ts')
| -rw-r--r-- | packages/shared/customFetch.ts | 13 |
1 files changed, 13 insertions, 0 deletions
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<typeof fetch>[0], + init?: Parameters<typeof fetch>[1], +): ReturnType<typeof fetch> { + const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds + return fetch(input, { + signal: AbortSignal.timeout(timeout), + ...init, + }); +} |
