import asyncio import base64 from io import BytesIO import streamlit as st from PIL import Image from proxy_lite import Runner, RunnerConfig def get_user_config(config_expander): config = { "environment": { "name": "webbrowser", "annotate_image": True, "screenshot_delay": 2.0, "include_html": False, "viewport_width": 1280, "viewport_height": 1920, "include_poi_text": True, "homepage": "https://dwd000006jia1mae.lightning.force.com/lightning/setup/AccountForecastSettings/home", "keep_original_image": False, "headless": False, # without proxies headless mode often results in getting bot blocked }, "solver": { "name": "simple", "agent": { "name": "proxy_lite", "client": { "name": "convergence", "model_id": "convergence-ai/proxy-lite-3b", "api_base": "https://convergence-ai-demo-api.hf.space/v1", }, }, }, "local_view": False, "verbose": True, "task_timeout": 1800, # 30 minutes "action_timeout": 300, "environment_timeout": 120, } with config_expander: st.subheader("Environment Settings") col1, col2 = st.columns(2) with col1: config["environment"]["include_html"] = st.checkbox( "Include HTML", value=config["environment"]["include_html"], help="Include HTML in observations", ) config["environment"]["include_poi_text"] = st.checkbox( "Include POI Text", value=config["environment"]["include_poi_text"], help="Include points of interest text in observations", ) config["environment"]["homepage"] = st.text_input( "Homepage", value=config["environment"]["homepage"], help="Homepage to start from", ) with col2: config["solver"]["agent"]["client"]["api_base"] = st.text_input( "VLLM Server URL", value=config["solver"]["agent"]["client"]["api_base"], help="URL of a vllm server running proxy-lite", ) config["environment"]["screenshot_delay"] = st.slider( "Screenshot Delay (seconds)", min_value=0.5, max_value=10.0, value=config["environment"]["screenshot_delay"], step=0.5, help="Delay before taking screenshots", ) st.subheader("Advanced Settings") config["task_timeout"] = st.number_input( "Task Timeout (seconds)", min_value=60, max_value=3600, step=60, value=config["task_timeout"], help="Maximum time allowed for task completion", ) config["action_timeout"] = st.number_input( "Action Timeout (seconds)", min_value=10, max_value=300, step=10, value=config["action_timeout"], help="Maximum time allowed for an action to complete", ) config["environment_timeout"] = st.number_input( "Environment Timeout (seconds)", min_value=10, max_value=300, step=10, value=config["environment_timeout"], help="Maximum time allowed for environment to respond", ) return config async def run_task_async( task: str, status_placeholder, action_placeholder, environment_placeholder, image_placeholder, history_placeholder, config: dict, ): try: config = RunnerConfig.from_dict(config) except Exception as e: st.error(f"Error loading RunnerConfig: {e!s}") return print(config) runner = Runner(config=config) # Add the spinning animation using HTML status_placeholder.markdown( """