1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Core traits and types for the `rune-chain` LLM orchestration framework.
//!
//! `rune-chain-core` is the foundation layer of the `rune-chain-*` crate family —
//! a modern, async-first Rust port of the LangChain concept. It defines the shared
//! vocabulary (types, traits, error variants) that every other `rune-chain-*` crate
//! depends on, without pulling in any LLM provider SDK itself.
//!
//! # Features
//!
//! - [`Chain`] — the central trait; implement it to create any unit of LLM work
//! - [`Llm`] — provider-agnostic interface to any large language model
//! - [`Memory`] — pluggable conversation history (in-process, DB, vector store, …)
//! - [`Message`] / [`Role`] — typed conversation turns (System, Human, Ai, Tool)
//! - [`GenerateResult`] / [`TokenUsage`] — structured output with token accounting
//! - [`StreamData`] — incremental token chunks for streaming responses
//! - [`PromptArgs`] + [`prompt_args!`] — ergonomic key-value input for templates
//! - [`ChainError`] / [`LlmError`] — structured error types with `From` wiring
//!
//! # Quick Start
//!
//! Implement [`Chain`] for your own type:
//!
//! ```rust
//! use rune_chain_core::{Chain, ChainError, GenerateResult, PromptArgs, prompt_args};
//! use async_trait::async_trait;
//!
//! struct EchoChain;
//!
//! #[async_trait]
//! impl Chain for EchoChain {
//! async fn call(&self, input: PromptArgs) -> Result<GenerateResult, ChainError> {
//! let text = input
//! .get("input")
//! .and_then(|v| v.as_str())
//! .unwrap_or("")
//! .to_string();
//! Ok(GenerateResult::from_text(text))
//! }
//! }
//!
//! # tokio_test::block_on(async {
//! let chain = EchoChain;
//! let result = chain.invoke(prompt_args! { "input" => "hello" }).await.unwrap();
//! assert_eq!(result, "hello");
//! # });
//! ```
pub use Chain;
pub use ;
pub use ;
pub use Llm;
pub use Memory;
pub use ;
pub use PromptArgs;
pub use StreamData;
pub use Tool;