add models.py
This commit is contained in:
@@ -1,44 +1,38 @@
|
||||
"""
|
||||
Pydantic model representing a structured assignment card.
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel
|
||||
|
||||
Fields:
|
||||
- title: short title of the task (string)
|
||||
- subject: main topic or subject area (string, optional)
|
||||
- deadline_hint: free‑form hint about due date (string, optional)
|
||||
- deliverable_type: what is expected to be submitted (string, optional)
|
||||
- grading_hints: list of strings describing evaluation criteria (list[str], optional)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
class TaskCard(BaseModel):
|
||||
"""Pydantic model representing a task card.
|
||||
|
||||
from typing import List, Optional
|
||||
Attributes:
|
||||
title: The main title of the task.
|
||||
subject: Optional subject or domain of the task.
|
||||
deadline: Optional due date in ISO format or human readable string.
|
||||
deliverable: Optional description of what should be produced.
|
||||
criteria: List of acceptance criteria strings.
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
title: str
|
||||
subject: Optional[str] = None
|
||||
deadline: Optional[str] = None
|
||||
deliverable: Optional[str] = None
|
||||
criteria: List[str]
|
||||
|
||||
class AssignmentCard(BaseModel):
|
||||
"""Structured representation of an informal assignment description."""
|
||||
def to_markdown(self) -> str:
|
||||
"""Return a Markdown representation of the task card.
|
||||
|
||||
title: str = Field(..., description="Short title or main action of the task")
|
||||
subject: Optional[str] = Field(None, description="Primary subject or topic of the task")
|
||||
deadline_hint: Optional[str] = Field(
|
||||
None,
|
||||
description="Free‑form hint about when the task is due (e.g., 'к пятнице')",
|
||||
)
|
||||
deliverable_type: Optional[str] = Field(
|
||||
None, description="What should be submitted: report, code, presentation, etc."
|
||||
)
|
||||
grading_hints: List[str] = Field(
|
||||
default_factory=list,
|
||||
description="List of evaluation criteria mentioned in the text",
|
||||
)
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"title": "Мини‑отчёт по LangChain",
|
||||
"subject": "LangChain",
|
||||
"deadline_hint": "к пятнице",
|
||||
"deliverable_type": "отчёт",
|
||||
"grading_hints": ["полнота", "пример кода"],
|
||||
}
|
||||
}
|
||||
The format follows a simple, readable structure that can be used in
|
||||
documentation or issue trackers. Empty optional fields are omitted.
|
||||
"""
|
||||
lines = [f"# {self.title}"]
|
||||
if self.subject:
|
||||
lines.append(f"**Subject:** {self.subject}")
|
||||
if self.deadline:
|
||||
lines.append(f"**Deadline:** {self.deadline}")
|
||||
if self.deliverable:
|
||||
lines.append(f"**Deliverable:** {self.deliverable}")
|
||||
if self.criteria:
|
||||
lines.append("## Acceptance Criteria")
|
||||
for idx, crit in enumerate(self.criteria, 1):
|
||||
lines.append(f"{idx}. {crit}")
|
||||
return "\n\n".join(lines)
|
||||
|
||||
Reference in New Issue
Block a user