| import os | |
| import sys | |
| # --------------------------------------------------------- | |
| # Unsloth Studio environment | |
| # --------------------------------------------------------- | |
| os.environ.setdefault( | |
| "UNSLOTH_STUDIO_HOME", | |
| "/tmp/unsloth_studio", | |
| ) | |
| os.makedirs( | |
| os.environ["UNSLOTH_STUDIO_HOME"], | |
| exist_ok=True, | |
| ) | |
| # --------------------------------------------------------- | |
| # Import the REAL Unsloth Studio FastAPI application | |
| # --------------------------------------------------------- | |
| from studio.backend.main import app as studio_app | |
| # --------------------------------------------------------- | |
| # Gradio | |
| # --------------------------------------------------------- | |
| import gradio as gr | |
| with gr.Blocks(title="Unsloth Studio") as demo: | |
| gr.Markdown( | |
| """ | |
| # 🦥 Unsloth Studio | |
| Full Unsloth Studio running inside a Hugging Face Space. | |
| """ | |
| ) | |
| # --------------------------------------------------------- | |
| # Mount Studio into Gradio | |
| # --------------------------------------------------------- | |
| demo.app = studio_app | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run( | |
| studio_app, | |
| host="0.0.0.0", | |
| port=7860, | |
| ) |