Skip to content

Commit 80a271a

Browse files
committed
Increase LLM request timeout from 2 min to 5 min
Structure extraction on large documents can take longer than 2 minutes. Increase default timeout to 300s and make it configurable via the timeout option on OpenAICompatibleLLM.
1 parent 933b778 commit 80a271a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/llm-backends.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export class OpenAICompatibleLLM extends BaseLLM {
258258
readonly maxTokens: number;
259259
readonly temperature: number;
260260
readonly extraHeaders: Record<string, string>;
261+
readonly timeout: number;
261262

262263
constructor(options: {
263264
baseUrl: string;
@@ -266,6 +267,7 @@ export class OpenAICompatibleLLM extends BaseLLM {
266267
maxTokens?: number;
267268
temperature?: number;
268269
extraHeaders?: Record<string, string>;
270+
timeout?: number;
269271
}) {
270272
super();
271273
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
@@ -274,6 +276,7 @@ export class OpenAICompatibleLLM extends BaseLLM {
274276
this.maxTokens = options.maxTokens ?? 4096;
275277
this.temperature = options.temperature ?? 0.0;
276278
this.extraHeaders = options.extraHeaders ?? {};
279+
this.timeout = options.timeout ?? 300_000;
277280
}
278281

279282
private buildHeaders(): Record<string, string> {
@@ -302,7 +305,7 @@ export class OpenAICompatibleLLM extends BaseLLM {
302305
method: "POST",
303306
headers: this.buildHeaders(),
304307
body: JSON.stringify(payload),
305-
signal: AbortSignal.timeout(120_000),
308+
signal: AbortSignal.timeout(this.timeout),
306309
});
307310

308311
if (!resp.ok) {
@@ -524,7 +527,7 @@ export class HuggingFaceLLM extends BaseLLM {
524527
Authorization: `Bearer ${this.apiKey}`,
525528
},
526529
body: JSON.stringify(payload),
527-
signal: AbortSignal.timeout(120_000),
530+
signal: AbortSignal.timeout(300_000),
528531
});
529532

530533
if (!resp.ok) {
@@ -579,7 +582,7 @@ export class OllamaLLM extends BaseLLM {
579582
"User-Agent": "TreeDex/0.1",
580583
},
581584
body: JSON.stringify(payload),
582-
signal: AbortSignal.timeout(120_000),
585+
signal: AbortSignal.timeout(300_000),
583586
});
584587

585588
if (!resp.ok) {

0 commit comments

Comments
 (0)