mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
fix(daemon): extend OpenAI image request timeouts (#788)
This commit is contained in:
parent
324b20ad81
commit
84ac93c945
3 changed files with 13 additions and 1 deletions
|
|
@ -41,7 +41,8 @@
|
|||
"chokidar": "^5.0.0",
|
||||
"express": "^4.19.2",
|
||||
"jszip": "^3.10.1",
|
||||
"multer": "^1.4.5-lts.1"
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"undici": "^7.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import { execFile as execFileCb, spawn } from 'node:child_process';
|
|||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { Agent as UndiciAgent } from 'undici';
|
||||
import {
|
||||
AUDIO_DURATIONS_SEC,
|
||||
VIDEO_LENGTHS_SEC,
|
||||
|
|
@ -516,6 +517,12 @@ function defaultAspectFor(surface) {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
const AZURE_DEFAULT_API_VERSION = '2024-02-01';
|
||||
const OPENAI_IMAGE_HEADERS_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
const OPENAI_IMAGE_BODY_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
const openAIImageDispatcher = new UndiciAgent({
|
||||
headersTimeout: OPENAI_IMAGE_HEADERS_TIMEOUT_MS,
|
||||
bodyTimeout: OPENAI_IMAGE_BODY_TIMEOUT_MS,
|
||||
});
|
||||
|
||||
async function renderOpenAIImage(ctx, credentials) {
|
||||
if (!credentials.apiKey) {
|
||||
|
|
@ -562,6 +569,7 @@ async function renderOpenAIImage(ctx, credentials) {
|
|||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify(body),
|
||||
dispatcher: openAIImageDispatcher,
|
||||
});
|
||||
const text = await resp.text();
|
||||
if (!resp.ok) {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ importers:
|
|||
multer:
|
||||
specifier: ^1.4.5-lts.1
|
||||
version: 1.4.5-lts.2
|
||||
undici:
|
||||
specifier: ^7.16.0
|
||||
version: 7.25.0
|
||||
devDependencies:
|
||||
'@types/better-sqlite3':
|
||||
specifier: ^7.6.13
|
||||
|
|
|
|||
Loading…
Reference in a new issue