disable svg css agent by default (#3269)

This commit is contained in:
LawyZheng
2025-08-22 13:54:04 +08:00
committed by GitHub
parent 675992aa95
commit b78fff647a
2 changed files with 13 additions and 5 deletions

View File

@@ -232,7 +232,9 @@ async def _convert_svg_to_string(
for retry in range(SVG_SHAPE_CONVERTION_ATTEMPTS):
try:
async with asyncio.timeout(_LLM_CALL_TIMEOUT_SECONDS):
json_response = await app.SECONDARY_LLM_API_HANDLER(
if app.SVG_CSS_CONVERTER_LLM_API_HANDLER is None:
raise Exception("To enable svg shape conversion, please set the Secondary LLM key")
json_response = await app.SVG_CSS_CONVERTER_LLM_API_HANDLER(
prompt=svg_convert_prompt, step=step, prompt_name="svg-convert"
)
svg_shape = json_response.get("shape", "")
@@ -390,7 +392,9 @@ async def _convert_css_shape_to_string(
for retry in range(CSS_SHAPE_CONVERTION_ATTEMPTS):
try:
async with asyncio.timeout(_LLM_CALL_TIMEOUT_SECONDS):
json_response = await app.SECONDARY_LLM_API_HANDLER(
if app.SVG_CSS_CONVERTER_LLM_API_HANDLER is None:
raise Exception("To enable css shape conversion, please set the Secondary LLM key")
json_response = await app.SVG_CSS_CONVERTER_LLM_API_HANDLER(
prompt=prompt, screenshots=[screenshot], step=step, prompt_name="css-shape-convert"
)
css_shape = json_response.get("shape", "")
@@ -569,7 +573,9 @@ class AgentFunction:
LOG.warning(
f"Element reached max count {MAX_ELEMENT_CNT}, will stop converting svg and css element."
)
element_exceeded = element_cnt > MAX_ELEMENT_CNT
disable_conversion = element_cnt > MAX_ELEMENT_CNT
if app.SVG_CSS_CONVERTER_LLM_API_HANDLER is None:
disable_conversion = True
if queue_ele.get("frame_index") != current_frame_index:
new_frame = next(
@@ -581,10 +587,10 @@ class AgentFunction:
_remove_rect(queue_ele)
# Check SVG eligibility and store for later conversion
if await _check_svg_eligibility(skyvern_frame, queue_ele, task, step, always_drop=element_exceeded):
if await _check_svg_eligibility(skyvern_frame, queue_ele, task, step, always_drop=disable_conversion):
eligible_svgs.append((queue_ele, skyvern_frame))
if not element_exceeded and _should_css_shape_convert(element=queue_ele):
if not disable_conversion and _should_css_shape_convert(element=queue_ele):
await _convert_css_shape_to_string(
skyvern_frame=skyvern_frame,
element=queue_ele,

View File

@@ -79,6 +79,8 @@ EXTRACTION_LLM_API_HANDLER = (
if SETTINGS_MANAGER.EXTRACTION_LLM_KEY
else LLM_API_HANDLER
)
SVG_CSS_CONVERTER_LLM_API_HANDLER = SECONDARY_LLM_API_HANDLER if SETTINGS_MANAGER.SECONDARY_LLM_KEY else None
WORKFLOW_CONTEXT_MANAGER = WorkflowContextManager()
WORKFLOW_SERVICE = WorkflowService()
AGENT_FUNCTION = AgentFunction()