Skip to content

Commit e19cfe0

Browse files
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

Some content is hidden

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

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -276,28 +276,26 @@ cognis-rag = { version = "0.2", features = ["faiss", "openai"] }
276276
git clone https://github.com/0xvasanth/cognis.git
277277
cd cognis
278278

279-
# Offline demos (no API keys needed)
280-
cargo run -p cognis-examples --example chains_pipe_operator
279+
# Offline demos (no LLM needed)
281280
cargo run -p cognis-examples --example tools_orchestrator
282-
cargo run -p cognis-examples --example agents_round_robin
283-
cargo run -p cognis-examples --example agents_bus_pubsub
284-
cargo run -p cognis-examples --example memory_entity
285-
cargo run -p cognis-examples --example memory_knowledge_graph
286-
cargo run -p cognis-examples --example retrieval_document_transformers
287281
cargo run -p cognis-examples --example graphs_state_machine
288-
cargo run -p cognis-examples --example graphs_dot_export
289-
cargo run -p cognis-examples --example resilience_advanced_rate_limiters
290-
cargo run -p cognis-examples --example parsers_fixing
291-
cargo run -p cognis-examples --example parsers_retry
292-
293-
# Provider-backed demos (need a running LLM)
294-
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.2:1b \
295-
cargo run -p cognis-examples --example agents_react_agent
296-
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.2:1b \
282+
cargo run -p cognis-examples --example graphs_with_checkpoints
283+
cargo run -p cognis-examples --example graphs_interrupts
284+
cargo run -p cognis-examples --example resilience_ssrf_protection
285+
cargo run -p cognis-examples --example resilience_rate_limiters
286+
287+
# Provider-backed demos (need a running LLM — `ollama pull llama3.1`)
288+
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
289+
cargo run -p cognis-examples --example 02_five_line_agent
290+
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
291+
cargo run -p cognis-examples --example 06_ollama_tool_calling
292+
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
293+
cargo run -p cognis-examples --example agents_conversational
294+
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
297295
cargo run -p cognis-examples --example retrieval_rag_pipeline
298296
```
299297

300-
The full demo set lives under [`examples/`](examples/) — organized by `chains/`, `agents/`, `memory/`, `models/`, `tools/`, `retrieval/`, `graphs/`, `observability/`, `resilience/`, and `parsers/`. Every example is registered in [`crates/examples/Cargo.toml`](crates/examples/Cargo.toml).
298+
47 curated examples live under [`examples/`](examples/) — organized by `v2/` (the numbered onboarding tour), `chains/`, `agents/`, `memory/`, `models/`, `tools/`, `retrieval/`, `graphs/`, `observability/`, `resilience/`, and `parsers/`. Every example file opens with a `What you'll learn / Why this matters / Scenario / Run with / Sample output` header so you can decide whether it's what you want before running.
301299

302300
## Build & test
303301

0 commit comments

Comments
 (0)