Skip to content

Commit 495251c

Browse files
htahir1github-actions[bot]strickvl
committed
Add an agent in production example (#3890)
* Add ZenML introduction to README.md * added agent example * Update evaluation pipeline max items to 100, 125, and 125 * Add document analysis pipeline and evaluation pipeline * Code review * Simplify analysis result extraction from artifacts * Refactor artifact loading and handling logic * Add "Your First AI Pipeline" section to table of contents * Add your first AI pipeline example for ZenML * Add login command for ZenML dashboard * Update Docker command for container startup * Update Docker compose command to start containers * Add architecture overview and screenshots * Add figures for pipeline visualization in ZenML dashboard * Add reasons for using pipelines in AI/ML workflows * Revise AI pipeline benefits in quickstart guide * Update AI pipeline architecture diagram layout * Update flowchart orientation to top to bottom * Add architecture overview in getting started guide * Add example installation instructions and architecture overview * Add whitespace and update comments for clarity * Update AI pipeline and examples with new links and services * Update ZenML hello-world.md with login step & new links.- * Refactor quickstart README for clarity and consistency * Add FloraCast and Retail Forecast to projects list * Update mypy configuration to ignore missing imports * Update ignore_missing_imports setting in pyproject.toml * Update links in README and fix relative path in docs * Add initial pipeline analysis and evaluation diagrams * Images * Delete test.html and add architecture.png image.<commit message> * Optimised images with calibre/image-actions * Update Argilla documentation links to correct URLs * Update docs/book/getting-started/your-first-ai-pipeline.md * Update docs/book/getting-started/your-first-ai-pipeline.md * Add new ML pipeline examples to README.md * Update README with new example images and links * Add example-06 and example-07 images to user guide * Add ZenML Pro cover image --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Alex Strick van Linschoten <[email protected]> (cherry picked from commit bdd3319)
1 parent ceb945e commit 495251c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3362
-27
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
---
4747

48+
ZenML is a unified MLOps framework that extends the battle-tested principles you rely on for classical ML to the new world of AI agents. It's one platform to develop, evaluate, and deploy your entire AI portfolio - from decision trees to complex multi-agent systems. By providing a single framework for your entire AI stack, ZenML enables developers across your organization to collaborate more effectively without maintaining separate toolchains for models and agents.
49+
50+
4851
## 🚨 The Problem: MLOps Works for Models, But What About AI?
4952

5053
![No MLOps for modern AI](docs/book/.gitbook/assets/readme_problem.png)
@@ -137,6 +140,7 @@ if __name__ == "__main__":
137140
```
138141

139142
**🚀 [See the complete working example →](examples/agent_comparison/)**
143+
Prefer a smaller end-to-end template? Check out the [Minimal Agent Production](examples/minimal_agent_production/) example — a lightweight document analysis service with pipelines, evaluation, and a simple web UI.
140144

141145
**The Result:** A clear winner is selected based on data, not opinions. You have full lineage from the test data and agent versions to the final report and deployment decision.
142146

@@ -269,6 +273,7 @@ The MCP (Model Context Protocol) integration transforms your ZenML metadata into
269273

270274
The best way to learn about ZenML is through our comprehensive documentation and tutorials:
271275

276+
- **[Your First AI Pipeline](https://docs.zenml.io/your-first-ai-pipeline)** - Build and evaluate an AI service in minutes
272277
- **[Starter Guide](https://docs.zenml.io/user-guides/starter-guide)** - From zero to production in 30 minutes
273278
- **[LLMOps Guide](https://docs.zenml.io/user-guides/llmops-guide)** - Specific patterns for LLM applications
274279
- **[SDK Reference](https://sdkdocs.zenml.io/)** - Complete SDK reference
@@ -280,10 +285,11 @@ For visual learners, start with this 11-minute introduction:
280285
### 📖 Production Examples
281286

282287
1. **[Agent Architecture Comparison](examples/agent_comparison/)** - Compare AI agents with LangGraph workflows, LiteLLM integration, and automatic visualizations via custom materializers
283-
2. **[E2E Batch Inference](examples/e2e/)** - Complete MLOps pipeline with feature engineering
284-
3. **[LLM RAG Pipeline](https://github.com/zenml-io/zenml-projects/tree/main/llm-complete-guide)** - Production RAG with evaluation loops
285-
4. **[Agentic Workflow (Deep Research)](https://github.com/zenml-io/zenml-projects/tree/main/deep_research)** - Orchestrate your agents with ZenML
286-
5. **[Fine-tuning Pipeline](https://github.com/zenml-io/zenml-projects/tree/main/gamesense)** - Fine-tune and deploy LLMs
288+
2. **[Minimal Agent Production](examples/minimal_agent_production/)** - Document analysis service with pipelines, evaluation, and web UI
289+
3. **[E2E Batch Inference](examples/e2e/)** - Complete MLOps pipeline with feature engineering
290+
4. **[LLM RAG Pipeline](https://github.com/zenml-io/zenml-projects/tree/main/llm-complete-guide)** - Production RAG with evaluation loops
291+
5. **[Agentic Workflow (Deep Research)](https://github.com/zenml-io/zenml-projects/tree/main/deep_research)** - Orchestrate your agents with ZenML
292+
6. **[Fine-tuning Pipeline](https://github.com/zenml-io/zenml-projects/tree/main/gamesense)** - Fine-tune and deploy LLMs
287293

288294
### 🏢 Deployment Options
289295

129 KB
Loading
106 KB
Loading
169 KB
Loading

docs/book/component-guide/annotators/argilla.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Argilla distinguishes itself for its focus on specific use cases and human-in-th
1414

1515
If you need to label textual data as part of your ML workflow, that is the point at which you could consider adding the Argilla annotator stack component as part of your ZenML stack.
1616

17-
We currently support the use of annotation at the various stages described in[the main annotators docs page](./). The Argilla integration currently is built to support annotation using a local (Docker-backed) instance of Argilla as well as a deployed instance of Argilla. There is an easy way to deploy Argilla as a [Hugging Face Space](https://huggingface.co/docs/hub/spaces-sdks-docker-argilla), for instance, which is documented in the [Argilla documentation](https://docs.argilla.io/latest/getting_started/quickstart/).
17+
We currently support the use of annotation at the various stages described in[the main annotators docs page](./). The Argilla integration currently is built to support annotation using a local (Docker-backed) instance of Argilla as well as a deployed instance of Argilla. There is an easy way to deploy Argilla as a [Hugging Face Space](https://huggingface.co/docs/hub/spaces-sdks-docker-argilla), for instance, which is documented in the [Argilla documentation](https://argilla.io/).
1818

1919
### How to deploy it?
2020

@@ -89,6 +89,6 @@ dataset = annotator.get_dataset("dataset_name")
8989
annotations = annotator.get_labeled_data(dataset_name="dataset_name")
9090
```
9191

92-
For more detailed information on how to use the Argilla annotator and the functionality it provides, visit the [Argilla documentation](https://docs.argilla.io/latest/).
92+
For more detailed information on how to use the Argilla annotator and the functionality it provides, visit the [Argilla documentation](https://argilla.io/).
9393

9494
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>

docs/book/getting-started/hello-world.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ Start by installing ZenML in a fresh Python environment:
1717

1818
```bash
1919
pip install zenml
20+
zenml login
2021
```
2122

22-
This gives you access to both the ZenML Python SDK and CLI tools.
23+
This gives you access to both the ZenML Python SDK and CLI tools. It also surfaces the
24+
ZenML dashboard + connects it to your local client.
2325
{% endstep %}
2426

2527
{% step %}
@@ -128,8 +130,8 @@ To continue your ZenML journey, explore these key topics:
128130
* **Organization**: Use [tags](../how-to/tags/tags.md) and [metadata](../how-to/metadata/metadata.md) to keep your AI projects structured
129131

130132
**For LLMs and AI Agents:**
131-
* **LLMOps Guide**: Follow our comprehensive [LLMOps Guide](https://docs.zenml.io/user-guides/llmops-guide) for agent development patterns
132-
* **Agent Evaluation**: Learn to [systematically evaluate](https://github.com/zenml-io/zenml-projects/tree/main/llm-complete-guide) and compare different agent architectures
133+
* **LLMOps Guide**: Write your [first AI pipeline](your-first-ai-pipeline.md) for agent development patterns
134+
* **Agent Evaluation**: Learn to [systematically evaluate](https://github.com/zenml-io/zenml/tree/main/examples/agent_comparison) and compare different agent architectures
133135
* **Prompt Management**: Version and track prompts, tools, and agent configurations as [artifacts](../how-to/artifacts/artifacts.md)
134136

135137
**Infrastructure & Deployment:**
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
description: Build your first AI pipeline and service with ZenML in minutes.
3+
icon: rocket
4+
---
5+
6+
## Your First AI Pipeline
7+
8+
Build and evaluate a real AI service powered by a ZenML pipeline. This quickstart works out of the box with a deterministic fallback and upgrades seamlessly to LLMs when you add a provider API key.
9+
10+
{% hint style="info" %}
11+
Why pipelines?
12+
- **Reproducible & portable**: Run the same code locally or on the cloud by switching stacks.
13+
- **One approach for models and agents**: Steps, pipelines, and artifacts work for sklearn and LLMs alike.
14+
- **Evaluate & observe by default**: Quality reports, lineage, and step metadata (tokens, latency) out of the box.
15+
{% endhint %}
16+
17+
Modeling agents as pipelines makes non-deterministic workflows debuggable and shippable: prompts, tools, and routing become explicit steps; runs produce versioned artifacts (including traces and metrics) you can compare and evaluate. This is the same pattern you use for classical ML, so agents and models share the lifecycle and tooling.
18+
19+
### What you'll build
20+
- **Document analysis service**: A FastAPI app that triggers a ZenML pipeline
21+
- **LLM-first with fallback**: Uses [LiteLLM](https://github.com/BerriAI/litellm) if an API key is set, otherwise runs a deterministic analysis that doesn't require making an API request to an LLM service
22+
- **Tracked artifacts**: Summary, keywords, sentiment, readability, and rich metadata
23+
- **Quality evaluation**: A separate pipeline that annotates runs and generates an HTML report
24+
25+
### Architecture (at a glance)
26+
27+
```mermaid
28+
---
29+
config:
30+
layout: elk
31+
theme: mc
32+
---
33+
flowchart TB
34+
subgraph Evaluation["Evaluation Pipeline"]
35+
R1["load recent analyses"]
36+
R2["annotate and score"]
37+
R3["render evaluation HTML"]
38+
end
39+
subgraph s1["Document Analysis Pipeline"]
40+
S1["ingest_document_step"]
41+
S2["analyze_document_step LLM or fallback"]
42+
S3["render_report_step"]
43+
end
44+
subgraph s2["Stack"]
45+
O[("Orchestrator - local or remote")]
46+
AR["Artifact Store"]
47+
end
48+
U["User / Client"] --> A["FastAPI app"]
49+
A -- Triggers on document upload --> s1
50+
S1 --> S2
51+
S2 --> S3
52+
S3 -- DocumentAnalysisResult --> AR
53+
R1 --> R2
54+
R2 --> R3
55+
U -- Triggers to evaluate app --> Evaluation
56+
Evaluation -- Executes on --> O
57+
s1 -- Executes on --> O
58+
style s1 fill:#E1BEE7,stroke:#AA00FF
59+
style Evaluation fill:#E1BEE7,stroke:#AA00FF
60+
```
61+
62+
### Prerequisites
63+
64+
```bash
65+
pip install "zenml[server]"
66+
zenml init
67+
```
68+
69+
Optional (for LLM mode via LiteLLM, OpenAI shown):
70+
```bash
71+
export OPENAI_API_KEY="your-key"
72+
```
73+
74+
### Get the example
75+
76+
```bash
77+
git clone --depth 1 https://github.com/zenml-io/zenml.git
78+
cd zenml/examples/minimal_agent_production
79+
pip install -r requirements.txt
80+
```
81+
{% hint style="info" %}
82+
Already have the repo? Just `cd examples/minimal_agent_production` and continue.
83+
{% endhint %}
84+
85+
### Run the service
86+
87+
```bash
88+
uvicorn app.main:app --reload --port 8010
89+
```
90+
91+
Open `http://localhost:8010` to use the UI, or call it programmatically:
92+
```bash
93+
curl -X POST http://localhost:8010/analyze \
94+
-H 'Content-Type: application/json' \
95+
-d '{
96+
"filename": "sample-report.txt",
97+
"content": "This is a sample document for analysis...",
98+
"document_type": "report",
99+
"analysis_type": "full"
100+
}'
101+
```
102+
103+
The endpoint triggers a ZenML pipeline run that stores detailed results and metadata you can inspect in the dashboard.
104+
105+
<figure>
106+
<img src="../.gitbook/assets/your_first_pipeline_ui.png" alt="FastAPI document analysis UI">
107+
<figcaption>The web UI served by uvicorn at <code>http://localhost:8010</code>.</figcaption>
108+
</figure>
109+
110+
### Inspect your pipeline runs
111+
112+
```bash
113+
zenml login --local
114+
```
115+
116+
In the dashboard, open the latest run to explore:
117+
- **Steps** like `ingest_document_step`, `analyze_document_step`, `render_report_step`
118+
- **Artifacts** like `DocumentAnalysis` with summary, keywords, sentiment, readability score
119+
- **Metadata** such as latency, token usage, and model name (when in LLM mode)
120+
121+
<figure>
122+
<img src="../.gitbook/assets/your_first_pipeline_analysis.png" alt="Document analysis pipeline DAG in ZenML dashboard">
123+
<figcaption>Document analysis pipeline DAG with step-level artifacts and metadata.</figcaption>
124+
</figure>
125+
126+
### Evaluate quality
127+
128+
Generate a quality report across recent analyses:
129+
```bash
130+
python run_evaluation.py
131+
```
132+
133+
Open the run in the dashboard and locate the HTML report artifact with per-item annotations (summary quality, keyword relevance, sentiment accuracy, completeness) and aggregated scores.
134+
135+
<figure>
136+
<img src="../.gitbook/assets/your_first_pipeline_pipeline_evaluation.png" alt="Evaluation pipeline DAG in ZenML dashboard">
137+
<figcaption>Evaluation pipeline producing an HTML report artifact with aggregated metrics.</figcaption>
138+
</figure>
139+
140+
### How it works (at a glance)
141+
142+
- The FastAPI app forwards requests to the `document_analysis_pipeline` in `pipelines/production.py`
143+
- The `analyze` step uses LiteLLM if an API key is configured, otherwise a deterministic analyzer
144+
- Artifacts are versioned and traceable; evaluation runs read past analyses and render a report
145+
146+
Key files to explore:
147+
- `examples/minimal_agent_production/pipelines/production.py`
148+
- `examples/minimal_agent_production/steps/analyze.py`
149+
- `examples/minimal_agent_production/run_evaluation.py`
150+
151+
### Production next steps
152+
- **Run remotely**: Configure a remote stack/orchestrator and run the same pipeline on managed compute. See [Deploy](deploying-zenml/README.md)
153+
- **Automate triggering**: [Create a run template](https://docs.zenml.io/user-guides/tutorial/trigger-pipelines-from-external-systems) (ZenML Pro) and trigger via API/webhooks from your app
154+
- **Operationalize**: Add caching, retries, schedules, and CI/CD using concepts in the docs
155+
156+
### Extend it
157+
158+
- Swap LLMs/providers through LiteLLM without code changes
159+
- Add guardrails/structured outputs via Pydantic models
160+
- Add retrieval or additional steps for more advanced analysis
161+
162+
Looking for the code? Browse the complete example at `examples/minimal_agent_production`.
397 KB
Loading

docs/book/toc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [Welcome to ZenML](introduction.md)
66
* [Installation](getting-started/installation.md)
77
* [Hello World](getting-started/hello-world.md)
8+
* [Your First AI Pipeline](getting-started/your-first-ai-pipeline.md)
89
* [Core Concepts](getting-started/core-concepts.md)
910
* [System Architecture](getting-started/system-architectures.md)
1011

503 KB
Loading

0 commit comments

Comments
 (0)