Spaces:
Sleeping
Sleeping
Commit ·
b08debc
1
Parent(s): c04b8c5
working version
Browse files- src/lib/ai-client.ts +16 -2
src/lib/ai-client.ts
CHANGED
|
@@ -24,6 +24,11 @@ export async function callAIEngine<T = unknown>(
|
|
| 24 |
const url = `${AI_ENGINE_URL}${endpoint}`;
|
| 25 |
const timeout = options?.timeout || 30000;
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
try {
|
| 28 |
const controller = new AbortController();
|
| 29 |
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
@@ -40,8 +45,17 @@ export async function callAIEngine<T = unknown>(
|
|
| 40 |
clearTimeout(timeoutId);
|
| 41 |
|
| 42 |
if (!response.ok) {
|
| 43 |
-
const
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
|
| 47 |
const data = await response.json();
|
|
|
|
| 24 |
const url = `${AI_ENGINE_URL}${endpoint}`;
|
| 25 |
const timeout = options?.timeout || 30000;
|
| 26 |
|
| 27 |
+
// Check if AI engine URL is configured
|
| 28 |
+
if (!AI_ENGINE_URL || AI_ENGINE_URL === "http://localhost:7860") {
|
| 29 |
+
console.warn("AI_ENGINE_URL not configured or using default. Make sure AI engine is running.");
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
try {
|
| 33 |
const controller = new AbortController();
|
| 34 |
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
|
|
| 45 |
clearTimeout(timeoutId);
|
| 46 |
|
| 47 |
if (!response.ok) {
|
| 48 |
+
const errorText = await response.text();
|
| 49 |
+
console.error(`AI Engine error [${response.status}]:`, errorText);
|
| 50 |
+
|
| 51 |
+
if (response.status === 503 || response.status === 502) {
|
| 52 |
+
return {
|
| 53 |
+
success: false,
|
| 54 |
+
error: `AI service unavailable (${response.status}). The AI engine may not be running. Check if the service is started.`
|
| 55 |
+
};
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
return { success: false, error: `AI Engine error: ${response.status} - ${errorText}` };
|
| 59 |
}
|
| 60 |
|
| 61 |
const data = await response.json();
|