Simple Agent
Most basic usage with OpenAI API
View Notebook on Github
AgentOps Basic Monitoring
This is an example of how to use the AgentOps library for basic Agent monitoring with OpenAI’s GPT
First let’s install the required packages
Then import them
Next, we’ll set our API keys. There are several ways to do this, the code below is just the most foolproof way for the purposes of this notebook. It accounts for both users who use environment variables and those who just want to set the API Key here in this notebook.
-
Create an environment variable in a .env file or other method. By default, the AgentOps
init()
function will look for an environment variable namedAGENTOPS_API_KEY
. Or… -
Replace
<your_agentops_key>
below and pass in the optionalapi_key
parameter to the AgentOpsinit(api_key=...)
function. Remember not to commit your API key to a public repo!
The AgentOps library is designed to be a plug-and-play replacement for the OpenAI Client, maximizing use with minimal install effort.
Now just use OpenAI as you would normally!
Single Session with ChatCompletion
Make sure to end your session with a Result
(Success|Fail|Indeterminate) for better tracking
Now if you check the AgentOps dashboard, you should see information related to this run!
Events
Additionally, you can track custom events via AgentOps. Let’s start a new session and record some events
The easiest way to record actions is through the use of AgentOps’ decorators
We can also manually craft an event exactly the way we want