-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: implemented google gemini integration (closes #33)
- Loading branch information
1 parent
430b3ab
commit 9e5e5ca
Showing
4 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
|
||
use crate::agent::state::SharedState; | ||
|
||
use super::{openai::OpenAIClient, ChatOptions, ChatResponse, Client, SupportedFeatures}; | ||
|
||
pub struct GoogleClient { | ||
client: OpenAIClient, | ||
} | ||
|
||
#[async_trait] | ||
impl Client for GoogleClient { | ||
fn new(_: &str, _: u16, model_name: &str, _: u32) -> anyhow::Result<Self> | ||
where | ||
Self: Sized, | ||
{ | ||
let client = OpenAIClient::custom( | ||
model_name, | ||
"GEMINI_API_KEY", | ||
"https://generativelanguage.googleapis.com/v1beta/openai/", | ||
)?; | ||
|
||
Ok(Self { client }) | ||
} | ||
|
||
async fn check_supported_features(&self) -> Result<SupportedFeatures> { | ||
self.client.check_supported_features().await | ||
} | ||
|
||
async fn chat( | ||
&self, | ||
state: SharedState, | ||
options: &ChatOptions, | ||
) -> anyhow::Result<ChatResponse> { | ||
self.client.chat(state, options).await | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl mini_rag::Embedder for GoogleClient { | ||
async fn embed(&self, text: &str) -> Result<mini_rag::Embeddings> { | ||
self.client.embed(text).await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters