Code
The following code creates a function that takes a list of place names and returns a list of standardized addresses:Key concepts
This implementation showcases several important ControlFlow features:-
Pydantic models: We use a Pydantic model (
StandardAddress
) to define the structure of our standardized addresses. This ensures that the standardization task returns well-structured, consistent results. -
Batch processing: We process a list of place names in a single task, which is more efficient than processing them individually. This is achieved by specifying
List[StandardAddress]
as theresult_type
. -
Context passing: We pass the entire list of place names as context to the task, allowing the LLM to process all inputs at once.
-
Simple task creation: We use
cf.run()
to create and execute a task in a single step, simplifying our code.