Skip to content

Commit

Permalink
update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
siyangqiu committed May 4, 2024
1 parent 6a53af4 commit 33e45e7
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions examples/recording-events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
},
"outputs": [],
"source": [
"import agentops\n",
"# Create new session\n",
"agentops.start_session()\n",
"agentops.init()\n",
"\n",
"# Optionally, we can add tags to the session\n",
"# agentops.start_session(['Hello Tracker'])"
"# agentops.init(tags=['Hello Tracker'])"
]
},
{
Expand Down Expand Up @@ -138,42 +139,24 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "eb23c1325298e22f",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🖇 AgentOps: Could not post data - {'message': '/events: Error posting event: Error inserting to table=\\'tools\\'. Postgres: json[\\'code\\']=\\'23505\\'. json[\\'message\\']=\\'duplicate key value violates unique constraint \"tools_pkey\"\\''}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"🖇 AgentOps: This run cost $0.00\n"
]
}
],
"outputs": [],
"source": [
"from agentops import ToolEvent, record, ErrorEvent\n",
"import agentops\n",
"\n",
"agentops.init()\n",
"\n",
"def scrape_website(url: str):\n",
" tool_event = ToolEvent(name='scrape_website', params={'url':url}) # the start timestamp is set when the obj is created\n",
"\n",
" try:\n",
" 1 / 0\n",
" 1 / 0 # Ooops! Something went wrong\n",
" except Exception as e:\n",
" record(ErrorEvent(exception=e, trigger_event=tool_event))\n",
" record(tool_event)\n",
"\n",
"scrape_website('https://app.agentops.ai') \n",
"scrape_website('https://app.agentops.ai') \n",
"\n",
"agentops.end_session('Success')"
]
Expand Down

0 comments on commit 33e45e7

Please sign in to comment.