Spaces:
Running
Running
Delete miniapp.py
Browse files- miniapp.py +0 -71
miniapp.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
import datetime
|
| 2 |
-
from urllib.parse import urlparse
|
| 3 |
-
|
| 4 |
-
import gradio as gr
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
APP_NAME = "miniapp"
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def _is_valid_http_url(url: str) -> bool:
|
| 11 |
-
try:
|
| 12 |
-
parsed = urlparse(url)
|
| 13 |
-
return parsed.scheme in ("http", "https") and bool(parsed.netloc)
|
| 14 |
-
except Exception:
|
| 15 |
-
return False
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def submit(model_name: str, model_api: str, notes: str):
|
| 19 |
-
model_name = (model_name or "").strip()
|
| 20 |
-
model_api = (model_api or "").strip()
|
| 21 |
-
notes = (notes or "").strip()
|
| 22 |
-
|
| 23 |
-
if not model_name:
|
| 24 |
-
return "请填写 **模型名称**。", None
|
| 25 |
-
if not model_api:
|
| 26 |
-
return "请填写 **模型 API**。", None
|
| 27 |
-
if not _is_valid_http_url(model_api):
|
| 28 |
-
return "**模型 API** 需要是合法的 `http(s)://...` URL。", None
|
| 29 |
-
|
| 30 |
-
payload = {
|
| 31 |
-
"model_name": model_name,
|
| 32 |
-
"model_api": model_api,
|
| 33 |
-
"notes": notes,
|
| 34 |
-
"submitted_at": datetime.datetime.now().isoformat(timespec="seconds"),
|
| 35 |
-
}
|
| 36 |
-
return "已收到提交(仅前端回显;未做评测/未写入排行榜)。", payload
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
with gr.Blocks(title=APP_NAME) as demo:
|
| 40 |
-
gr.Markdown(
|
| 41 |
-
f"## {APP_NAME}\n\n"
|
| 42 |
-
"纯前端信息收集页:填写模型名称与 API 地址,点击提交后回显。\n\n"
|
| 43 |
-
"- 不需要 Hugging Face 登录\n"
|
| 44 |
-
"- 不依赖 scorer\n"
|
| 45 |
-
"- 不读写任何 leaderboard 数据\n"
|
| 46 |
-
)
|
| 47 |
-
|
| 48 |
-
with gr.Row():
|
| 49 |
-
with gr.Column(scale=2):
|
| 50 |
-
model_name = gr.Textbox(label="模型名称(必填)", placeholder="例如:my-agent-v1")
|
| 51 |
-
model_api = gr.Textbox(
|
| 52 |
-
label="模型 API(必填)",
|
| 53 |
-
placeholder="例如:https://api.example.com/v1/chat/completions",
|
| 54 |
-
)
|
| 55 |
-
notes = gr.Textbox(
|
| 56 |
-
label="备注(可选)",
|
| 57 |
-
lines=4,
|
| 58 |
-
placeholder="例如:鉴权方式、限流说明、模型简介等",
|
| 59 |
-
)
|
| 60 |
-
submit_btn = gr.Button("提交", variant="primary")
|
| 61 |
-
with gr.Column(scale=3):
|
| 62 |
-
status = gr.Markdown()
|
| 63 |
-
submission_json = gr.JSON(label="提交内容(回显)")
|
| 64 |
-
|
| 65 |
-
submit_btn.click(
|
| 66 |
-
submit,
|
| 67 |
-
inputs=[model_name, model_api, notes],
|
| 68 |
-
outputs=[status, submission_json],
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|