disable svg css agent by default (#3269)
This commit is contained in:
@@ -232,7 +232,9 @@ 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(
|
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"
|
prompt=svg_convert_prompt, step=step, prompt_name="svg-convert"
|
||||||
)
|
)
|
||||||
svg_shape = json_response.get("shape", "")
|
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):
|
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(
|
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"
|
prompt=prompt, screenshots=[screenshot], step=step, prompt_name="css-shape-convert"
|
||||||
)
|
)
|
||||||
css_shape = json_response.get("shape", "")
|
css_shape = json_response.get("shape", "")
|
||||||
@@ -569,7 +573,9 @@ class AgentFunction:
|
|||||||
LOG.warning(
|
LOG.warning(
|
||||||
f"Element reached max count {MAX_ELEMENT_CNT}, will stop converting svg and css element."
|
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:
|
if queue_ele.get("frame_index") != current_frame_index:
|
||||||
new_frame = next(
|
new_frame = next(
|
||||||
@@ -581,10 +587,10 @@ class AgentFunction:
|
|||||||
_remove_rect(queue_ele)
|
_remove_rect(queue_ele)
|
||||||
|
|
||||||
# Check SVG eligibility and store for later conversion
|
# 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))
|
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(
|
await _convert_css_shape_to_string(
|
||||||
skyvern_frame=skyvern_frame,
|
skyvern_frame=skyvern_frame,
|
||||||
element=queue_ele,
|
element=queue_ele,
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ EXTRACTION_LLM_API_HANDLER = (
|
|||||||
if SETTINGS_MANAGER.EXTRACTION_LLM_KEY
|
if SETTINGS_MANAGER.EXTRACTION_LLM_KEY
|
||||||
else LLM_API_HANDLER
|
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_CONTEXT_MANAGER = WorkflowContextManager()
|
||||||
WORKFLOW_SERVICE = WorkflowService()
|
WORKFLOW_SERVICE = WorkflowService()
|
||||||
AGENT_FUNCTION = AgentFunction()
|
AGENT_FUNCTION = AgentFunction()
|
||||||
|
|||||||
Reference in New Issue
Block a user