1313from pydantic import BaseModel , Field # pyright: ignore [reportUnknownVariableType]
1414
1515import workflowai
16- from workflowai import Run , WorkflowAIError
16+ from workflowai import WorkflowAIError
1717from workflowai .core .domain .model import Model
1818from workflowai .fields import Image
1919
@@ -31,8 +31,8 @@ class ImageOutput(BaseModel):
3131 )
3232
3333
34- @workflowai .agent (id = "city-identifier" , model = Model .GEMINI_1_5_FLASH_LATEST )
35- async def identify_city_from_image (_ : ImageInput ) -> Run [ ImageOutput ] :
34+ @workflowai .agent (id = "city-identifier" , model = Model .GEMINI_2_0_FLASH_LATEST )
35+ async def identify_city_from_image (image_input : ImageInput ) -> ImageOutput :
3636 """
3737 Analyze the provided image and identify the city and country shown in it.
3838 If the image shows a recognizable landmark or cityscape, identify the city and country.
@@ -62,9 +62,8 @@ async def main():
6262
6363 image = Image (content_type = "image/jpeg" , data = content )
6464 try :
65- agent_run = await identify_city_from_image (
65+ agent_run = await identify_city_from_image . run (
6666 ImageInput (image = image ),
67- use_cache = "auto" ,
6867 )
6968 except WorkflowAIError as e :
7069 print (f"Failed to run task. Code: { e .error .code } . Message: { e .error .message } " )
@@ -77,9 +76,8 @@ async def main():
7776 # Example using URL for Image
7877 image_url = "https://t4.ftcdn.net/jpg/02/96/15/35/360_F_296153501_B34baBHDkFXbl5RmzxpiOumF4LHGCvAE.jpg"
7978 image = Image (url = image_url )
80- agent_run = await identify_city_from_image (
79+ agent_run = await identify_city_from_image . run (
8180 ImageInput (image = image ),
82- use_cache = "auto" ,
8381 )
8482
8583 print ("\n --------\n Agent output:\n " , agent_run .output , "\n --------\n " )
0 commit comments