Skip to content

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

Fixing job_posting and calling end_session in notebook automation (#390)

Howard Gil8161133a853f
diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml
index 406a7351..303437e0 100644
--- a/.github/workflows/test-notebooks.yml
+++ b/.github/workflows/test-notebooks.yml
@@ -1,14 +1,7 @@
name: Test Notebooks
on:
- push:
- branches:
- - main
- paths:
- - "agentops/**"
- - "examples/**"
- - "tests/**"
- - ".github/workflows/test-notebooks.yml"
- pull_request_target:
+ pull_request:
+ types: [closed]
branches:
- main
paths:
@@ -43,13 +36,17 @@ jobs:
echo "GROQ_API_KEY=${{ secrets.GROQ_API_KEY }}" >> .env
echo "MULTION_API_KEY=${{ secrets.MULTION_API_KEY }}" >> .env
echo "SERPER_API_KEY=${{ secrets.SERPER_API_KEY }}" >> .env
+ - name: Install AgentOps from main branch and remove agentops install from notebooks
+ run: |
+ pip install git+https://github.com/AgentOps-AI/agentops.git@main
+ find . -name '*.ipynb' -exec sed -i '/^%pip install.*agentops/d' {} +
- name: Run notebooks and check for errors
run: |
mkdir -p logs
exit_code=0
exclude_notebooks=(
- "./examples/crew/job_posting.ipynb",
+ "./examples/crewai_examples/job_posting.ipynb",
"./examples/demos/agentchat_agentops.ipynb"
)
diff --git a/examples/anthropic-sdk/anthropic_example.ipynb b/examples/anthropic_examples/anthropic_example.ipynb
similarity index 100%
rename from examples/anthropic-sdk/anthropic_example.ipynb
rename to examples/anthropic_examples/anthropic_example.ipynb
diff --git a/examples/autogen/AgentChat.ipynb b/examples/autogen_examples/AgentChat.ipynb
similarity index 99%
rename from examples/autogen/AgentChat.ipynb
rename to examples/autogen_examples/AgentChat.ipynb
index 4de700ab..85fd4991 100644
--- a/examples/autogen/AgentChat.ipynb
+++ b/examples/autogen_examples/AgentChat.ipynb
@@ -146,6 +146,7 @@
"except StdinNotImplementedError:\n",
" # This is only necessary for AgentOps testing automation which is headless and will not have user input\n",
" print(\"Stdin not implemented. Skipping initiate_chat\")\n",
+ " agentops.end_session(\"Indeterminate\")\n",
"\n",
"# Close your AgentOps session to indicate that it completed.\n",
"agentops.end_session(\"Success\")\n",
diff --git a/examples/autogen/MathAgent.ipynb b/examples/autogen_examples/MathAgent.ipynb
similarity index 99%
rename from examples/autogen/MathAgent.ipynb
rename to examples/autogen_examples/MathAgent.ipynb
index bf542594..13bf58a8 100644
--- a/examples/autogen/MathAgent.ipynb
+++ b/examples/autogen_examples/MathAgent.ipynb
@@ -195,6 +195,7 @@
"except StdinNotImplementedError:\n",
" # This is only necessary for AgentOps testing automation which is headless and will not have user input\n",
" print(\"Stdin not implemented. Skipping initiate_chat\")\n",
+ " agentops.end_session(\"Indeterminate\")\n",
"\n",
"agentops.end_session(\"Success\")"
]
diff --git a/examples/cohere-sdk/cohere_example.ipynb b/examples/cohere_examples/cohere_example.ipynb
similarity index 100%
rename from examples/cohere-sdk/cohere_example.ipynb
rename to examples/cohere_examples/cohere_example.ipynb
diff --git a/examples/crew/README.md b/examples/crewai_examples/README.md
similarity index 100%
rename from examples/crew/README.md
rename to examples/crewai_examples/README.md
diff --git a/examples/crew/job_posting.ipynb b/examples/crewai_examples/job_posting.ipynb
similarity index 95%
rename from examples/crew/job_posting.ipynb
rename to examples/crewai_examples/job_posting.ipynb
index eb3faaaa..4c118ac4 100644
--- a/examples/crew/job_posting.ipynb
+++ b/examples/crewai_examples/job_posting.ipynb
@@ -41,7 +41,10 @@
"from crewai_tools.tools import WebsiteSearchTool, SerperDevTool, FileReadTool\n",
"import agentops\n",
"import os\n",
- "from dotenv import load_dotenv"
+ "from dotenv import load_dotenv\n",
+ "from IPython.core.error import (\n",
+ " StdinNotImplementedError,\n",
+ ") # only needed by AgentOps testing automation"
]
},
{
@@ -244,8 +247,13 @@
" ],\n",
")\n",
"\n",
- "# Kick off the process\n",
- "result = crew.kickoff()\n",
+ "try:\n",
+ " # Kick off the process\n",
+ " result = crew.kickoff()\n",
+ "except StdinNotImplementedError:\n",
+ " # This is only necessary for AgentOps testing automation which is headless and will not have user input\n",
+ " print(\"Stdin not implemented. Skipping kickoff()\")\n",
+ " agentops.end_session(\"Indeterminate\")\n",
"\n",
"print(\"Job Posting Creation Process Completed.\")\n",
"print(\"Final Job Posting:\")\n",
diff --git a/examples/crew/markdown_validator.ipynb b/examples/crewai_examples/markdown_validator.ipynb
similarity index 100%
rename from examples/crew/markdown_validator.ipynb
rename to examples/crewai_examples/markdown_validator.ipynb
diff --git a/examples/demos/agentchat_agentops.ipynb b/examples/demos/agentchat_agentops.ipynb
index 7b0d7b18..2aa7a84e 100644
--- a/examples/demos/agentchat_agentops.ipynb
+++ b/examples/demos/agentchat_agentops.ipynb
@@ -196,6 +196,7 @@
"except StdinNotImplementedError:\n",
" # This is only necessary for AgentOps testing automation which is headless and will not have user input\n",
" print(\"Stdin not implemented. Skipping initiate_chat\")\n",
+ " agentops.end_session(\"Indeterminate\")\n",
"\n",
"# Close your AgentOps session to indicate that it completed.\n",
"agentops.end_session(\"Success\")"
diff --git a/examples/langchain/langchain_examples.ipynb b/examples/langchain_examples/langchain_examples.ipynb
similarity index 99%
rename from examples/langchain/langchain_examples.ipynb
rename to examples/langchain_examples/langchain_examples.ipynb
index 361064c6..b087de3b 100644
--- a/examples/langchain/langchain_examples.ipynb
+++ b/examples/langchain_examples/langchain_examples.ipynb
@@ -148,6 +148,10 @@
},
"outputs": [],
"source": [
+ "agentops_handler = AgentOpsLangchainCallbackHandler(\n",
+ " api_key=AGENTOPS_API_KEY, default_tags=[\"Langchain Example\"]\n",
+ ")\n",
+ "\n",
"llm = ChatOpenAI(\n",
" openai_api_key=OPENAI_API_KEY, callbacks=[agentops_handler], model=\"gpt-3.5-turbo\"\n",
")\n",
diff --git a/examples/litellm-sdk/litellm_example.ipynb b/examples/litellm_examples/litellm_example.ipynb
similarity index 100%
rename from examples/litellm-sdk/litellm_example.ipynb
rename to examples/litellm_examples/litellm_example.ipynb
diff --git a/examples/multion/Autonomous_web_browsing.ipynb b/examples/multion_examples/Autonomous_web_browsing.ipynb
similarity index 100%
rename from examples/multion/Autonomous_web_browsing.ipynb
rename to examples/multion_examples/Autonomous_web_browsing.ipynb
diff --git a/examples/multion/Sample_browsing_agent.ipynb b/examples/multion_examples/Sample_browsing_agent.ipynb
similarity index 100%
rename from examples/multion/Sample_browsing_agent.ipynb
rename to examples/multion_examples/Sample_browsing_agent.ipynb
diff --git a/examples/multion/Step_by_step_web_browsing.ipynb b/examples/multion_examples/Step_by_step_web_browsing.ipynb
similarity index 100%
rename from examples/multion/Step_by_step_web_browsing.ipynb
rename to examples/multion_examples/Step_by_step_web_browsing.ipynb
diff --git a/examples/multion/Webpage_data_retrieval.ipynb b/examples/multion_examples/Webpage_data_retrieval.ipynb
similarity index 100%
rename from examples/multion/Webpage_data_retrieval.ipynb
rename to examples/multion_examples/Webpage_data_retrieval.ipynb