@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
33import { mkdir , rename , writeFile } from "node:fs/promises" ;
44import { dirname } from "node:path" ;
55import { promisify } from "node:util" ;
6+ import { fetchJson } from "@openmapx/core" ;
67import { isPrivateEndpoint } from "../provider-config.js" ;
78import { SEMANTIC_DIMENSIONS , SEMANTIC_MODEL } from "../semantic-taxonomy-types.js" ;
89
@@ -11,6 +12,7 @@ export const MAX_CONTAINER_LIMIT_BYTES = 8 * 1024 ** 3;
1112export const MINIMUM_HEADROOM_BYTES = 1024 ** 3 ;
1213const MINIMUM_ROUNDS = 5 ;
1314const EVIDENCE_MAX_AGE_MS = 24 * 60 * 60 * 1_000 ;
15+ const OLLAMA_REQUEST_TIMEOUT_MS = 2 * 60_000 ;
1416const EMBEDDING_PROMPT = "Instruct: classify a generic map request\nQuery: a quiet place to read" ;
1517const PARSER_PROMPT = "Return a short JSON object for a generic map search for a library." ;
1618
@@ -186,10 +188,22 @@ export function parseDockerStatsMemory(input: string): number {
186188 return bytes ;
187189}
188190
189- async function jsonRequest ( endpoint : string , path : string , init ?: RequestInit ) : Promise < unknown > {
190- const response = await fetch ( `${ endpoint } ${ path } ` , init ) ;
191- if ( ! response . ok ) throw new Error ( `Ollama request failed with HTTP ${ response . status } ` ) ;
192- return response . json ( ) as Promise < unknown > ;
191+ interface OllamaJsonRequestInit {
192+ method : string ;
193+ headers : Record < string , string > ;
194+ body : string ;
195+ }
196+
197+ async function jsonRequest (
198+ endpoint : string ,
199+ path : string ,
200+ init ?: OllamaJsonRequestInit ,
201+ ) : Promise < unknown > {
202+ return fetchJson < unknown > ( `${ endpoint } ${ path } ` , {
203+ label : "Ollama" ,
204+ timeoutMs : OLLAMA_REQUEST_TIMEOUT_MS ,
205+ ...( init ? { headers : init . headers , init : { method : init . method , body : init . body } } : { } ) ,
206+ } ) ;
193207}
194208
195209function residentModels (
0 commit comments