import asyncio import gradio as gr from backend.api import submit_model from frontend.leaderboard import parse_parameter_count def handle_submission( model_name, hf_space_tag, model_description, organization, model_size, pretrained, pretraining_data, publication_title, publication_link, zero_shot, few_shot, n_shot ): """Handle model submission from the form.""" # Basic validation if not model_name or not hf_space_tag or not model_description or not organization or not model_size or not pretrained or not publication_title or not publication_link or not zero_shot or not few_shot: return "
Please fill in all required fields (*)
" if "/" not in hf_space_tag: return "
HuggingFace space tag should be in format 'username/space-name'
" # Parse and validate model_size parsed_model_size = parse_parameter_count(model_size) if model_size and parsed_model_size is None: return "
Invalid model size format. Use raw numbers (e.g., 120000000) or human-readable format (e.g., 120M, 0.12B)
" # Process submission try: result = asyncio.run(submit_model( model_name=model_name, hf_space_tag=hf_space_tag, model_description=model_description, organization=organization or "", model_size=parsed_model_size, pretrained = pretrained, pretraining_data = pretraining_data or "", publication_title=publication_title or "", publication_link=publication_link or "", zero_shot = zero_shot, few_shot = few_shot, n_shot = n_shot, )) return "
 Success! Your model has been submitted for evaluation. Results pending approval.
" except Exception as e: return f"
L Error: {str(e)}
"