Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Langchain added to documentation (#273)
Albert Kim Jrf8ccbdca6b8a
diff --git a/docs/mint.json b/docs/mint.jsonindex 3f797730..622c6eff 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -84,6 +84,7 @@"pages": ["v1/integrations/crewai","v1/integrations/autogen",+ "v1/integrations/langchain","v1/integrations/cohere","v1/integrations/litellm"]diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdxindex 04922bfc..23ca4619 100644--- a/docs/v1/integrations/autogen.mdx+++ b/docs/v1/integrations/autogen.mdx@@ -20,7 +20,7 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do```</CodeGroup><Check>- [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 1,000th 😊)+ [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊)</Check></Step><Step title="Install Autogen">diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdxindex 58e6071b..91b76d15 100644--- a/docs/v1/integrations/cohere.mdx+++ b/docs/v1/integrations/cohere.mdx@@ -22,7 +22,7 @@ This is a living integration. Should you need any added functionality message uspoetry add agentops```</CodeGroup>- <Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 1,000th 😊)</Check>+ <Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊)</Check></Step><Step title="Add 3 lines of code"><CodeGroup>diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdxindex 61f825c0..8b55bad2 100644--- a/docs/v1/integrations/crewai.mdx+++ b/docs/v1/integrations/crewai.mdx@@ -25,7 +25,7 @@ Crew has comprehensive [documentation](https://docs.crewai.com) available as wel```</CodeGroup><Check>- [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 1,000th 😊)+ [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊)</Check></Step><Step title="Install Crew from the AgentOps fork">diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdxnew file mode 100644index 00000000..6fef2008--- /dev/null+++ b/docs/v1/integrations/langchain.mdx@@ -0,0 +1,110 @@+---+title: Langchain+description: "AgentOps provides first class support for Lanchain applications"+---++AgentOps works seamlessly with applications built using Langchain.++## Adding AgentOps to Langchain applications++<Steps>+ <Step title="Install the AgentOps SDK and the additional Langchain dependency">+ <CodeGroup>+ ```bash pip+ pip install agentops+ pip install agentops[langchain]+ ```+ ```bash poetry+ poetry add agentops+ poetry add agentops[langchain]+ ```+ </CodeGroup>+ <Check>+ [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊)+ </Check>+ </Step>+ <Step title="Set up your import statements">+ Import the following Langchain and AgentOps dependencies+ <CodeGroup>+ ```python python+ import os+ from langchain.chat_models import ChatOpenAI+ from langchain.agents import initialize_agent, AgentType+ from agentops.langchain_callback_handler import LangchainCallbackHandler+ ```+ </CodeGroup>+ <Tip>+ For more features see our [Usage](/v1/usage) section.+ </Tip>+ </Step>+ <Step title="Set up your Langchain handler to make the calls">+ Set up your Langchain agent with the AgentOps callback handler and AgentOps will automatically record your Langchain sessions.+ <CodeGroup>+ ```python python+ 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)+ ```+ </CodeGroup>+ <Tip>+ 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.+ </Tip>+ </Step>+ <Step title="Set your API key">+ Retrieve an API Key from your Settings > [Projects & API Keys](https://app.agentops.ai/settings/projects) page.+ <Frame type="glass" caption="Settings > Projects & API Keys">+ <img height="200" src="/images/api-keys.png" />+ </Frame>+ <Info>+ API keys are tied to individual projects.<br></br>+ A Default Project has been created for you, so just click Copy API Key+ </Info>+ Set this API Key in your [environment variables](/v1/usage/environment-variables)+ ```python .env+ AGENTOPS_API_KEY=<YOUR API KEY>+ ```+ </Step>+ <Step title="Run your agent">+ Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Langchain Agent! 🕵️+ <Tip>+ After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard+ </Tip>+ <div/>{/* Intentionally blank div for newline */}+ <Frame type="glass" caption="Clickable link to session">+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/link-to-session.gif?raw=true" />+ </Frame>+ </Step>+</Steps>++## Full Examples++<CodeGroup>+ ```python python+ import os+ from langchain.chat_models import ChatOpenAI+ from langchain.agents import initialize_agent, AgentType+ from agentops.langchain_callback_handler import LangchainCallbackHandler++ 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)+ ```+</CodeGroup>\ No newline at end of filediff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdxindex f043ba88..3c470b0f 100644--- a/docs/v1/introduction.mdx+++ b/docs/v1/introduction.mdx@@ -4,7 +4,7 @@ description: "Build your next agent with evals, observability, and replays"mode: "wide"----<Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub if you find AgentOps helpful (you may be our 1,000th 😊)</Check>+<Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub if you find AgentOps helpful (you may be our 2,000th 😊)</Check># AgentOps is your new terminaldiff --git a/docs/v1/quickstart.mdx b/docs/v1/quickstart.mdxindex 1a1d9bbe..a85f5b71 100644--- a/docs/v1/quickstart.mdx+++ b/docs/v1/quickstart.mdx@@ -14,7 +14,6 @@ import SupportedModels from '/snippets/supported-models.mdx'poetry add agentops```</CodeGroup>- <Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 1,000th 😊)</Check></Step><Step title="Add 2 lines of code"><CodeGroup>@@ -61,7 +60,7 @@ import SupportedModels from '/snippets/supported-models.mdx'</Frame></Step></Steps>-+<Check>[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub if you found AgentOps helpful (you may be our 2,000th 😊)</Check>## More basic functionality