Note that you don’t need to set up a separate agentops.init() call, as the LangChain callback handler will automatically initialize the AgentOps client for you.
Set up your LangChain agent with the AgentOps callback handler, and AgentOps will automatically record your LangChain sessions.
handler = LangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['LangChain Example'])llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY, callbacks=[handler], model='gpt-3.5-turbo')agent = initialize_agent(tools, llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True, callbacks=[handler], # You must pass in a callback handler to record your agent handle_parsing_errors=True)
Set your API key as an .env variable for easy access.