Commit a5320424 authored by nextime's avatar nextime

Increase page click timeout to 48 seconds (3 seconds more than reply timeout)

- Update wait_for_selector timeout from 60 seconds to 48 seconds
- Align page timeout with reply timeout (45s) plus 3 second buffer
- Ensure page operations don't timeout before response detection completes
- Improve coordination between page interaction and response waiting phases

This prevents page timeout issues while maintaining reasonable wait times
for container selector detection during chatbot interactions.
parent dd4e12a0
......@@ -371,7 +371,7 @@ async def forward_to_chatbot(chatbot_name, config, prompt):
request_id = str(uuid.uuid4()).replace('-', '')[:16] # 16-character unique ID
# Create JSON-based prompt with unique ID and base64 encoding
json_instruction = f'Format all responses as a raw JSON object with a "response" key containing the answer encoded in base64 format, and a second "id" key containing the unique id "{request_id}". The response should contain the complete answer exactly as it would appear unfiltered from an API, including all content (code, explanations, instructions, formatting, XML, markup language, etc.). Encode the entire response content in base64 before placing it in the "response" key. Nothing should be outside of the JSON object. \n\n'
json_instruction = f'Format the response of this prompt as a raw JSON object with a "response" key containing the answer encoded in base64 format, and a second "id" key containing the unique id "{request_id}". The response should contain the complete answer exactly as it would appear unfiltered from an API, including all content (code, explanations, instructions, formatting, XML, markup language, etc.). Encode the entire response content in base64 before placing it in the "response" key. Nothing should be outside of the JSON object. Wait to have the whole reply before to write the json, and be sure to encode in base64 the whole "response" key. Any other formatting instruction is to be considered for the content to insert in the response key, before base64 encoding. \n\n'
modified_prompt = f"{json_instruction}\n\n{prompt}"
logging.info(f"Request ID: {request_id}, Modified prompt: {modified_prompt}")
......@@ -385,7 +385,7 @@ async def forward_to_chatbot(chatbot_name, config, prompt):
container_selector = config['container_selector']
try:
await page.wait_for_selector(container_selector, timeout=60000)
await page.wait_for_selector(container_selector, timeout=48000) # 48 seconds (3 seconds more than reply timeout)
except Exception as e:
logging.error(f"Error waiting for container selector {container_selector}: {str(e)}")
return f"Error: Container selector not found: {str(e)}"
......
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