|
| 1 | +# Samples Guide |
| 2 | + |
| 3 | +The LayerLens Python SDK ships with 70+ runnable samples covering every API resource, from a single trace evaluation to enterprise compliance pipelines and multi-agent orchestration. All samples live in the [`samples/`](../samples/) directory and can be run directly after installing the SDK and setting your API key. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install layerlens --index-url https://sdk.layerlens.ai/package |
| 9 | +export LAYERLENS_STRATIX_API_KEY=your-api-key |
| 10 | +python samples/core/quickstart.py |
| 11 | +``` |
| 12 | + |
| 13 | +[`quickstart.py`](../samples/core/quickstart.py) walks through the complete workflow end-to-end: upload a trace, create a judge, run an evaluation, and retrieve results. |
| 14 | + |
| 15 | +## Samples by Category |
| 16 | + |
| 17 | +### Core SDK Operations (18 samples) |
| 18 | + |
| 19 | +Located in [`samples/core/`](../samples/core/). Start here to learn how every LayerLens resource -- traces, judges, evaluations, results, models, and benchmarks -- works individually and together, including async patterns and pagination. |
| 20 | + |
| 21 | +Key samples: |
| 22 | +- [`quickstart.py`](../samples/core/quickstart.py) -- Your first evaluation in under 30 lines |
| 23 | +- [`trace_evaluation.py`](../samples/core/trace_evaluation.py) -- Full trace evaluation lifecycle |
| 24 | +- [`judge_optimization.py`](../samples/core/judge_optimization.py) -- Optimize judge accuracy via automated prompt engineering |
| 25 | +- [`evaluation_pipeline.py`](../samples/core/evaluation_pipeline.py) -- Chain judges, traces, and results into an automated pipeline |
| 26 | +- [`async_workflow.py`](../samples/core/async_workflow.py) -- Concurrent operations with AsyncStratix |
| 27 | + |
| 28 | +See the [Core SDK README](../samples/core/README.md) for the full list. |
| 29 | + |
| 30 | +### Industry Solutions (10 samples) |
| 31 | + |
| 32 | +Located in [`samples/industry/`](../samples/industry/). Domain-specific evaluation scenarios with judges tuned for regulated and high-stakes verticals including healthcare, financial services, legal, government, insurance, and retail. |
| 33 | + |
| 34 | +Key samples: |
| 35 | +- [`healthcare_clinical.py`](../samples/industry/healthcare_clinical.py) -- Clinical decision support evaluation |
| 36 | +- [`financial_trading.py`](../samples/industry/financial_trading.py) -- SOX-aligned trading compliance |
| 37 | +- [`legal_contracts.py`](../samples/industry/legal_contracts.py) -- Contract review quality assessment |
| 38 | + |
| 39 | +See the [Industry Solutions README](../samples/industry/README.md) for the full list. |
| 40 | + |
| 41 | +### Multi-Agent Evaluation (5 samples) |
| 42 | + |
| 43 | +Located in [`samples/cowork/`](../samples/cowork/). Patterns for [Claude Cowork](https://claude.com/product/cowork), [Agent Teams](https://code.claude.com/docs/en/agent-teams), or any multi-agent framework where multiple agents collaborate and each agent's output needs independent quality assessment. |
| 44 | + |
| 45 | +Key samples: |
| 46 | +- [`multi_agent_eval.py`](../samples/cowork/multi_agent_eval.py) -- Generator-Evaluator pattern |
| 47 | +- [`code_review.py`](../samples/cowork/code_review.py) -- Instrumentor-Reviewer pattern |
| 48 | +- [`rag_assessment.py`](../samples/cowork/rag_assessment.py) -- RAG quality evaluation |
| 49 | + |
| 50 | +See the [Multi-Agent README](../samples/cowork/README.md) for the full list. |
| 51 | + |
| 52 | +### CI/CD Integration (2 samples + workflow) |
| 53 | + |
| 54 | +Located in [`samples/cicd/`](../samples/cicd/). Embed evaluation quality gates into your build and deployment pipelines so regressions never reach production. |
| 55 | + |
| 56 | +- [`quality_gate.py`](../samples/cicd/quality_gate.py) -- Gate deployments on evaluation pass rates |
| 57 | +- [`pre_commit_hook.py`](../samples/cicd/pre_commit_hook.py) -- Catch regressions at commit time |
| 58 | +- [`github_actions_gate.yml`](../samples/cicd/github_actions_gate.yml) -- Drop-in GitHub Actions workflow |
| 59 | + |
| 60 | +See the [CI/CD README](../samples/cicd/README.md) for details. |
| 61 | + |
| 62 | +### LLM Provider Integrations (2 samples) |
| 63 | + |
| 64 | +Located in [`samples/integrations/`](../samples/integrations/). Trace and evaluate outputs from OpenAI and Anthropic with minimal instrumentation. |
| 65 | + |
| 66 | +- [`openai_traced.py`](../samples/integrations/openai_traced.py) -- Trace an OpenAI completion and evaluate it |
| 67 | +- [`anthropic_traced.py`](../samples/integrations/anthropic_traced.py) -- Capture multi-turn Claude conversations |
| 68 | + |
| 69 | +### Content-Type Evaluations (3 samples) |
| 70 | + |
| 71 | +Located in [`samples/modalities/`](../samples/modalities/). Apply specialized judges to different content types -- text responses, brand assets, and structured documents. |
| 72 | + |
| 73 | +- [`text_evaluation.py`](../samples/modalities/text_evaluation.py) -- Score text across safety, relevance, and compliance |
| 74 | +- [`brand_evaluation.py`](../samples/modalities/brand_evaluation.py) -- Enforce brand voice consistency |
| 75 | +- [`document_evaluation.py`](../samples/modalities/document_evaluation.py) -- Validate document extraction accuracy |
| 76 | + |
| 77 | +### OpenClaw Agent Evaluation (10 demos + skill) |
| 78 | + |
| 79 | +Located in [`samples/openclaw/`](../samples/openclaw/). Trace, evaluate, and monitor [OpenClaw](https://openclaw.ai/) autonomous AI agents using LayerLens -- including cage match model tournaments, code gating, drift detection, content auditing, honeypot skill auditing, and adversarial red-teaming. |
| 80 | + |
| 81 | +See the [OpenClaw README](../samples/openclaw/README.md) for the full list of integration samples and advanced evaluation patterns. |
| 82 | + |
| 83 | +### MCP Server (1 sample) |
| 84 | + |
| 85 | +Located in [`samples/mcp/`](../samples/mcp/). Expose LayerLens capabilities as tools for Claude, Cursor, and any MCP-compatible AI assistant. |
| 86 | + |
| 87 | +- [`layerlens_server.py`](../samples/mcp/layerlens_server.py) -- MCP server with trace management, judge creation, and evaluation execution |
| 88 | + |
| 89 | +See the [MCP README](../samples/mcp/README.md) for setup instructions. |
| 90 | + |
| 91 | +### CopilotKit Integration (2 agents + UI components) |
| 92 | + |
| 93 | +Located in [`samples/copilotkit/`](../samples/copilotkit/). Full-stack integration with CopilotKit using LangGraph CoAgents and generative UI card components. |
| 94 | + |
| 95 | +- [`agents/evaluator_agent.py`](../samples/copilotkit/agents/evaluator_agent.py) -- LangGraph CoAgent for evaluation workflows |
| 96 | +- [`agents/investigator_agent.py`](../samples/copilotkit/agents/investigator_agent.py) -- LangGraph CoAgent for trace investigation |
| 97 | +- [`components/*.tsx`](../samples/copilotkit/components/) -- React card components for rendering results |
| 98 | +- [`hooks/*.ts`](../samples/copilotkit/hooks/) -- CopilotKit hooks for wiring LayerLens actions |
| 99 | + |
| 100 | +See the [CopilotKit README](../samples/copilotkit/README.md) for the full list. |
| 101 | + |
| 102 | +### Claude Code Skills (6 skills) |
| 103 | + |
| 104 | +Located in [`samples/claude-code/`](../samples/claude-code/). Slash commands that bring LayerLens workflows directly into the Claude Code CLI -- manage traces, judges, evaluations, optimizations, benchmarks, and investigations without leaving your terminal. |
| 105 | + |
| 106 | +See the [Claude Code Skills README](../samples/claude-code/README.md) for the full list. |
| 107 | + |
| 108 | +### Sample Data |
| 109 | + |
| 110 | +Located in [`samples/data/`](../samples/data/). Pre-built trace files, test datasets, and 16 industry-specific evaluation datasets so you can run every sample without generating your own data first. |
| 111 | + |
| 112 | +See the [Sample Data README](../samples/data/README.md) for contents. |
| 113 | + |
| 114 | +## Full Sample Reference |
| 115 | + |
| 116 | +For the complete table of every sample with descriptions, see the [samples README](../samples/README.md). |
0 commit comments