Spaces:
Runtime error

File size: 1,029 Bytes
1fc34dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os, requests, gradio as gr
HF_TOKEN = os.environ.get("HF_TOKEN", "")
ROUTER_URL = "https://router.huggingface.co/v1/chat/completions"
def chat(message, history, model_id):
    if not HF_TOKEN: return "HF_TOKEN secret not set"
    payload = {"model": model_id, "messages": [{"role":"user","content":message}], "max_tokens": 1024}
    r = requests.post(ROUTER_URL, json=payload, headers={"Authorization": f"Bearer {HF_TOKEN}"}, timeout=60)
    if r.status_code == 200:
        j = r.json(); m = j["choices"][0]["message"]
        return m.get("content") or m.get("reasoning") or "(empty)"
    return f"upstream {r.status_code}: {r.text[:300]}"
with gr.Blocks(title="Emaaa LLM Proxy 002 (MirzaTech)") as demo:
    gr.Markdown("# Emaaa LLM Proxy 002
Empire-controlled HF Router gateway · MirzaTech account · per Mo vision principle 4")
    model = gr.Textbox(label="Model", value="meta-llama/Llama-3.3-70B-Instruct:cerebras")
    gr.ChatInterface(fn=chat, additional_inputs=[model])
if __name__ == "__main__": demo.launch()