pub struct ParrotFakeChatModel { /* private fields */ }Expand description
Generic fake chat model that echoes the last message.
- Chat model should be usable in both sync and async tests
Implementations§
Source§impl ParrotFakeChatModel
impl ParrotFakeChatModel
Sourcepub fn with_config(self, config: ChatModelConfig) -> Self
pub fn with_config(self, config: ChatModelConfig) -> Self
Set the configuration.
Trait Implementations§
Source§impl BaseChatModel for ParrotFakeChatModel
impl BaseChatModel for ParrotFakeChatModel
Source§fn chat_config(&self) -> &ChatModelConfig
fn chat_config(&self) -> &ChatModelConfig
Get the chat model configuration.
Source§fn _generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
_stop: Option<Vec<String>>,
_run_manager: Option<&'life1 CallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn _generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
_stop: Option<Vec<String>>,
_run_manager: Option<&'life1 CallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Core abstract method to generate a chat result. Read more
Source§fn profile(&self) -> Option<&ModelProfile>
fn profile(&self) -> Option<&ModelProfile>
Get the model profile, if available.
Source§fn _agenerate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
_run_manager: Option<&'life1 AsyncCallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn _agenerate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
_run_manager: Option<&'life1 AsyncCallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Async version of
_generate. Read moreSource§fn _stream(
&self,
_messages: Vec<BaseMessage>,
_stop: Option<Vec<String>>,
_run_manager: Option<&CallbackManagerForLLMRun>,
) -> Result<ChatGenerationStream>
fn _stream( &self, _messages: Vec<BaseMessage>, _stop: Option<Vec<String>>, _run_manager: Option<&CallbackManagerForLLMRun>, ) -> Result<ChatGenerationStream>
Stream the output of the model. Read more
Source§fn _astream<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
_run_manager: Option<&'life1 AsyncCallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatGenerationStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn _astream<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
_run_manager: Option<&'life1 AsyncCallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatGenerationStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Async stream the output of the model. Read more
Source§fn get_first_message(&self, result: &ChatResult) -> Result<AIMessage>
fn get_first_message(&self, result: &ChatResult) -> Result<AIMessage>
Get the first AI message from a chat result. Read more
Source§fn _combine_llm_outputs(
&self,
_llm_outputs: &[Option<HashMap<String, Value>>],
) -> HashMap<String, Value>
fn _combine_llm_outputs( &self, _llm_outputs: &[Option<HashMap<String, Value>>], ) -> HashMap<String, Value>
Combine LLM outputs from multiple results. Read more
Source§fn _convert_cached_generations(
&self,
cache_val: Vec<Generation>,
) -> Vec<ChatGeneration>
fn _convert_cached_generations( &self, cache_val: Vec<Generation>, ) -> Vec<ChatGeneration>
Convert cached Generation objects to ChatGeneration objects. Read more
Source§fn _get_invocation_params(
&self,
stop: Option<&[String]>,
kwargs: Option<&HashMap<String, Value>>,
) -> HashMap<String, Value>
fn _get_invocation_params( &self, stop: Option<&[String]>, kwargs: Option<&HashMap<String, Value>>, ) -> HashMap<String, Value>
Get invocation parameters for tracing. Read more
Source§fn _get_llm_string(
&self,
stop: Option<&[String]>,
kwargs: Option<&HashMap<String, Value>>,
) -> String
fn _get_llm_string( &self, stop: Option<&[String]>, kwargs: Option<&HashMap<String, Value>>, ) -> String
Get the LLM string for cache key generation. Read more
Source§fn has_stream_impl(&self) -> bool
fn has_stream_impl(&self) -> bool
Check if
_stream is implemented (not the default). Read moreSource§fn has_astream_impl(&self) -> bool
fn has_astream_impl(&self) -> bool
Check if
_astream is implemented (not the default). Read moreSource§fn has_streaming_field(&self) -> Option<bool>
fn has_streaming_field(&self) -> Option<bool>
Check if streaming is enabled via a model field. Read more
Source§fn _should_stream(
&self,
async_api: bool,
has_tools: bool,
stream_kwarg: Option<bool>,
run_manager: Option<&[Arc<dyn BaseCallbackHandler>]>,
) -> bool
fn _should_stream( &self, async_api: bool, has_tools: bool, stream_kwarg: Option<bool>, run_manager: Option<&[Arc<dyn BaseCallbackHandler>]>, ) -> bool
Determine if a given model call should hit the streaming API. Read more
Source§fn generate<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Vec<BaseMessage>>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Vec<BaseMessage>>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Generate from a batch of message lists. Read more
Source§fn agenerate<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Vec<BaseMessage>>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn agenerate<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Vec<BaseMessage>>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Async version of
generate.Source§fn _call_async<'life0, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<BaseMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn _call_async<'life0, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<BaseMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Async call helper. Read more
Source§fn generate_with_tools<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
_tools: &'life1 [ToolDefinition],
_tool_choice: Option<&'life2 ToolChoice>,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn generate_with_tools<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
_tools: &'life1 [ToolDefinition],
_tool_choice: Option<&'life2 ToolChoice>,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Generate a response from the model with tools. Read more
Source§fn convert_input(&self, input: LanguageModelInput) -> Result<Vec<BaseMessage>>
fn convert_input(&self, input: LanguageModelInput) -> Result<Vec<BaseMessage>>
Convert input to messages.
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Invoke the model with input.
Source§fn ainvoke<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn ainvoke<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
) -> Pin<Box<dyn Future<Output = Result<AIMessage>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Async invoke the model.
Source§fn bind_tools(
&self,
_tools: &[Arc<dyn BaseTool>],
_tool_choice: Option<ToolChoice>,
) -> Result<()>
fn bind_tools( &self, _tools: &[Arc<dyn BaseTool>], _tool_choice: Option<ToolChoice>, ) -> Result<()>
Bind tools to the model. Read more
Source§fn get_tool_definitions(
&self,
tools: &[Arc<dyn BaseTool>],
) -> Vec<ToolDefinition>
fn get_tool_definitions( &self, tools: &[Arc<dyn BaseTool>], ) -> Vec<ToolDefinition>
Get tool definitions from tools. Read more
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessageChunkStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessageChunkStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Generate a streaming response from the model. Read more
Source§fn astream<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessageChunkStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn astream<'life0, 'async_trait>(
&'life0 self,
input: LanguageModelInput,
stop: Option<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<AIMessageChunkStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Async stream the model output. Read more
Source§fn stream_generations<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
run_manager: Option<&'life1 CallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatGenerationStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream_generations<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<BaseMessage>,
stop: Option<Vec<String>>,
run_manager: Option<&'life1 CallbackManagerForLLMRun>,
) -> Pin<Box<dyn Future<Output = Result<ChatGenerationStream>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stream ChatGenerationChunk objects from the model. Read more
Source§fn get_chat_ls_params(&self, stop: Option<&[String]>) -> LangSmithParams
fn get_chat_ls_params(&self, stop: Option<&[String]>) -> LangSmithParams
Get standard params for tracing.
Source§fn to_dict(&self) -> HashMap<String, Value>
fn to_dict(&self) -> HashMap<String, Value>
Get a dictionary representation of the model. Read more
Source§impl BaseLanguageModel for ParrotFakeChatModel
impl BaseLanguageModel for ParrotFakeChatModel
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name/identifier.
Source§fn config(&self) -> &LanguageModelConfig
fn config(&self) -> &LanguageModelConfig
Get the configuration for this model.
Source§fn generate_prompt<'life0, 'async_trait>(
&'life0 self,
prompts: Vec<LanguageModelInput>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_prompt<'life0, 'async_trait>(
&'life0 self,
prompts: Vec<LanguageModelInput>,
stop: Option<Vec<String>>,
_callbacks: Option<Callbacks>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pass a sequence of prompts to the model and return model generations. Read more
Source§fn get_ls_params(&self, stop: Option<&[String]>) -> LangSmithParams
fn get_ls_params(&self, stop: Option<&[String]>) -> LangSmithParams
Get parameters for tracing/monitoring.
Source§fn identifying_params(&self) -> HashMap<String, Value>
fn identifying_params(&self) -> HashMap<String, Value>
Get the identifying parameters for this model.
Source§fn get_token_ids(&self, text: &str) -> Vec<u32>
fn get_token_ids(&self, text: &str) -> Vec<u32>
Get the ordered IDs of tokens in a text. Read more
Source§fn get_num_tokens(&self, text: &str) -> usize
fn get_num_tokens(&self, text: &str) -> usize
Get the number of tokens present in the text. Read more
Source§fn get_num_tokens_from_messages(&self, messages: &[BaseMessage]) -> usize
fn get_num_tokens_from_messages(&self, messages: &[BaseMessage]) -> usize
Get the number of tokens in the messages. Read more
Source§impl Clone for ParrotFakeChatModel
impl Clone for ParrotFakeChatModel
Source§fn clone(&self) -> ParrotFakeChatModel
fn clone(&self) -> ParrotFakeChatModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParrotFakeChatModel
impl Debug for ParrotFakeChatModel
Source§impl Default for ParrotFakeChatModel
impl Default for ParrotFakeChatModel
Source§fn default() -> ParrotFakeChatModel
fn default() -> ParrotFakeChatModel
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ParrotFakeChatModel
impl !RefUnwindSafe for ParrotFakeChatModel
impl Send for ParrotFakeChatModel
impl Sync for ParrotFakeChatModel
impl Unpin for ParrotFakeChatModel
impl !UnwindSafe for ParrotFakeChatModel
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