rune-chain-core 0.1.1

Core traits and types for the rune-chain LLM orchestration framework
Documentation

rune-chain-core

Core traits and types for the rune-chain LLM orchestration framework.

crates.io docs.rs license CI

What it does

rune-chain-core is the shared foundation for the rune-chain-* family of crates — a modern, async-first Rust port of the LangChain concept. It defines the traits, types, and error variants that all other rune-chain-* crates build on, without depending on any specific LLM provider.

Installation

[dependencies]
rune-chain-core = "0.1"
async-trait = "0.1"

Usage

Implement [Chain] for any unit of LLM work:

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))
    }
}

let chain = EchoChain;
let result = chain.invoke(prompt_args! { "input" => "hello" }).await?;
println!("{result}");

Core abstractions

Item Description
Chain Central trait — implement to create any LLM pipeline step
Llm Provider-agnostic interface to any large language model
Memory Pluggable conversation history
Message / Role Typed turns: System, Human, Ai, Tool
GenerateResult Generated text + optional token usage
StreamData Incremental token chunk for streaming responses
PromptArgs + prompt_args! Ergonomic input map for prompt templates
ChainError / LlmError Structured errors with From conversion between them

License

MIT