OpenAI Agent walkthrough
Create Project Folder
Install Dependencies
Create Project Files
.env file.Set Environment Variables
.env file, set your environment variables by filling in your API keys, Project name, and Log stream name.By using these exact variable names, Galileo will automatically use them in your application.- NOTE: The Project name and Log stream name are customizable. Change them as needed for your own experiments. You can view all your Projects and Log streams in the Galileo Console.
Import Libraries
Define Output Structure
int would be an invalid output in response to the question “Who was the first president of the United States?”This is achieved in Python using BaseModel.- BaseModel: A Python class from the
pydanticlibrary which automatically validates whether groups of values are the correct types.
Create Tutor Agents
- Agent: An AI module that receives inputs and provides specialized outputs based on predefined instructions.
Create Guardrail Agent
- Guardrail Agent: A specialized agent for evaluating inputs and determining whether they meet specific criteria.
Define Guardrail Function
- Tripwire: A condition that triggers if the guardrail criteria are not met, preventing further processing.
Create Triage Agent
- Triage Agent: An agent that analyzes the input and determines which specialized agent should handle the request.
Run the Agents
GalileoTracingProcessor SDK docs.- Runner: A utility that executes the agents with provided input and context.
Complete Application Code
Open project & Log stream
.env file.You will see new Traces, each containing data logged from running your AI Agent pipeline.-
NOTE: Learn more about using Projects and Log streams in the Getting Started Guide.
View Results
- Each agent involved and when it was used
- All agent inputs, outputs, and handoffs
- Whether Guardrail Tripwires were passed or triggered
-
The time of execution, Project ID, Run ID, Trace ID, and Parent ID (viewable in the “Parameters” tab in the top-right)
OPTIONAL: Test the Guardrail Tripwire
- NOTE: This will cause an error because the Guardrail Agent rejects questions that trigger the Tripwire.
Congratulations!