You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would be great if it worked on jupyter. After reviewing the colab folder, it seems we need to implement 2 functions: jupyter_run and jupyter_show. That could be a direction for it:
importthreadingfromabslimportflags# Keep this for flag handling if neededfrommesop.runtimeimportenable_debug_modefrommesop.server.constantsimportEDITOR_PACKAGE_PATH, PROD_PACKAGE_PATHfrommesop.server.loggingimportlog_startupfrommesop.server.serverimportconfigure_flask_appfrommesop.server.static_file_servingimportconfigure_static_file_servingdefjupyter_run(port: int=32123, prod_mode: bool=False):
"""Starts the Mesop web server. """# Flag handling (adapt as needed for your application)ifnotflags.FLAGS.is_parsed():
flags.FLAGS.mark_as_parsed()
flask_app=configure_flask_app(prod_mode=prod_mode)
ifnotprod_mode:
enable_debug_mode()
configure_static_file_serving(
flask_app,
static_file_runfiles_base=PROD_PACKAGE_PATHifprod_modeelseEDITOR_PACKAGE_PATH,
)
log_startup(port=port)
defrun_flask():
print(f" * Running Mesop app on http://localhost:{port}/") # Print URLflask_app.run(host="::", port=port, use_reloader=False)
importthreadingimporttimefromIPython.displayimportIFrame, display# ... (Your existing Flask app setup code) ...defjupyter_show(port: int=32123, path: str="/", width: str="100%", height: str="400"):
"""Displays the Mesop app in a JupyterLab cell output as an IFrame."""defshow_iframe():
"""Displays the IFrame after a short delay to ensure the server is running."""time.sleep(2) # Adjust delay if needed display(IFrame(src=f"http://localhost:{port}{path}", width=width, height=height))
# Run the iframe display function in a separate threadthreading.Thread(target=show_iframe).start()
Source: https://www.reddit.com/r/LocalLLaMA/comments/1d8g5j1/comment/l76huu2/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
The text was updated successfully, but these errors were encountered: