And, that’s it! With just this, you can start logging all of your AutoGen requests and make them reliable.
Let’s Run your Agent
import autogen# Create user proxy agent, coder, product manageruser_proxy = autogen.UserProxyAgent( name="User_proxy", system_message="A human admin who will give the idea and run the code provided by Coder.", code_execution_config={"last_n_messages": 2, "work_dir": "groupchat"}, human_input_mode="ALWAYS",)with llm_config: coder = autogen.AssistantAgent( name="Coder", system_message = "You are a Python developer who is good at developing games. You work with Product Manager.", )# Create groupchatgroupchat = autogen.GroupChat( agents=[user_proxy, coder], messages=[])manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)# Start the conversationuser_proxy.initiate_chat( manager, message="Build a classic & basic pong game with 2 players in python")
Here’s the output from your Agent’s run on Portkey’s dashboard
Note: AG2 messages will go through Portkey’s AI Gateway following OpenAI’s API signature. Some language models may not work properly because messages need to be in a specific role order.
Learn more about Portkey Config object here.
Be Careful to Load-Balance/Fallback to providers that don’t support tool calling when the request contains a function call.
Agent runs are complex. Portkey automatically logs 40+ comprehensive metrics for your AI agents, including cost, tokens used, latency, etc. Whether you need a broad overview or granular insights into your agent runs, Portkey’s customizable filters provide the metrics you need.
AG2 agents, while powerful, can sometimes produce unexpected or undesired outputs. Portkey’s Guardrails feature helps enforce agent behavior in real-time, ensuring your AG2 agents operate within specified parameters. Verify both the inputs to and outputs from your agents to ensure they adhere to specified formats and content guidelines. Learn more about Portkey’s Guardrails here