-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60fb40c
commit bd73b0c
Showing
6 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,51 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
|
||
use crate::agent::state::SharedState; | ||
|
||
use super::{openai::OpenAIClient, ChatOptions, ChatResponse, Client}; | ||
|
||
pub struct NvidiaNIMClient { | ||
client: OpenAIClient, | ||
} | ||
|
||
#[async_trait] | ||
impl Client for NvidiaNIMClient { | ||
fn new(_: &str, _: u16, model_name: &str, _: u32) -> anyhow::Result<Self> | ||
where | ||
Self: Sized, | ||
{ | ||
let model_name = if model_name.contains("/") { | ||
model_name | ||
} else { | ||
&format!("nvidia/{}", model_name) | ||
}; | ||
|
||
let client = OpenAIClient::custom( | ||
model_name, | ||
"NIM_API_KEY", | ||
"https://integrate.api.nvidia.com/v1/", | ||
)?; | ||
|
||
Ok(Self { client }) | ||
} | ||
|
||
async fn check_native_tools_support(&self) -> Result<bool> { | ||
self.client.check_native_tools_support().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 NvidiaNIMClient { | ||
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