pub struct GeminiAdapter { /* private fields */ }
Expand description
Google Gemini独立适配器,支持多模态AI服务
Google Gemini independent adapter for multimodal AI service
Gemini API is completely different from OpenAI format, requires independent adapter:
- Endpoint: /v1beta/models/{model}:generateContent
- Request body: contents array instead of messages
- Response: candidates[0].content.parts[0].text
- Authentication: URL parameter ?key=<API_KEY>
Implementations§
Source§impl GeminiAdapter
impl GeminiAdapter
pub fn new() -> Result<Self, AiLibError>
Sourcepub fn with_transport_ref(
transport: DynHttpTransportRef,
api_key: String,
base_url: String,
) -> Result<Self, AiLibError>
pub fn with_transport_ref( transport: DynHttpTransportRef, api_key: String, base_url: String, ) -> Result<Self, AiLibError>
Construct using object-safe transport reference
Sourcepub fn with_transport_ref_and_metrics(
transport: DynHttpTransportRef,
api_key: String,
base_url: String,
metrics: Arc<dyn Metrics>,
) -> Result<Self, AiLibError>
pub fn with_transport_ref_and_metrics( transport: DynHttpTransportRef, api_key: String, base_url: String, metrics: Arc<dyn Metrics>, ) -> Result<Self, AiLibError>
Construct with an injected transport and metrics implementation
Trait Implementations§
Source§impl ChatApi for GeminiAdapter
impl ChatApi for GeminiAdapter
Source§fn chat_completion<'life0, 'async_trait>(
&'life0 self,
request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion<'life0, 'async_trait>(
&'life0 self,
request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send chat completion request Read more
Source§fn chat_completion_stream<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<ChatCompletionChunk, AiLibError>> + Send + Unpin>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion_stream<'life0, 'async_trait>(
&'life0 self,
_request: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<ChatCompletionChunk, AiLibError>> + Send + Unpin>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Streaming chat completion request Read more
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get list of supported models Read more
Source§fn get_model_info<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ModelInfo, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_model_info<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ModelInfo, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get model information Read more
Source§fn chat_completion_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<ChatCompletionRequest>,
concurrency_limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<ChatCompletionResponse, AiLibError>>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<ChatCompletionRequest>,
concurrency_limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<ChatCompletionResponse, AiLibError>>, AiLibError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
批处理聊天完成请求 Read more
Auto Trait Implementations§
impl Freeze for GeminiAdapter
impl !RefUnwindSafe for GeminiAdapter
impl Send for GeminiAdapter
impl Sync for GeminiAdapter
impl Unpin for GeminiAdapter
impl !UnwindSafe for GeminiAdapter
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