Commit e19cfe0
authored
docs(examples): curate to 47 scenario-shaped examples (#37)
* docs(examples): curate to 47 scenario-shaped examples
Cuts the example set from 102 to 47 and reshapes every keeper around a
recognizable real-world situation a developer would say "yes, that's
my problem" to — replacing the API-tour shape that read like an
integration test.
# What every keeper looks like now
Standard header at the top of every file:
//! What you'll learn: <one-sentence takeaway>
//! Why this matters: <when you'd reach for this in your code>
//! Scenario: <the situation the body enacts>
//! Run with: <exact cargo command>
//! Sample output: <real output captured against ollama / llama3.1>
So a developer browsing the repo can decide whether the example is what
they want without running it.
# Scenarios (a sample)
- `memory_types` — a user introduces themselves, plans a trip, then
asks the agent to recall their name from turn 1; we run the same
conversation through Buffer / Window(2) / TokenBufferMemory(200)
and watch which still remember.
- `agents_conversational` — multi-turn recall test ("what's my name").
- `agents_multi_agent` — Sequential planner -> executor for a real
team-standup task.
- `chains_structured_extraction` — parse a meeting note into a typed
Vec<ActionItem { who, what, due }>.
- `chains_pipe_operator` — triage incoming support tickets through
embed -> categorize -> tag.
- `models_embedding` — find the most similar product description for
a search query.
- `models_routing` — route greetings to a fast model, technical
questions to a bigger one.
- `tools_orchestrator` — fan out three slow price-fetch tools in
parallel, fold to the cheapest.
- `retrieval_indexing_rag` — docs site re-indexer; round 1 indexes 3
docs, edit one, round 2 only re-embeds the changed doc.
- `graphs_with_checkpoints` — resumable 5-step ETL pipeline (extract /
validate / transform / load / notify) with per-step snapshots.
- `graphs_interrupts` — agent drafts a customer email; graph pauses
before the `send` node so a reviewer can approve, then resumes.
- `obs_evaluation` — regression eval over 5 known FAQ pairs you'd run
in CI to catch quality regressions.
- `resilience_ssrf_protection` — URL-fetch tool that gets a URL from
user input; reject 10.x / 192.168.x / localhost / 169.254 (cloud
metadata) before the request leaves your process.
# Cuts
Removed examples that were:
- staged demos using fake providers (StaticEcho / EchoProvider /
CannedProvider / FakeProvider / Tagged)
- hand-crafted AiMessage / Message construction to demonstrate
internals
- partial-step tours of an API surface that other examples already
cover end-to-end (chains_simple, chains_composition, retrieval/{
vector_store, document_store, vector_store_search,
rag_with_vectorstore, document_compression, cross_encoder,
document_transformers}, graphs/{validation, visualization, runtime,
metrics, debug, dot_export, analysis, ...})
- pure-internal demos (obs_callback_manager, obs_tracing,
agents_bus_pubsub, agents_lifecycle, agents_execution_hooks,
agents_plugin_system, agents_planning_middleware)
55 files removed, 7 merged, 47 retained.
# Verification
- `cargo build -p cognis-examples` clean.
- All 47 ran end-to-end against Ollama (llama3.1 + nomic-embed-text);
captured sample output is in each file's header.
- `graphs_interrupts` rebuilt to compile two graph variants (one with
interrupts, one without) so resume actually advances past the
pause point.
# Docs
- `docs/mintlify/examples/*` — 12 mdx pages updated to reflect the
curated list. Tables now read "Name | Scenario | Source".
- `docs/mintlify/examples/index.mdx` — counts updated, header
template documented for first-time visitors.
- `README.md` — example commands list refreshed.
# Out of scope
- `crates/v1/` — frozen V1 source, untouched.
- `models_content_blocks` — needs a vision model (`llava` or hosted
vision-capable model). Captured output reflects llama3.1 (no vision)
refusing the request; header notes the model requirement.
* chore: apply rustfmt to all 47 examples
Pre-push checklist miss on the previous commit. Running `cargo fmt --all`
on the curated example set; no behavior changes.1 parent acdc8b7 commit e19cfe0
116 files changed
Lines changed: 2764 additions & 3363 deletions
File tree
- crates/examples
- docs/mintlify/examples
- examples
- agents
- chains
- graphs
- memory
- models
- observability
- parsers
- resilience
- retrieval
- tools
- v2
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
| 279 | + | |
281 | 280 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | 281 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
297 | 295 | | |
298 | 296 | | |
299 | 297 | | |
300 | | - | |
| 298 | + | |
301 | 299 | | |
302 | 300 | | |
303 | 301 | | |
| |||
0 commit comments