Spaces:
Runtime error
Runtime error
allow subs
Browse files19 unmodified lines202122232425262728293047 unmodified lines78798081828319 unmodified lines)from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKENfrom src.populate import get_leaderboard_dfdef restart_space():API.restart_space(repo_id=REPO_ID)### Space initialisationtry:print(EVAL_REQUESTS_PATH)47 unmodified lineswith gr.TabItem("π About", elem_id="llm-benchmark-tab-table", id=2):gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")with gr.Row():with gr.Accordion("π Citation", open=False):citation_button = gr.Textbox(19 unmodified lines202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511647 unmodified lines16416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120219 unmodified lines)from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKENfrom src.populate import get_leaderboard_dfimport jsonimport osfrom datetime import datetimefrom huggingface_hub import HfApidef restart_space():API.restart_space(repo_id=REPO_ID)def submit_model_request(model_id: str, contact: str = "") -> str:"""Submit a model evaluation request"""if not model_id or not model_id.strip():return "β Please provide a model ID"model_id = model_id.strip()# Validate format (should have provider/model)if "/" not in model_id:return "β Model ID must include provider (e.g., `anthropic/claude-3-opus`)"provider, model_name = model_id.split("/", 1)# Check if already existsrequest_filename = f"{model_id.replace('/', '_')}_eval_request_False_float16_Original.json"# Create request objectrequest_data = {"model": model_id,"provider": provider,"base_model": "","revision": "main","precision": "float16","weight_type": "Original","status": "PENDING","submitted_time": datetime.now().isoformat() + "Z","submitted_by": contact if contact else "anonymous","model_type": "pretrained","likes": 0,"params": 0,"license": "?","private": False,}try:# Save to requests pathprovider_dir = os.path.join(EVAL_REQUESTS_PATH, provider)os.makedirs(provider_dir, exist_ok=True)request_path = os.path.join(provider_dir, request_filename)# Check if already existsif os.path.exists(request_path):with open(request_path, 'r') as f:existing = json.load(f)if existing.get("status") in ["FINISHED", "RUNNING"]:return f"β Model `{model_id}` is already {existing['status'].lower()}"# Write request filewith open(request_path, 'w') as f:json.dump(request_data, f, indent=2)# Try to push to HF (if token available)try:hf_api = HfApi(token=TOKEN)hf_api.upload_file(path_or_fileobj=request_path,path_in_repo=f"{provider}/{request_filename}",repo_id=QUEUE_REPO,repo_type="dataset",commit_message=f"Add evaluation request for {model_id}")return f"""β **Request submitted successfully!****Model:** `{model_id}`**Provider:** {provider}**Status:** PENDINGWe'll run the benchmark and update the leaderboard within a few days.{f"We'll contact you at: {contact}" if contact else ""}"""except Exception as e:return f"""β οΈ **Request saved locally but failed to upload to HuggingFace**Error: {str(e)}The request has been saved but needs manual upload. Please contact the maintainers."""except Exception as e:return f"β Failed to submit request: {str(e)}"### Space initialisationtry:print(EVAL_REQUESTS_PATH)47 unmodified lineswith gr.TabItem("π About", elem_id="llm-benchmark-tab-table", id=2):gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")with gr.TabItem("π Submit Model", elem_id="llm-benchmark-tab-table", id=3):with gr.Column():gr.Markdown("""## Request Model EvaluationSubmit a model ID to request it be added to the leaderboard.We'll run the benchmark and update the results within a few days.**Supported providers:** OpenAI, Anthropic, X.AI, Google, Meta, etc. (via OpenRouter)""")with gr.Row():with gr.Column():model_id_input = gr.Textbox(label="Model ID",placeholder="e.g., anthropic/claude-3-opus, openai/gpt-4-turbo",info="Full model ID including provider (e.g., anthropic/claude-3-opus)")contact_input = gr.Textbox(label="Contact (optional)",placeholder="email@example.com or @discord_username",info="How can we reach you with updates?")submit_btn = gr.Button("Submit Request", variant="primary")result_output = gr.Markdown()submit_btn.click(fn=submit_model_request,inputs=[model_id_input, contact_input],outputs=result_output)with gr.Row():with gr.Accordion("π Citation", open=False):citation_button = gr.Textbox(
app.py+119