pub mod system_prompt;
pub mod types;
mod request;
mod response;
mod http;
pub use http::HttpChat;
pub use request::{build_chat_request, build_chat_request_tools};
pub use response::{clean_output, extract_text, parse_chat_response};
pub use system_prompt::system_prompt;
pub use types::{ChatResponse, LlmConfig, Provider, ToolCall, ToolDecl, ToolResult, Turn};
#[allow(async_fn_in_trait)]
pub trait Chat {
async fn chat(
&self,
cfg: &LlmConfig,
system: &str,
turns: &[Turn],
) -> Result<String, ChatError>;
}
#[derive(Clone, Debug)]
pub struct ChatError(pub String);
impl std::fmt::Display for ChatError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
#[allow(async_fn_in_trait)]
pub trait ToolChat {
async fn chat_tools(
&self,
cfg: &LlmConfig,
system: &str,
turns: &[Turn],
tools: &[ToolDecl],
) -> Result<ChatResponse, ChatError>;
}