-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathhello_world.py
More file actions
33 lines (24 loc) · 830 Bytes
/
hello_world.py
File metadata and controls
33 lines (24 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import asyncio
from typing import Optional
from pydantic import BaseModel, Field
import agentics.core.transducible_functions
class Movie(BaseModel):
movie_name: Optional[str] = None
description: Optional[str] = None
year: Optional[int] = None
class Genre(BaseModel):
genre: Optional[str] = Field(None, description="Provide one category only")
# Create movie instance
movies = [
Movie(
movie_name="The Godfather",
description="The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.",
year=1972,
),
Movie(movie_name="The Shawshank Redemption"),
]
# Create transduction function using << operator
classify_genre = Genre << Movie
# Execute transduction
result = asyncio.run(classify_genre(movies))
print(result)