pub struct MockLLMProvider { /* private fields */ }Expand description
Mock LLM Provider(用于测试)
Implementations§
Source§impl MockLLMProvider
impl MockLLMProvider
Sourcepub fn new(name: &str) -> MockLLMProvider
pub fn new(name: &str) -> MockLLMProvider
创建 Mock Provider
Sourcepub fn with_default_response(
self,
response: impl Into<String>,
) -> MockLLMProvider
pub fn with_default_response( self, response: impl Into<String>, ) -> MockLLMProvider
设置默认响应
Sourcepub async fn add_response(&self, response: impl Into<String>)
pub async fn add_response(&self, response: impl Into<String>)
添加预设响应(按顺序返回)
Trait Implementations§
Source§impl LLMProvider for MockLLMProvider
impl LLMProvider for MockLLMProvider
Source§fn default_model(&self) -> &str
fn default_model(&self) -> &str
获取默认模型
Source§fn supported_models(&self) -> Vec<&str>
fn supported_models(&self) -> Vec<&str>
获取支持的模型列表
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
检查是否支持流式输出
Source§fn supports_tools(&self) -> bool
fn supports_tools(&self) -> bool
检查是否支持工具调用
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockLLMProvider: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MockLLMProvider: 'async_trait,
发送 Chat Completion 请求
Source§fn supports_model(&self, model: &str) -> bool
fn supports_model(&self, model: &str) -> bool
检查是否支持某个模型
Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
检查是否支持视觉(图片输入)
Source§fn supports_embedding(&self) -> bool
fn supports_embedding(&self) -> bool
检查是否支持 embedding
Source§fn chat_stream<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ChatCompletionChunk, LLMError>> + Send>>, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn chat_stream<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ChatCompletionChunk, LLMError>> + Send>>, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
发送 Chat Completion 流式请求
Source§fn embedding<'life0, 'async_trait>(
&'life0 self,
_request: EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn embedding<'life0, 'async_trait>(
&'life0 self,
_request: EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse, LLMError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
发送 Embedding 请求
Auto Trait Implementations§
impl !Freeze for MockLLMProvider
impl !RefUnwindSafe for MockLLMProvider
impl Send for MockLLMProvider
impl Sync for MockLLMProvider
impl Unpin for MockLLMProvider
impl UnsafeUnpin for MockLLMProvider
impl !UnwindSafe for MockLLMProvider
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage