fix svg css llm call timeout bug (#2670)
This commit is contained in:
@@ -213,7 +213,7 @@ async def _convert_svg_to_string(
|
|||||||
|
|
||||||
for retry in range(SVG_SHAPE_CONVERTION_ATTEMPTS):
|
for retry in range(SVG_SHAPE_CONVERTION_ATTEMPTS):
|
||||||
try:
|
try:
|
||||||
async with asyncio.Timeout(_LLM_CALL_TIMEOUT_SECONDS):
|
async with asyncio.timeout(_LLM_CALL_TIMEOUT_SECONDS):
|
||||||
json_response = await app.SECONDARY_LLM_API_HANDLER(
|
json_response = await app.SECONDARY_LLM_API_HANDLER(
|
||||||
prompt=svg_convert_prompt, step=step, prompt_name="svg-convert"
|
prompt=svg_convert_prompt, step=step, prompt_name="svg-convert"
|
||||||
)
|
)
|
||||||
@@ -240,11 +240,12 @@ async def _convert_svg_to_string(
|
|||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Timeout to call LLM to parse SVG. Going to stop retrying",
|
"Timeout to call LLM to parse SVG. Going to drop the svg element directly.",
|
||||||
element_id=element_id,
|
element_id=element_id,
|
||||||
key=svg_key,
|
key=svg_key,
|
||||||
)
|
)
|
||||||
break
|
_mark_element_as_dropped(element)
|
||||||
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Failed to convert SVG to string shape by secondary llm. Will retry if haven't met the max try attempt after 3s.",
|
"Failed to convert SVG to string shape by secondary llm. Will retry if haven't met the max try attempt after 3s.",
|
||||||
@@ -367,7 +368,7 @@ async def _convert_css_shape_to_string(
|
|||||||
# TODO: we don't retry the css shape conversion today
|
# TODO: we don't retry the css shape conversion today
|
||||||
for retry in range(CSS_SHAPE_CONVERTION_ATTEMPTS):
|
for retry in range(CSS_SHAPE_CONVERTION_ATTEMPTS):
|
||||||
try:
|
try:
|
||||||
async with asyncio.Timeout(_LLM_CALL_TIMEOUT_SECONDS):
|
async with asyncio.timeout(_LLM_CALL_TIMEOUT_SECONDS):
|
||||||
json_response = await app.SECONDARY_LLM_API_HANDLER(
|
json_response = await app.SECONDARY_LLM_API_HANDLER(
|
||||||
prompt=prompt, screenshots=[screenshot], step=step, prompt_name="css-shape-convert"
|
prompt=prompt, screenshots=[screenshot], step=step, prompt_name="css-shape-convert"
|
||||||
)
|
)
|
||||||
@@ -394,11 +395,11 @@ async def _convert_css_shape_to_string(
|
|||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Timeout to call LLM to parse css shape. Going to stop retrying",
|
"Timeout to call LLM to parse css shape. Going to abort the convertion directly.",
|
||||||
element_id=element_id,
|
element_id=element_id,
|
||||||
key=shape_key,
|
key=shape_key,
|
||||||
)
|
)
|
||||||
break
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Failed to convert css shape to string shape by secondary llm. Will retry if haven't met the max try attempt after 3s.",
|
"Failed to convert css shape to string shape by secondary llm. Will retry if haven't met the max try attempt after 3s.",
|
||||||
|
|||||||
Reference in New Issue
Block a user