pub struct GenericProvider<P: Protocol> { /* private fields */ }Expand description
通用提供商实现
这个结构体为大多数标准LLM API提供通用实现。 它使用Protocol trait来处理API特定的格式转换, 使用HttpClient来处理网络通信。
Implementations§
Source§impl<P: Protocol> GenericProvider<P>
impl<P: Protocol> GenericProvider<P>
Sourcepub fn new(protocol: P, client: HttpClient) -> Self
pub fn new(protocol: P, client: HttpClient) -> Self
创建新的通用提供商
Sourcepub fn client(&self) -> &HttpClient
pub fn client(&self) -> &HttpClient
获取客户端引用
Trait Implementations§
Source§impl<P: Protocol> Clone for GenericProvider<P>
impl<P: Protocol> Clone for GenericProvider<P>
Source§impl<P: Protocol> Provider for GenericProvider<P>
impl<P: Protocol> Provider for GenericProvider<P>
Source§fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmConnectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmConnectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
聊天完成
Auto Trait Implementations§
impl<P> Freeze for GenericProvider<P>where
P: Freeze,
impl<P> !RefUnwindSafe for GenericProvider<P>
impl<P> Send for GenericProvider<P>
impl<P> Sync for GenericProvider<P>
impl<P> Unpin for GenericProvider<P>where
P: Unpin,
impl<P> !UnwindSafe for GenericProvider<P>
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