mirror of
https://github.com/ollama/ollama-python.git
synced 2026-05-01 11:48:17 +08:00
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:
parent
4daf4afdb6
commit
7d1e002be9
@ -1,6 +1,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import List, Optional, Literal
|
from typing import Literal
|
||||||
from ollama import chat
|
from ollama import chat
|
||||||
|
|
||||||
|
|
||||||
@ -13,12 +13,12 @@ class Object(BaseModel):
|
|||||||
|
|
||||||
class ImageDescription(BaseModel):
|
class ImageDescription(BaseModel):
|
||||||
summary: str
|
summary: str
|
||||||
objects: List[Object]
|
objects: list[Object]
|
||||||
scene: str
|
scene: str
|
||||||
colors: List[str]
|
colors: list[str]
|
||||||
time_of_day: Literal['Morning', 'Afternoon', 'Evening', 'Night']
|
time_of_day: Literal['Morning', 'Afternoon', 'Evening', 'Night']
|
||||||
setting: Literal['Indoor', 'Outdoor', 'Unknown']
|
setting: Literal['Indoor', 'Outdoor', 'Unknown']
|
||||||
text_content: Optional[str] = None
|
text_content: str | None = None
|
||||||
|
|
||||||
|
|
||||||
# Get path from user input
|
# Get path from user input
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user