fix(admin): trend chart height 100px, logs 3-column layout, KPI cards clickable links, AI timeout 120s env var, X/Pinterest settings
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { AppError } from './errors.js';
|
||||
|
||||
/** Default AI timeout: 2 minutes for complex product descriptions */
|
||||
const AI_TIMEOUT_MS = Number.parseInt(process.env.AI_TIMEOUT_MS ?? '120000', 10);
|
||||
|
||||
/**
|
||||
* Shared helpers for AI content generation (OpenAI-compatible chat API)
|
||||
* and HTML formatting of the generated text.
|
||||
@@ -15,7 +18,7 @@ export async function generateWithModel(
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ model, messages: [{ role: 'user', content: prompt }], temperature: 0.4 }),
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
signal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
||||
});
|
||||
const payload = (await response.json().catch(() => null)) as {
|
||||
choices?: Array<{ message?: { content?: unknown } }>;
|
||||
|
||||
Reference in New Issue
Block a user