ThinkSquare / src /llm /data_models /pydantic_data_models.py
Falguni's picture
Add annotation support in natural language with LLMs
e048cbb
raw
history blame contribute delete
591 Bytes
from typing import List
from pydantic import BaseModel, Field
class SingleCommentModel(BaseModel):
comment_ref: int = Field(description="Move number in the game")
comment: str = Field(description="Rewritten comment text for the move")
class MultiCommentModel(BaseModel):
comments: List[SingleCommentModel] = Field(
description="List of rewritten comments for each move (with comment) in the game",
)
from pydantic import TypeAdapter
# Optional sanity check: show the schema
adapter = TypeAdapter(MultiCommentModel)
schema = adapter.json_schema()
print(schema)