pub struct RecordingProvider<M> { /* private fields */ }Expand description
包裹任意 BaseChatModel:成功响应后把请求/响应对追加到 JSONL。
Implementations§
Source§impl<M> RecordingProvider<M>
impl<M> RecordingProvider<M>
Sourcepub fn bind_tools(&self, tools: Vec<ToolDefinition>) -> Selfwhere
M: Clone,
pub fn bind_tools(&self, tools: Vec<ToolDefinition>) -> Selfwhere
M: Clone,
绑定工具:返回一个记录该工具集的新实例。
后续 chat 会把工具定义录进 RecordedExchange.tools,让回放侧
能按工具名路由(见 crate::ReplayStrategy::ByToolName)。
Trait Implementations§
Source§impl<M> BaseChatModel for RecordingProvider<M>
impl<M> BaseChatModel for RecordingProvider<M>
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Chat with the model. Read more
Source§fn stream_chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<String, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream_chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<String, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream chat with the model. Read more
Source§fn bind_tools(
&self,
tools: Vec<ToolDefinition>,
) -> Option<Box<dyn BaseChatModel<Error = Self::Error> + Send + Sync>>
fn bind_tools( &self, tools: Vec<ToolDefinition>, ) -> Option<Box<dyn BaseChatModel<Error = Self::Error> + Send + Sync>>
Bind tool definitions for function calling. Read more
Source§impl<M> BaseLanguageModel<Vec<Message>, LLMResult> for RecordingProvider<M>
impl<M> BaseLanguageModel<Vec<Message>, LLMResult> for RecordingProvider<M>
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Returns the model name.
Source§fn temperature(&self) -> Option<f32>
fn temperature(&self) -> Option<f32>
Returns the temperature parameter.
Source§fn max_tokens(&self) -> Option<usize>
fn max_tokens(&self) -> Option<usize>
Returns the max tokens limit.
Source§fn with_temperature(self, temp: f32) -> Self
fn with_temperature(self, temp: f32) -> Self
Sets the temperature parameter.
Source§fn with_max_tokens(self, max: usize) -> Self
fn with_max_tokens(self, max: usize) -> Self
Sets the max tokens limit.
Source§impl<M> Runnable<Vec<Message>, LLMResult> for RecordingProvider<M>
impl<M> Runnable<Vec<Message>, LLMResult> for RecordingProvider<M>
Source§type Error = TestkitError
type Error = TestkitError
Error type.
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Transforms single input to output. Read more
Source§fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Output>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Output>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Batch processing - transforms multiple inputs to outputs. Read more
Source§fn batch_as_completed<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(usize, Output)>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn batch_as_completed<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(usize, Output)>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Batch processing that returns results in completion order. Read more
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
input: Input,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
input: Input,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Streaming output - for real-time responses (LLM, etc). Read more
Source§fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<Input, Self::Error>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send + 'life0>>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<Input, Self::Error>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send + 'life0>>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Stream-to-stream transformation - the core of LCEL streaming. Read more
Auto Trait Implementations§
impl<M> Freeze for RecordingProvider<M>where
M: Freeze,
impl<M> RefUnwindSafe for RecordingProvider<M>where
M: RefUnwindSafe,
impl<M> Send for RecordingProvider<M>where
M: Send,
impl<M> Sync for RecordingProvider<M>where
M: Sync,
impl<M> Unpin for RecordingProvider<M>where
M: Unpin,
impl<M> UnsafeUnpin for RecordingProvider<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for RecordingProvider<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<M> StreamingStructuredOutputExt for Mwhere
M: BaseChatModel,
impl<M> StreamingStructuredOutputExt for Mwhere
M: BaseChatModel,
Source§fn stream_structured_output<'life0, 'life1, 'async_trait, T>(
&'life0 self,
schema: Value,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<T, StructuredOutputError>> + Send>>, StructuredOutputError>> + Send + 'async_trait>>
fn stream_structured_output<'life0, 'life1, 'async_trait, T>( &'life0 self, schema: Value, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<T, StructuredOutputError>> + Send>>, StructuredOutputError>> + Send + 'async_trait>>
Stream structured output from a chat model. Read more
Source§impl<M> StructuredOutputExt for Mwhere
M: BaseChatModel,
impl<M> StructuredOutputExt for Mwhere
M: BaseChatModel,
Source§fn with_structured_output<'life0, 'life1, 'async_trait, T>(
&'life0 self,
schema: Value,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, StructuredOutputError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: Sync + 'async_trait,
fn with_structured_output<'life0, 'life1, 'async_trait, T>(
&'life0 self,
schema: Value,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, StructuredOutputError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: Sync + 'async_trait,
Call the LLM with a JSON schema and prompt, returning a parsed result of type
T. Read more