examples: use type hinting generics in standard collections for structured outputs (#389)

---------

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Co-authored-by: ParthSareen <parth.sareen@ollama.com>
This commit is contained in:
Tomoya Fujita 2024-12-20 13:31:21 -08:00 committed by GitHub
parent 4daf4afdb6
commit 7d1e002be9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
from pathlib import Path
from pydantic import BaseModel
from typing import List, Optional, Literal
from typing import Literal
from ollama import chat
@ -13,12 +13,12 @@ class Object(BaseModel):
class ImageDescription(BaseModel):
summary: str
objects: List[Object]
objects: list[Object]
scene: str
colors: List[str]
colors: list[str]
time_of_day: Literal['Morning', 'Afternoon', 'Evening', 'Night']
setting: Literal['Indoor', 'Outdoor', 'Unknown']
text_content: Optional[str] = None
text_content: str | None = None
# Get path from user input