Skip to main content

Crate lc_core

Crate lc_core 

Source
Expand description

Core abstractions for LangChainRust.

This crate provides the foundational traits and types:

  • Runnable: Base execution interface
  • BaseLanguageModel: LLM abstraction
  • BaseChatModel: Chat model interface
  • BaseTool, Tool: Tool abstraction
  • RunnableConfig: Execution configuration with callbacks
  • Output parsers, structured output, caching, token counting, batch API

Re-exports§

pub use json_parse::parse_llm_json;
pub use json_parse::parse_llm_json_with_retry;
pub use json_parse::LlmJsonParseError;
pub use judge::structured_call;
pub use judge::truncate;
pub use judge::StructuredJudgeError;
pub use language_models::predict_tools;
pub use language_models::BaseChatModel;
pub use language_models::BaseLanguageModel;
pub use language_models::MultimodalError;
pub use language_models::MultimodalModel;
pub use language_models::PredictToolsError;
pub use language_models::StreamChunk;
pub use language_models::TokenUsage;
pub use output_parsers::BaseOutputParser;
pub use output_parsers::CommaSeparatedListOutputParser;
pub use output_parsers::JsonOutputParser;
pub use output_parsers::OutputParserError;
pub use output_parsers::OutputParserResult;
pub use output_parsers::StrOutputParser;
pub use output_parsers::StructuredOutputParser;
pub use output_parsers::TypedOutputParser;
pub use runnables::into_runnable_any;
pub use runnables::CancellationToken;
pub use runnables::LcelError;
pub use runnables::RetryConfig;
pub use runnables::RetryOn;
pub use runnables::Runnable;
pub use runnables::RunnableAny;
pub use runnables::RunnableAnyWrapper;
pub use runnables::RunnableAssign;
pub use runnables::RunnableBinding;
pub use runnables::RunnableBranch;
pub use runnables::RunnableConfig;
pub use runnables::RunnableConfigurable;
pub use runnables::RunnableConfigurableFields;
pub use runnables::RunnableExt;
pub use runnables::RunnableLambda;
pub use runnables::RunnableParallel;
pub use runnables::RunnablePassthrough;
pub use runnables::RunnablePick;
pub use runnables::RunnableRetry;
pub use runnables::RunnableSequence;
pub use runnables::RunnableWithFallbacks;
pub use structured_output::stream_structured_output;
pub use structured_output::with_structured_output;
pub use structured_output::PartialJsonError;
pub use structured_output::PartialJsonParser;
pub use structured_output::StreamingStructuredOutputExt;
pub use structured_output::StructuredOutputError;
pub use structured_output::StructuredOutputExt;
pub use tools::BaseTool;
pub use tools::FunctionDefinition;
pub use tools::StructuredOutput;
pub use tools::Tool;
pub use tools::ToolDefinition;
pub use tools::ToolError;
pub use tools::ToolRegistry;

Modules§

batch
Batch API client for OpenAI and Anthropic batch processing.
cache
LLM call cache
json_parse
Tolerant JSON parsing for LLM outputs.
judge
Shared LLM judge infrastructure: lets an LLM return a verdict via structured arguments.
language_models
Language model base traits.
math
Shared math utilities.
output_parsers
Output parsers for extracting and transforming LLM response text.
router_llm
Model routing, fallback and load balancing.
runnables
Runnable module - LangChain Expression Language (LCEL) core
ssrf
SSRF protection — a single shared implementation, no copies allowed.
structured_output
Structured output utilities for extracting typed data from LLM responses.
token_counter
Token counter and cost tracking
tools
Tool abstractions for agent function calling.

Structs§

FunctionCall
Function call inside a ToolCall
ToolCall
Tool call from LLM response
ToolCallBuilder
Builder for constructing a ToolCall field by field.
ToolCallResult
Tool call result to send back to LLM

Enums§

CoreError
Unified error type for the lc-core crate.

Functions§

other_error
Helper to convert any error into CoreError::Other. Use this instead of ? when the error type is not a known CoreError variant.