Split custom world generation into staged lightweight batches
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
This commit is contained in:
@@ -18,6 +18,13 @@ export class LlmConnectivityError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export class LlmTimeoutError extends LlmConnectivityError {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'LlmTimeoutError';
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveTimeoutMs(rawValue: string | undefined, fallback: number) {
|
||||
const parsed = Number(rawValue);
|
||||
return Number.isFinite(parsed) && parsed > 0 ? Math.round(parsed) : fallback;
|
||||
@@ -26,7 +33,7 @@ export function resolveTimeoutMs(rawValue: string | undefined, fallback: number)
|
||||
export const REQUEST_TIMEOUT_MS = resolveTimeoutMs(ENV.VITE_LLM_REQUEST_TIMEOUT_MS, 15000);
|
||||
export const CUSTOM_WORLD_REQUEST_TIMEOUT_MS = resolveTimeoutMs(
|
||||
ENV.VITE_LLM_CUSTOM_WORLD_TIMEOUT_MS,
|
||||
Math.max(REQUEST_TIMEOUT_MS, 45000),
|
||||
Math.max(REQUEST_TIMEOUT_MS, 120000),
|
||||
);
|
||||
|
||||
function logLlmDebug(title: string, payload: unknown) {
|
||||
@@ -39,7 +46,7 @@ function logLlmDebug(title: string, payload: unknown) {
|
||||
|
||||
function normalizeLlmError(error: unknown): never {
|
||||
if (error instanceof DOMException && error.name === 'AbortError') {
|
||||
throw new LlmConnectivityError('The LLM request timed out. Please check the network or endpoint.');
|
||||
throw new LlmTimeoutError('The LLM request timed out. Please check the network or endpoint.');
|
||||
}
|
||||
|
||||
if (error instanceof TypeError) {
|
||||
@@ -53,6 +60,10 @@ export function isLlmConnectivityError(error: unknown): error is LlmConnectivity
|
||||
return error instanceof LlmConnectivityError;
|
||||
}
|
||||
|
||||
export function isLlmTimeoutError(error: unknown): error is LlmTimeoutError {
|
||||
return error instanceof LlmTimeoutError;
|
||||
}
|
||||
|
||||
async function requestMessageContent(
|
||||
systemPrompt: string,
|
||||
userPrompt: string,
|
||||
|
||||
Reference in New Issue
Block a user