Skip to content

Commit

Permalink
Add /gemini2 command, and update Groq model (#25)
Browse files Browse the repository at this point in the history
* added gemini2 command & updated groq model & removed gemini 1.0 pro

* updated description of command

* actually implemented gemini2

* changed back model_id to model
  • Loading branch information
DuckyBlender authored Dec 15, 2024
1 parent 35469d2 commit 1906d6e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/commands/groq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl CommandTrait for Llama {
}

fn description(&self) -> Option<&'static str> {
Some("ask Llama 3.1 70B")
Some("ask Llama 3.3 70B")
}

fn rate_limit(&self) -> RateLimiter<i64> {
Expand All @@ -36,7 +36,7 @@ impl CommandTrait for Llama {
ctx.bot_state.http_client.clone(),
"https://api.groq.com/openai/v1",
&env::var("GROQ_API_KEY").unwrap(),
"llama-3.1-70b-versatile",
"llama-3.3-70b-versatile",
&[Message { role: "user", content: &prompt }],
)
.await?
Expand Down
32 changes: 27 additions & 5 deletions src/commands/makersuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,38 @@ use crate::utilities::telegram_utils;
const SYSTEM_INSTRUCTION: &str =
"Be concise and precise. Don't be verbose. Answer in the user's language.";

pub struct GoogleGemini;
pub struct GoogleGemini {
command_names: &'static [&'static str],
description: &'static str,
model: &'static str,
}

impl GoogleGemini {
pub const fn gemini() -> Self {
Self {
command_names: &["gemini", "g"],
description: "ask Gemini 1.5 Flash",
model: "gemini-1.5-flash-latest",
}
}

pub const fn gemini2() -> Self {
Self {
command_names: &["gemini2", "g2"],
description: "ask Gemini 2.0 Flash",
model: "gemini-2.0-flash-exp",
}
}
}

#[async_trait]
impl CommandTrait for GoogleGemini {
fn command_names(&self) -> &[&str] {
&["gemini", "g"]
self.command_names
}

fn description(&self) -> Option<&'static str> {
Some("ask Gemini 1.0 Pro or 1.5 Flash")
Some(self.description)
}

fn rate_limit(&self) -> RateLimiter<i64> {
Expand Down Expand Up @@ -75,7 +97,7 @@ impl CommandTrait for GoogleGemini {
parts.push(Part::FileData(FileData { file_uri: file.uri }));

(
"gemini-1.5-flash-latest",
self.model,
Some([Part::Text(Cow::Borrowed(SYSTEM_INSTRUCTION))].as_slice()),
parts,
)
Expand All @@ -88,7 +110,7 @@ impl CommandTrait for GoogleGemini {
return Err(CommandError::Custom("no prompt or file provided.".into()));
}

("gemini-1.5-flash-latest", None, parts)
(self.model, None, parts)
};

let http_client = ctx.bot_state.http_client.clone();
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ async fn main() {
bot.add_command(commands::markov_chain::MarkovChain);
bot.add_command(commands::config::Config);
bot.add_command(commands::different_dimension_me::DifferentDimensionMe);
bot.add_command(commands::makersuite::GoogleGemini);
bot.add_command(commands::makersuite::GoogleGemini::gemini());
bot.add_command(commands::makersuite::GoogleGemini::gemini2());
bot.add_command(commands::makersuite::GooglePalm);
bot.add_command(commands::groq::Llama);
bot.add_command(commands::translate::Translate);
Expand Down

0 comments on commit 1906d6e

Please sign in to comment.