mod chain; pub use chain::HookChain; use crate::PythonOwned; use litellm_host::hooks::{CallHooks, HookRuntime, RuntimeCallEvent}; use pyo3::prelude::*; use pyo3::types::PyDict; /// What a hook step produced: either the value the driver asked for, or a Python /// awaitable the driver hands back to the caller's task before asking again. pub type HookResume = fn(&mut L, Python<'_>, PyResult>) -> PyResult>; pub enum HookStep { Await(Py, HookResume), Ready(T), } pub struct PythonRuntime; impl HookRuntime for PythonRuntime { type Context<'a> = Python<'a>; type Arguments = Py; type Response = Py; type Chunk = Py; type Error = PyErr; type Step = HookStep; fn ready(value: T) -> Self::Step { HookStep::Ready(value) } } pub type PythonCallEvent<'a> = RuntimeCallEvent<'a, PythonRuntime>; pub trait PythonCallHooks: CallHooks + PythonOwned {} impl + PythonOwned> PythonCallHooks for H {}