|
| 1 | +from agent_framework.orchestrations import SequentialBuilder |
| 2 | +from pydantic import BaseModel |
| 3 | + |
| 4 | +from uipath_agent_framework.chat import UiPathOpenAIChatClient |
| 5 | + |
| 6 | + |
| 7 | +class CityInfo(BaseModel): |
| 8 | + """Structured output for city information.""" |
| 9 | + |
| 10 | + city: str |
| 11 | + country: str |
| 12 | + description: str |
| 13 | + population_estimate: str |
| 14 | + famous_for: list[str] |
| 15 | + |
| 16 | + |
| 17 | +client = UiPathOpenAIChatClient(model="gpt-5-mini-2025-08-07") |
| 18 | + |
| 19 | +researcher = client.as_agent( |
| 20 | + name="researcher", |
| 21 | + description="Researches factual information about a city.", |
| 22 | + instructions=( |
| 23 | + "You are a thorough researcher. Given a city name, gather key facts " |
| 24 | + "including its country, population, notable landmarks, cultural " |
| 25 | + "significance, and what it is famous for. Present your findings clearly." |
| 26 | + ), |
| 27 | +) |
| 28 | + |
| 29 | +editor = client.as_agent( |
| 30 | + name="editor", |
| 31 | + description="Edits research into a structured city profile.", |
| 32 | + instructions=( |
| 33 | + "You are a precise editor. Take the researcher's findings and organize " |
| 34 | + "them into a well-structured city profile. Ensure all facts are accurate " |
| 35 | + "and the description is concise and informative." |
| 36 | + ), |
| 37 | + default_options={"response_format": CityInfo}, |
| 38 | +) |
| 39 | + |
| 40 | +workflow = SequentialBuilder( |
| 41 | + participants=[researcher, editor], |
| 42 | +).build() |
| 43 | + |
| 44 | +agent = workflow.as_agent(name="sequential_structured_output_workflow") |
0 commit comments