with open('app.py', 'r') as f: content = f.read() # 1. Fix the Gradio 6.0 warnings # `with gr.Blocks(title="...", theme=gr.themes.Soft(...), css=css) as demo:` import re content = re.sub(r'with gr\.Blocks\([^)]+\) as demo:', 'with gr.Blocks(title="Stock Forecasting Backtest Platform") as demo:', content) # Update demo.launch() content = content.replace('demo.launch()', 'demo.launch(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="slate"), css=css)') # 2. Fix update_model_info # It should accept custom_repo, or we should just remove the injected logic from update_model_info and let it accept (model_keys, custom_repo) # The inputs to update_model_info change from `inputs=model_dropdown` to `inputs=[model_dropdown, custom_repo_input]` old_update_sig = "def update_model_info(model_keys):" new_update_sig = "def update_model_info(model_keys, custom_repo=\"\"):" content = content.replace(old_update_sig, new_update_sig) # Update the UI binding for update_model_info old_change = "model_dropdown.change(fn=update_model_info, inputs=model_dropdown, outputs=model_info_md)" new_change = "model_dropdown.change(fn=update_model_info, inputs=[model_dropdown, custom_repo_input], outputs=model_info_md)\\n custom_repo_input.change(fn=update_model_info, inputs=[model_dropdown, custom_repo_input], outputs=model_info_md)" content = content.replace(old_change, new_change) # Also fix the initial call in the UI old_init = 'model_info_md = gr.HTML(update_model_info("google-research/timesfm"))' new_init = 'model_info_md = gr.HTML(update_model_info(["google-research/timesfm"], ""))' content = content.replace(old_init, new_init) with open('app.py', 'w') as f: f.write(content)