pub use async_trait::async_trait;
use chat::Tool;
use serde::{Deserialize, Serialize};
pub mod backends;
pub mod providers;
pub mod builder;
pub mod chain;
pub mod chat;
pub mod completion;
pub mod embedding;
pub mod error;
pub mod validated_llm;
pub mod resilient_llm;
pub mod evaluator;
pub mod stt;
pub mod tts;
pub mod secret_store;
pub mod models;
#[macro_use]
pub mod memory;
#[cfg(feature = "agent")]
pub mod agent;
#[cfg(feature = "api")]
pub mod api;
#[inline]
pub fn init_logging() {
#[cfg(feature = "logging")]
{
let _ = env_logger::try_init();
}
}
pub trait LLMProvider:
chat::ChatProvider
+ completion::CompletionProvider
+ embedding::EmbeddingProvider
+ stt::SpeechToTextProvider
+ tts::TextToSpeechProvider
+ models::ModelsProvider
{
fn tools(&self) -> Option<&[Tool]> {
None
}
}
#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)]
pub struct ToolCall {
pub id: String,
#[serde(rename = "type", default = "default_call_type")]
pub call_type: String,
pub function: FunctionCall,
}
pub fn default_call_type() -> String {
"function".to_string()
}
#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)]
pub struct FunctionCall {
pub name: String,
pub arguments: String,
}
impl std::fmt::Display for ToolCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{{\n \"id\": \"{}\",\n \"type\": \"{}\",\n \"function\": {}\n}}",
self.id, self.call_type, self.function
)
}
}
impl std::fmt::Display for FunctionCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{{\n \"name\": \"{}\",\n \"arguments\": {}\n}}",
self.name, self.arguments
)
}
}