Commit 5aa7a365 authored by nextime's avatar nextime

Improve response detection timing and add delay for Gemini

- Added 2-second delay before response detection to allow Gemini to finish generating
- Enhanced JavaScript fallback logic to better handle response waiting
- Improved timing for response detection to avoid returning setup acknowledgments
- Better synchronization between prompt sending and response detection
parent ca9b223c
......@@ -1278,6 +1278,9 @@ async def detect_progressive_response(page, container_selector, prompt, modified
except Exception as e:
logging.error(f"Failed to save HTML content: {e}")
# Add a small delay to allow Gemini to finish generating the response
await asyncio.sleep(2)
return await page.evaluate(
"""([containerSelector, prompt, modifiedPrompt, requestId, chatbotName]) => {
const container = document.querySelector(containerSelector);
......@@ -1402,6 +1405,10 @@ async def detect_progressive_response(page, container_selector, prompt, modified
}
}
}
// If no response found yet, wait a bit longer and try again
console.log(`No response found for request ID ${requestId}, waiting longer...`);
// This will cause the function to return undefined, triggering a retry
}
// Fallback to selector-based detection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment