Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files
app/api/generate-ai-code-stream/route.ts
CHANGED
|
@@ -1282,8 +1282,6 @@ It's better to have 3 complete files than 10 incomplete files.`
|
|
| 1282 |
} catch (streamError: any) {
|
| 1283 |
console.error(`[generate-ai-code-stream] Error calling streamText (attempt ${retryCount + 1}/${maxRetries + 1}):`, streamError);
|
| 1284 |
|
| 1285 |
-
// Check if this is a Groq service unavailable error
|
| 1286 |
-
const isGroqServiceError = isKimiGroq && streamError.message?.includes('Service unavailable');
|
| 1287 |
const isRetryableError = streamError.message?.includes('Service unavailable') ||
|
| 1288 |
streamError.message?.includes('rate limit') ||
|
| 1289 |
streamError.message?.includes('timeout');
|
|
@@ -1301,12 +1299,6 @@ It's better to have 3 complete files than 10 incomplete files.`
|
|
| 1301 |
// Wait before retry with exponential backoff
|
| 1302 |
await new Promise(resolve => setTimeout(resolve, retryCount * 2000));
|
| 1303 |
|
| 1304 |
-
// If Groq fails, try switching to a fallback model
|
| 1305 |
-
if (isGroqServiceError && retryCount === maxRetries) {
|
| 1306 |
-
console.log('[generate-ai-code-stream] Groq service unavailable, falling back to GPT-4');
|
| 1307 |
-
streamOptions.model = openai('gpt-4-turbo');
|
| 1308 |
-
actualModel = 'gpt-4-turbo';
|
| 1309 |
-
}
|
| 1310 |
} else {
|
| 1311 |
// Final error, send to user
|
| 1312 |
await sendProgress({
|
|
|
|
| 1282 |
} catch (streamError: any) {
|
| 1283 |
console.error(`[generate-ai-code-stream] Error calling streamText (attempt ${retryCount + 1}/${maxRetries + 1}):`, streamError);
|
| 1284 |
|
|
|
|
|
|
|
| 1285 |
const isRetryableError = streamError.message?.includes('Service unavailable') ||
|
| 1286 |
streamError.message?.includes('rate limit') ||
|
| 1287 |
streamError.message?.includes('timeout');
|
|
|
|
| 1299 |
// Wait before retry with exponential backoff
|
| 1300 |
await new Promise(resolve => setTimeout(resolve, retryCount * 2000));
|
| 1301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1302 |
} else {
|
| 1303 |
// Final error, send to user
|
| 1304 |
await sendProgress({
|