Synwire

Synwire is an async-first Rust framework for building LLM-powered applications, designed around trait-based composition and zero unsafe code.

Key features

  • Trait-based architecture -- swap providers, vector stores, and tools via trait objects
  • Async-first -- all I/O uses async/await with Tokio
  • Graph orchestration -- build stateful agent workflows with StateGraph
  • Type-safe macros -- #[tool] and #[derive(State)] for ergonomic definitions
  • Comprehensive testing -- FakeChatModel and FakeEmbeddings for offline testing
  • Zero unsafe code -- #![forbid(unsafe_code)] in core crates

Quick example

use synwire_core::language_models::{FakeChatModel, BaseChatModel};
use synwire_core::messages::Message;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let model = FakeChatModel::new(vec!["Hello from Synwire!".into()]);
    let messages = vec![Message::human("Hi")];
    let result = model.invoke(&messages, None).await?;
    println!("{}", result.message.content().as_text());
    Ok(())
}

Crate overview

CrateDescription
synwire-coreCore traits: BaseChatModel, Embeddings, VectorStore, Tool, RunnableCore
synwire-orchestratorGraph-based orchestration: StateGraph, CompiledGraph, channels
synwire-checkpointCheckpoint traits and in-memory implementation
synwire-checkpoint-sqliteSQLite checkpoint backend
synwire-llm-openaiOpenAI provider (ChatOpenAI, OpenAIEmbeddings)
synwire-llm-ollamaOllama provider (ChatOllama, OllamaEmbeddings)
synwire-deriveProcedural macros (#[tool], #[derive(State)])
synwire-test-utilsFake models, proptest strategies, fixture builders
synwireConvenience re-exports, caches, text splitters, few-shot prompts
  • Getting Started -- step-by-step tutorials from first chat to graph agents
  • How-To Guides -- task-focused recipes for common operations
  • Explanation -- design rationale and architecture decisions
  • Reference -- glossary, error guide, feature flags
  • Contributing -- setup, style guide