cognis-core
The foundation crate for Cognis v2, providing the core traits and primitives for building composable AI workflows.
Purpose
cognis-core defines the typed Runnable<I, O> trait, which is the building block of all operations in Cognis. It also provides the essential data structures for chat messages, prompts, output parsing, and functional composition.
Key Features
- Runnable Trait: A standardized interface for any unit of work that can be invoked, batched, or streamed.
- Composition: Primitives like
pipe,Parallel, andBranchto build complex chains from simple runnables. - Messages: Typed chat messages (
SystemMessage,HumanMessage,AiMessage,ToolMessage) with support for multi-modal content. - Prompts: Template systems for generating formatted strings or message sequences.
- Output Parsers: Tools to transform raw LLM output into structured data (JSON, XML, lists, etc.).
- Wrappers: Higher-order runnables for
Retry,Fallback,Timeout, andCache.
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic Example: Defining and Piping Runnables
use *;
use async_trait;
;
async