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](https://img.shields.io/crates/v/rune-chain-core)](https://crates.io/crates/rune-chain-core)
[![docs.rs](https://img.shields.io/docsrs/rune-chain-core)](https://docs.rs/rune-chain-core)
[![license](https://img.shields.io/crates/l/rune-chain-core)](LICENSE)
[![CI](https://github.com/alexile/runes/actions/workflows/ci.yml/badge.svg)](https://github.com/alexile/runes/actions)

## 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

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

## Usage

Implement [`Chain`] for any unit of LLM work:

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

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