Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cognis.vasanth.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Every example lives under examples/ in the repo. They’re real, runnable programs — not snippets — and each one is shaped around a recognizable scenario, not an API tour.

How each example is shaped

Open any file and you’ll see this header at the top:
//! 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:        <captured against Ollama / llama3.1>
So you can decide whether the example is what you want without running it.

How to run

git clone https://github.com/0xvasanth/cognis.git
cd cognis
cargo run -p cognis-examples --example <NAME>
For LLM-backed examples, set COGNIS_PROVIDER plus the matching key. The simplest path is local Ollama — no key needed:
ollama pull llama3.1
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
  cargo run -p cognis-examples --example agents_react_agent
See Environment variables for the full provider env-var table, and Quickstart for the smallest working agent.

Categories

Quickstart V2

8 numbered demos that walk the V2 surface end-to-end. The fastest way to learn the shape of every layer.

Chains

4 examples on composition — pipe, structured extraction, typed runnables, dirty-JSON repair.

Agents

5 examples on the agent loop — ReAct, conversational memory, multi-agent, planning, streaming events.

Memory

3 examples covering the memory variants — Buffer/Window/TokenBuffer trade-offs, summary compaction, knowledge-graph triples.

Models

4 examples on LLM clients — streaming, embeddings + similarity search, length-based model routing, multimodal.

Tools

4 examples on tool definition and dispatch — typed schemas, multi-tool agent, orchestrator DAG, stateful HTTP.

Retrieval

5 examples on RAG — splitters, end-to-end pipeline, incremental indexing, cross-encoder reranking, caching.

Graphs

5 examples on Graph<S> — polling state machines, checkpointing, HITL interrupts, semantic routing, topic channels.

Observability

3 examples on observers, evaluation harness, and pre-flight health checks.

Resilience

4 examples on error handling, retry/backoff, cost-based rate limiters, SSRF guards.

Parsers

2 examples on output-fixing and retry parsers — making structured output robust against bad model JSON.

Looking for something larger?

Standalone examples show one feature at a time. For full applications that combine several layers (research assistants, code Q&A over a repo, multi-agent debate, streaming UIs, more), see Patterns.