From the course: OpenAI API: Agents

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Anatomy of a simple agent workflow

Anatomy of a simple agent workflow - OpenAI API Tutorial

From the course: OpenAI API: Agents

Anatomy of a simple agent workflow

- Okay, let's take a look at the entire agent workflow from top to bottom using a basic example. Here I'm going to use the Quickstart that's provided in the documentation. At the top, we import all the classes and components we need, so the agent itself, in this case, the InputsGuardrail, the GuardrailFunctionOutput, and Runner. We also import anything else we need like BaseModel from Pydantic to declare base models and types, and Async I/O to simplify running asynchronous functions. Next, a BaseModel is declared for HomeworkOutputs. And here you see the two values are is_homework, which is a boolean, and reasoning, which is the string. And this will be used in the agent to test, is the question the user is asking a question about homework or is it a question about something else? And based on the response in the string, you'll get either a true or false under is_homework. To see how the rest works, let's go to the bottom and then work our way up. To start, we have a main function…

Contents