CoolFace
Apppublic

Muskan02/llm-code-deployer

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
models.py82 linesDownload Raw Back to root
1from pydantic import BaseModel, Field, EmailStr2from typing import List3 4# Data model for attachments (like the sample image)5class Attachment(BaseModel):6    name: str = Field(..., description="Name of the attached file (e.g., 'sample.png')")7    url: str = Field(..., description="The content encoded as a data URI (data:image/png;base64,...)")8 9# The main data model for the incoming task payload10class TaskRequest(BaseModel):11    # Student email ID12    email: EmailStr = Field(..., description="Student email ID")13    # Student-provided secret14    secret: str = Field(..., description="Student-provided secret")15    # A unique task ID.16    task: str = Field(..., description="A unique task ID (e.g., 'captcha-solver-...')")17    # There will be multiple rounds per task. This is the round index18    round: int = Field(..., description="The round index (e.g., 1)")19    # Pass this nonce back to the evaluation URL20    nonce: str = Field(..., description="Pass this nonce back to the evaluation URL below")21    # brief: mentions what the app needs to do22    brief: str = Field(..., description="Brief description of what the app needs to do")23    # checks: mention how it will be evaluated24    checks: List[str] = Field(..., description="Evaluation checks (e.g., license, readme quality)")25    # Send repo & commit details to the URL below26    evaluation_url: str = Field(..., description="URL to send repo & commit details")27    # Attachments will be encoded as data URIs28    attachments: List[Attachment] = Field(..., description="Attachments encoded as data URIs")29 30 31 32# from pydantic import BaseModel, EmailStr33# from typing import List, Optional34 35# # Defines the structure for an individual attachment, like a sample captcha image36# class Attachment(BaseModel):37#     """38#     Represents an attachment provided in the task payload.39#     The 'url' is expected to be a data URI (e.g., base64 encoded image).40#     """41#     name: str42#     url: str43 44# # Defines the complete structure of the JSON request body45# class TaskRequest(BaseModel):46#     """47#     The main model representing the task request sent by the evaluation server.48#     """49#     email: EmailStr  # Enforces a valid email format50#     secret: str51#     task: str52#     round: int53#     nonce: str54#     brief: str55#     checks: List[str]  # A list of strings detailing the evaluation checks56#     evaluation_url: str57#     attachments: List[Attachment] # A list of Attachment objects58 59#     # Configuration for Pydantic to allow validation from dicts/JSON60#     class Config:61#         schema_extra = {62#             "example": {63#                 "email": "student@example.com",64#                 "secret": "my-secure-token",65#                 "task": "captcha-solver-12345",66#                 "round": 1,67#                 "nonce": "ab12-cd34-ef56",68#                 "brief": "Create a captcha solver that handles ?url=https://.../image.png.",69#                 "checks": [70#                     "Repo has MIT license",71#                     "README.md is professional"72#                 ],73#                 "evaluation_url": "https://example.com/notify",74#                 "attachments": [75#                     {76#                         "name": "sample.png",77#                         "url": "data:image/png;base64,iVBORw..."78#                     }79#                 ]80#             }81#         }82