Skip to content

Commit 53940b8

Browse files
author
Pierre
committed
new .run
1 parent 7a3d78b commit 53940b8

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ image = Image(content_type='image/jpeg', data='<base 64 encoded data>')
335335
image = Image(url="https://example.com/image.jpg")
336336
```
337337

338-
An example of using image as input is available in [city_identifier.py](./examples/images/city_identifier.py).
338+
An example of using image as input is available in [07_image_agent.py](./examples/07_image_agent.py).
339339

340340
### Files (PDF, .txt, ...)
341341

examples/01_basic_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ async def main():
6161
# Example 1: Basic usage with Paris
6262
print("\nExample 1: Basic usage with Paris")
6363
print("-" * 50)
64-
run = await get_capital_info(CityInput(city="Paris"))
64+
run = await get_capital_info.run(CityInput(city="Paris"))
6565
print(run)
6666

6767
# Example 2: Using Tokyo
6868
print("\nExample 2: Using Tokyo")
6969
print("-" * 50)
70-
run = await get_capital_info(CityInput(city="Tokyo"))
70+
run = await get_capital_info.runCityInput(city="Tokyo"))
7171
print(run)
7272

7373

examples/07_image_agent.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
1414

1515
import workflowai
16-
from workflowai import Run, WorkflowAIError
16+
from workflowai import WorkflowAIError
1717
from workflowai.core.domain.model import Model
1818
from 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--------\nAgent output:\n", agent_run.output, "\n--------\n")

0 commit comments

Comments
 (0)