1pub mod batch;
13pub mod cache;
14pub mod json_parse;
15pub mod language_models;
16pub mod math;
17pub mod output_parsers;
18pub mod router_llm;
19pub mod runnables;
20pub mod structured_output;
21pub mod token_counter;
22pub mod tools;
23
24pub use json_parse::{parse_llm_json, parse_llm_json_with_retry, LlmJsonParseError};
26
27pub use language_models::{BaseChatModel, BaseLanguageModel};
28pub use output_parsers::{
29 BaseOutputParser, CommaSeparatedListOutputParser, JsonOutputParser, OutputParserError,
30 OutputParserResult, StrOutputParser, StructuredOutputParser, TypedOutputParser,
31};
32pub use runnables::{Runnable, RunnableConfig};
33pub use structured_output::{
34 stream_structured_output, with_structured_output, PartialJsonError, PartialJsonParser,
35 StreamingStructuredOutputExt, StructuredOutputError, StructuredOutputExt,
36};
37pub use tools::{
38 BaseTool, FunctionCall, FunctionDefinition, StructuredOutput, Tool, ToolCall, ToolCallResult,
39 ToolDefinition, ToolError, ToolRegistry,
40};
41
42#[derive(Debug, thiserror::Error)]
47pub enum CoreError {
48 #[error("Tool error: {0}")]
50 Tool(#[from] ToolError),
51
52 #[error("JSON parse error: {0}")]
54 JsonParse(#[from] LlmJsonParseError),
55
56 #[error("Batch error: {0}")]
58 Batch(#[from] batch::BatchError),
59
60 #[error("Router error: {0}")]
62 Router(#[from] router_llm::RouterError),
63
64 #[error("Structured output error: {0}")]
66 StructuredOutput(#[from] StructuredOutputError),
67
68 #[error("Partial JSON error: {0}")]
70 PartialJson(#[from] PartialJsonError),
71
72 #[error("Output parser error: {0}")]
74 OutputParser(#[from] OutputParserError),
75
76 #[error("Math error: {0}")]
78 Math(#[from] math::MathError),
79
80 #[error("{0}")]
82 Other(String),
83}
84
85impl From<std::convert::Infallible> for CoreError {
87 fn from(_: std::convert::Infallible) -> Self {
88 unreachable!()
89 }
90}
91
92pub fn other_error<E: std::fmt::Display>(err: E) -> CoreError {
95 CoreError::Other(err.to_string())
96}