pub mod batch;
pub mod cache;
pub mod json_parse;
pub mod language_models;
pub mod math;
pub mod output_parsers;
pub mod router_llm;
pub mod runnables;
pub mod structured_output;
pub mod token_counter;
pub mod tools;
pub use json_parse::{parse_llm_json, parse_llm_json_with_retry, LlmJsonParseError};
pub use language_models::{BaseChatModel, BaseLanguageModel};
pub use output_parsers::{
BaseOutputParser, CommaSeparatedListOutputParser, JsonOutputParser, OutputParserError,
OutputParserResult, StrOutputParser, StructuredOutputParser, TypedOutputParser,
};
pub use runnables::{Runnable, RunnableConfig};
pub use structured_output::{
stream_structured_output, with_structured_output, PartialJsonError, PartialJsonParser,
StreamingStructuredOutputExt, StructuredOutputError, StructuredOutputExt,
};
pub use tools::{
BaseTool, FunctionCall, FunctionDefinition, StructuredOutput, Tool, ToolCall, ToolCallResult,
ToolDefinition, ToolError, ToolRegistry,
};
#[derive(Debug, thiserror::Error)]
pub enum CoreError {
#[error("Tool error: {0}")]
Tool(#[from] ToolError),
#[error("JSON parse error: {0}")]
JsonParse(#[from] LlmJsonParseError),
#[error("Batch error: {0}")]
Batch(#[from] batch::BatchError),
#[error("Router error: {0}")]
Router(#[from] router_llm::RouterError),
#[error("Structured output error: {0}")]
StructuredOutput(#[from] StructuredOutputError),
#[error("Partial JSON error: {0}")]
PartialJson(#[from] PartialJsonError),
#[error("Output parser error: {0}")]
OutputParser(#[from] OutputParserError),
#[error("Math error: {0}")]
Math(#[from] math::MathError),
#[error("{0}")]
Other(String),
}
impl From<std::convert::Infallible> for CoreError {
fn from(_: std::convert::Infallible) -> Self {
unreachable!()
}
}
pub fn other_error<E: std::fmt::Display>(err: E) -> CoreError {
CoreError::Other(err.to_string())
}