-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
545 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"id": "bb6538d8-2a5d-4a99-b2c1-7130963e4f7b", | ||
"metadata": {}, | ||
"source": [ | ||
"# Adding AgentOps to an existing Autogen service\n", | ||
"<img src=\"https://raw.githubusercontent.com/AgentOps-AI/agentops/main/docs/images/external/autogen/autogen_integration.png?raw=true\"/>\n", | ||
"\n", | ||
"To get started, you'll need to install the AgentOps package and [set an API key](app.agentops.ai).\n", | ||
"\n", | ||
"AgentOps automatically configures itself when it's initialized meaning your agent run data will be tracked and logged to your AgentOps account right away." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "d93f2339-7b99-4cf1-9232-c24faba49c7b", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=24c5d9f6-fb82-41e6-a468-2dc74a5318a3\u001b[0m\u001b[0m\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"AgentOps is now running. You can view your session in the link above\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import agentops\n", | ||
"\n", | ||
"from autogen import ConversableAgent, UserProxyAgent, config_list_from_json\n", | ||
"\n", | ||
"# When initializing AgentOps, you can pass in optional tags to help filter sessions\n", | ||
"agentops.init(api_key=\"...\", tags=[\"simple-autogen-example\"])\n", | ||
"\n", | ||
"print('AgentOps is now running. You can view your session in the link above')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7858f0f6-9aca-4cdb-a514-9fbf7e353d50", | ||
"metadata": {}, | ||
"source": [ | ||
"AutoGen will now start automatically tracking\n", | ||
"\n", | ||
"* LLM prompts and completions\n", | ||
"* Token usage and costs\n", | ||
"* Agent names and actions\n", | ||
"* Correspondence between agents\n", | ||
"* Tool usage\n", | ||
"* Errors" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "2962d990-f7ef-43d8-ba09-d29bd8356d9f", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[33magent\u001b[0m (to user):\n", | ||
"\n", | ||
"How can I help you today?\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdin", | ||
"output_type": "stream", | ||
"text": [ | ||
"Provide feedback to agent. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Tell me a joke about AgentOps\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[33muser\u001b[0m (to agent):\n", | ||
"\n", | ||
"Tell me a joke about AgentOps\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------\n", | ||
"\u001b[31m\n", | ||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n", | ||
"\u001b[33magent\u001b[0m (to user):\n", | ||
"\n", | ||
"Why don't AgentOps teams ever play hide and seek?\n", | ||
"\n", | ||
"Because good luck hiding when they always know where everyone is supposed to be!\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdin", | ||
"output_type": "stream", | ||
"text": [ | ||
"Provide feedback to agent. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Another\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[33muser\u001b[0m (to agent):\n", | ||
"\n", | ||
"Another\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------\n", | ||
"\u001b[31m\n", | ||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n", | ||
"\u001b[33magent\u001b[0m (to user):\n", | ||
"\n", | ||
"Why did the AgentOps team bring a ladder to work?\n", | ||
"\n", | ||
"Because they’re always reaching for high-level optimizations!\n", | ||
"\n", | ||
"--------------------------------------------------------------------------------\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdin", | ||
"output_type": "stream", | ||
"text": [ | ||
"Provide feedback to agent. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: exit\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"🖇 AgentOps: This run's cost $0.001080\n", | ||
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=24c5d9f6-fb82-41e6-a468-2dc74a5318a3\u001b[0m\u001b[0m\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Success! Visit your AgentOps dashboard to see the replay\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"# Define an openai api key for the agent configurations\n", | ||
"openai_api_key = \"...\"\n", | ||
"config_list = [\n", | ||
" {\n", | ||
" \"model\": \"gpt-4-turbo\",\n", | ||
" \"api_key\": openai_api_key,\n", | ||
" \"tags\": [\"gpt-4\", \"tool\"]\n", | ||
" }\n", | ||
"]\n", | ||
"\n", | ||
"# Create the agent that uses the LLM.\n", | ||
"assistant = ConversableAgent(\"agent\", llm_config={\"config_list\": config_list})\n", | ||
"\n", | ||
"# Create the agent that represents the user in the conversation.\n", | ||
"user_proxy = UserProxyAgent(\"user\", code_execution_config=False)\n", | ||
"\n", | ||
"# Let the assistant start the conversation. It will end when the user types \"exit\".\n", | ||
"assistant.initiate_chat(user_proxy, message=\"How can I help you today?\")\n", | ||
"\n", | ||
"# Close your AgentOps session to indicate that it completed.\n", | ||
"agentops.end_session(\"Success\")\n", | ||
"print('Success! Visit your AgentOps dashboard to see the replay')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7b422137-903a-41ef-a4ca-95b50aea4138", | ||
"metadata": {}, | ||
"source": [ | ||
"You can view data on this run at [app.agentops.ai](app.agentops.ai).\n", | ||
"\n", | ||
"The dashboard will display LLM events for each message sent by each agent, including those made by the human user." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "72993a75-1031-4874-aa26-0ef816a3256c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.