Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions .github/workflows/examples-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: Examples Integration Test

# This workflow runs all example scripts to ensure they work correctly
# and that LLM spans are properly tracked in AgentOps using the
# integrated validation functionality.

on:
push:
branches: [ main, develop ]
paths:
- 'examples/**/*.py'
- 'agentops/**'
- '.github/workflows/examples-integration-test.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'examples/**/*.py'
- 'agentops/**'
- '.github/workflows/examples-integration-test.yml'
workflow_dispatch:

env:
PYTHON_VERSION: '3.11'

jobs:
test-examples:
runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
fail-fast: false
matrix:
example:
# OpenAI examples
- { path: 'examples/openai/openai_example_sync.py', name: 'OpenAI Sync' }
- { path: 'examples/openai/openai_example_async.py', name: 'OpenAI Async' }
- { path: 'examples/openai/multi_tool_orchestration.py', name: 'OpenAI Multi-Tool' }
- { path: 'examples/openai/web_search.py', name: 'OpenAI Web Search' }

# Anthropic examples
- { path: 'examples/anthropic/anthropic-example-sync.py', name: 'Anthropic Sync' }
- { path: 'examples/anthropic/anthropic-example-async.py', name: 'Anthropic Async' }
- { path: 'examples/anthropic/agentops-anthropic-understanding-tools.py', name: 'Anthropic Tools' }

# LangChain examples
- { path: 'examples/langchain/langchain_examples.py', name: 'LangChain' }

# LiteLLM examples
- { path: 'examples/litellm/litellm_example.py', name: 'LiteLLM' }

# Google Generative AI examples
- { path: 'examples/google_genai/gemini_example.py', name: 'Google Gemini' }

# xAI examples
- { path: 'examples/xai/grok_examples.py', name: 'xAI Grok' }
- { path: 'examples/xai/grok_vision_examples.py', name: 'xAI Grok Vision' }

# CrewAI examples
- { path: 'examples/crewai/job_posting.py', name: 'CrewAI Job Posting' }
- { path: 'examples/crewai/markdown_validator.py', name: 'CrewAI Markdown' }

# AutoGen examples
- { path: 'examples/autogen/AgentChat.py', name: 'AutoGen Agent Chat' }
- { path: 'examples/autogen/MathAgent.py', name: 'AutoGen Math Agent' }

# AG2 examples
- { path: 'examples/ag2/async_human_input.py', name: 'AG2 Async Human Input' }
- { path: 'examples/ag2/tools_wikipedia_search.py', name: 'AG2 Wikipedia Search' }

# Context Manager examples
- { path: 'examples/context_manager/basic_usage.py', name: 'Context Manager Basic' }
- { path: 'examples/context_manager/error_handling.py', name: 'Context Manager Errors' }
- { path: 'examples/context_manager/parallel_traces.py', name: 'Context Manager Parallel' }
- { path: 'examples/context_manager/production_patterns.py', name: 'Context Manager Production' }

# Agno examples
- { path: 'examples/agno/agno_async_operations.py', name: 'Agno Async Operations' }
- { path: 'examples/agno/agno_basic_agents.py', name: 'Agno Basic Agents' }
- { path: 'examples/agno/agno_research_team.py', name: 'Agno Research Team' }
- { path: 'examples/agno/agno_tool_integrations.py', name: 'Agno Tool Integrations' }
- { path: 'examples/agno/agno_workflow_setup.py', name: 'Agno Workflow Setup' }

# Google ADK examples
- { path: 'examples/google_adk/human_approval.py', name: 'Google ADK Human Approval' }

# LlamaIndex examples
- { path: 'examples/llamaindex/llamaindex_example.py', name: 'LlamaIndex' }

# Mem0 examples
- { path: 'examples/mem0/mem0_memoryclient_example.py', name: 'Mem0 Memory Client' }

# Watsonx examples
- { path: 'examples/watsonx/watsonx-streaming.py', name: 'Watsonx Streaming' }
- { path: 'examples/watsonx/watsonx-text-chat.py', name: 'Watsonx Text Chat' }
- { path: 'examples/watsonx/watsonx-tokeniation-model.py', name: 'Watsonx Tokenization' }

# LangGraph examples
- { path: 'examples/langgraph/langgraph_example.py', name: 'LangGraph' }

# Smolagents examples
- { path: 'examples/smolagents/multi_smolagents_system.py', name: 'Smolagents Multi System' }
- { path: 'examples/smolagents/text_to_sql.py', name: 'Smolagents Text to SQL' }

# OpenAI Agents examples
- { path: 'examples/openai_agents/agent_guardrails.py', name: 'OpenAI Agents Guardrails' }
- { path: 'examples/openai_agents/agent_patterns.py', name: 'OpenAI Agents Patterns' }
- { path: 'examples/openai_agents/agents_tools.py', name: 'OpenAI Agents Tools' }
- { path: 'examples/openai_agents/customer_service_agent.py', name: 'OpenAI Agents Customer Service' }

# Add more examples as needed

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install AgentOps
run: |
pip install -e .

- name: Install example dependencies
run: |
# Install common dependencies
pip install python-dotenv requests

# Install from requirements.txt in the example's directory
example_dir=$(dirname "${{ matrix.example.path }}")
if [ -f "$example_dir/requirements.txt" ]; then
echo "Installing dependencies from $example_dir/requirements.txt"
pip install -r "$example_dir/requirements.txt"
else
echo "No requirements.txt found in $example_dir"
fi

- name: Run example - ${{ matrix.example.name }}
env:
AGENTOPS_API_KEY: ${{ secrets.AGENTOPS_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
WATSONX_API_KEY: ${{ secrets.WATSONX_API_KEY }}
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
WATSONX_URL: ${{ secrets.WATSONX_URL }}
MEM0_API_KEY: ${{ secrets.MEM0_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
AI21_API_KEY: ${{ secrets.AI21_API_KEY }}
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
EXA_API_KEY: ${{ secrets.EXA_API_KEY }}
LLAMA_API_KEY: ${{ secrets.LLAMA_API_KEY }}
PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }}
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
PYTHONPATH: ${{ github.workspace }}
run: |
echo "Running ${{ matrix.example.name }}..."
python "${{ matrix.example.path }}" || exit 1

- name: Check for errors
if: failure()
run: |
echo "Example ${{ matrix.example.name }} failed!"
echo "Path: ${{ matrix.example.path }}"

# Show last 50 lines of any log files
if [ -f agentops.log ]; then
echo "=== AgentOps Log ==="
tail -n 50 agentops.log
fi

summary:
needs: test-examples
runs-on: ubuntu-latest
if: always()

steps:
- name: Summary
run: |
echo "## Examples Integration Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ needs.test-examples.result }}" == "success" ]; then
echo "✅ All examples passed!" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Some examples failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
fi
32 changes: 19 additions & 13 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from agentops.helpers.deprecation import deprecated, warn_deprecated_param
import threading

# Import validation functions
from agentops.validation import validate_trace_spans, print_validation_summary, ValidationError

# Thread-safe client management
_client_lock = threading.Lock()
_client = None
Expand Down Expand Up @@ -442,37 +445,40 @@ def extract_key_from_attr(attr_value: str) -> str:


__all__ = [
"init",
"configure",
"get_client",
"record",
"start_trace",
"end_trace",
"update_trace_metadata",
# Legacy exports
"start_session",
"end_session",
"track_agent",
"track_tool",
"end_all_sessions",
"Session",
"ToolEvent",
"ErrorEvent",
"ActionEvent",
"LLMEvent",
"Session",
# Modern exports
"init",
"start_trace",
"end_trace",
"update_trace_metadata",
"Client",
"get_client",
# Decorators
"trace",
"session",
"agent",
"task",
"workflow",
"operation",
"guardrail",
"tracer",
"tool",
# Trace state enums
"guardrail",
# Enums
"TraceState",
"SUCCESS",
"ERROR",
"UNSET",
# OpenTelemetry status codes (for advanced users)
"StatusCode",
# Validation
"validate_trace_spans",
"print_validation_summary",
"ValidationError",
]
Loading
Loading