File size: 901 Bytes
597464a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import subprocess
import time
import gradio as gr

# Clone and build FreeLLMAPI if it doesn't exist
if not os.path.exists("freellmapi"):
    subprocess.run(["git", "clone", "https://github.com/tashfeenahmed/freellmapi.git", "freellmapi"])
    subprocess.run(["npm", "install"], cwd="freellmapi")
    subprocess.run(["npm", "run", "build"], cwd="freellmapi")

# Start FreeLLMAPI Node process on port 3000
env = os.environ.copy()
env["PORT"] = "3000"
env["NODE_ENV"] = "production"

process = subprocess.Popen(["npm", "start"], cwd="freellmapi", env=env)
time.sleep(5)

# Render simple Gradio dashboard wrapper
with gr.Blocks() as demo:
    gr.Markdown("# ⚡ FreeLLMAPI Gateway")
    gr.Markdown("Your OpenAI-compatible `/v1` endpoint is live on this Space's direct URL.")
    gr.HTML('<iframe src="http://localhost:3000" width="100%" height="750px"></iframe>')

demo.launch(server_port=7860)