agent_chain_core/
lib.rs

1//! Agent Chain Core - A Rust implementation of LangChain core library.
2//!
3//! This crate provides:
4//! - Message types for LLM conversations (human, AI, system, tool)
5//! - Tool trait and `#[tool]` macro for function calling
6//! - Chat model abstractions and provider integrations
7//! - Support for multiple providers (Anthropic, OpenAI, etc.)
8//!
9//! # Architecture
10//!
11//! The architecture follows LangChain's pattern:
12//!
13//! - **Core layer** ([`chat_model`]): Base `ChatModel` trait that all providers implement
14//! - **Message layer** ([`messages`]): Message types for conversations
15//! - **Tools layer** ([`tools`]): Tool definitions and the `#[tool]` macro
16//!
17//! # Quick Start
18//!
19//! ```ignore
20//! use agent_chain_core::{init_chat_model, HumanMessage};
21//!
22//! // Initialize a model - provider is inferred from name
23//! let model = init_chat_model("claude-sonnet-4-5-20250929", None)?;
24//!
25//! // Or specify explicitly
26//! let model = init_chat_model("my-custom-model", Some("openai"))?;
27//!
28//! // Use the model
29//! let messages = vec![HumanMessage::new("Hello!").into()];
30//! let response = model.generate(messages, None).await?;
31//! ```
32//!
33//! # Feature Flags
34//!
35//! - `default`: Includes all providers
36//! - `specta`: Specta derive support
37
38pub mod chat_models;
39pub mod error;
40pub mod messages;
41pub mod tools;
42
43// Re-export error types
44pub use error::{Error, Result};
45
46// Re-export core chat model types
47pub use chat_models::{
48    BoundChatModel, ChatChunk, ChatModel, ChatModelExt, ChatResult, ChatResultMetadata, ChatStream,
49    DynBoundChatModel, DynChatModelExt, LangSmithParams, ToolChoice, UsageMetadata,
50};
51
52// Re-export message types
53pub use messages::{
54    AIMessage, AnyMessage, BaseMessage, ContentPart, HasId, HumanMessage, ImageDetail, ImageSource,
55    MessageContent, SystemMessage, ToolCall, ToolMessage,
56};
57
58// Re-export tool types
59pub use tools::{Tool, ToolDefinition, tool};
60
61// Re-export async_trait for use in generated code
62pub use async_trait::async_trait;