Spaces:
Running
Running
| import streamlit as st, os, requests, json | |
| st.set_page_config(page_title="Router Diagnostics", page_icon="π§ͺ", layout="wide") | |
| st.title("π Router Text-Generation Diagnostics") | |
| endpoint = st.text_input("Endpoint", os.getenv("HF_CHAT_ENDPOINT") or "https://router.huggingface.co/openai/gpt-oss-120b") | |
| token = st.text_input("HF API Token (optional; else use env)", os.getenv("HF_API_TOKEN") or os.getenv("HF_TOKEN") or "", type="password") | |
| prompt = st.text_area("Prompt", "ping") | |
| if st.button("Ping"): | |
| try: | |
| r = requests.post(endpoint, headers={"Authorization": f"Bearer {token or os.getenv('HF_API_TOKEN') or os.getenv('HF_TOKEN')}","Content-Type":"application/json"}, json={"inputs": prompt, "parameters": {"max_new_tokens": 64}}, timeout=60) | |
| st.subheader("Status / headers") | |
| st.code(f"{r.status_code}\n{dict(r.headers)}") | |
| try: | |
| st.subheader("JSON") | |
| st.json(r.json()) | |
| except Exception: | |
| st.subheader("Raw text") | |
| st.code(r.text[:2000]) | |
| except Exception as e: | |
| st.error(e) | |