Spaces:
Runtime error
Runtime error
Download app.py from MirzaTech/emaaa-llm-proxy-002: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/MirzaTech/emaaa-llm-proxy-002/resolve/main/app.py
- Command line
-
hf download hf://spaces/MirzaTech/emaaa-llm-proxy-002/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MirzaTech/emaaa-llm-proxy-002/resolve/main/app.py
1.03 kB
| 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() | |