Skip to content

Commit

Permalink
Amadeus: don't treat questionmark somehow specially
Browse files Browse the repository at this point in the history
Signed-off-by: Miezhiko <Miezhiko@gmail.com>
  • Loading branch information
Miezhiko committed Jun 23, 2023
1 parent 0b94307 commit 5487eb3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Amadeus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amadeus"
version = "11.0.3"
version = "11.0.4"
authors = [ "Miezhiko" ]
repository = "https://github.com/Miezhiko/Amadeus"
readme = "README.md"
Expand Down
15 changes: 8 additions & 7 deletions Amadeus/src/steins/ai/bert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ pub async fn chat( msg: Option<u64>
, lsm: bool
, russian: bool
, guild_id: u64 ) -> Result<Option<String>> {
let wlmt = if guild_id == 611822838831251466 { 64 } else { 16 };
let rndx = if user_id == 510368731378089984 {
6
} else {
rand::thread_rng().gen_range(0..wlmt)
};
let wlmt = if guild_id == 611822838831251466
{ 64 }
else { 16 };
let rndx = if user_id == 510368731378089984
{ 7 }
else { rand::thread_rng().gen_range(0..wlmt) };
let mut input = process_message_for_gpt(&something);
if rndx < 6 {
if rndx < 7 {
if input.len() > GPT_LIMIT {
if let Some((i, _)) = input.char_indices().rev().nth(GPT_LIMIT) {
input = input[i..].to_string();
Expand All @@ -131,6 +131,7 @@ pub async fn chat( msg: Option<u64>
3 => codebert (msg, chan, input, user_id, lsm, russian).await,
4 => gptj (msg, chan, input, user_id, lsm, russian).await,
5 => chat_gpt2 (msg, chan, input, user_id, lsm, russian).await,
6 => ask (msg, chan, input, user_id, lsm, russian).await,
_ => wagner (msg, chan, input, user_id, lsm, russian).await
}
}
62 changes: 13 additions & 49 deletions Amadeus/src/steins/ai/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,55 +63,19 @@ async fn generate_response( ctx: &Context
}
}
} else { msg.content.clone() };
if msg.content.ends_with('?') {
let rndxqa: u32 = rand::thread_rng().gen_range(0..2);
if rndxqa == 1 {
match bert::ask( message_id
, msg.channel_id.0.get()
, text
, msg.author.id.0.get()
, lsm
, russian ).await {
Ok(answer) => {
bert_generated = true;
answer },
Err(why) => {
error!("Failed to bert ask {why}");
Some( generate(ctx, msg, Some(russian)).await )
}
}
} else {
match bert::chat( message_id
, msg.channel_id.0.get()
, text
, msg.author.id.0.get()
, lsm
, russian
, guild_id ).await {
Ok(answer) => {
bert_generated = true;
answer },
Err(why) => {
error!("Failed to bert chat with question {why}, input: {}", &msg.content);
Some( generate(ctx, msg, Some(russian)).await )
}
}
}
} else {
match bert::chat( message_id
, msg.channel_id.0.get()
, text
, msg.author.id.0.get()
, lsm
, russian
, guild_id ).await {
Ok(answer) => {
bert_generated = true;
answer },
Err(why) => {
error!("Failed to bert chat {why}, input: {}", &msg.content);
Some( generate(ctx, msg, Some(russian)).await )
}
match bert::chat( message_id
, msg.channel_id.0.get()
, text
, msg.author.id.0.get()
, lsm
, russian
, guild_id ).await {
Ok(answer) => {
bert_generated = true;
answer },
Err(why) => {
error!("Failed to bert chat {why}, input: {}", &msg.content);
Some( generate(ctx, msg, Some(russian)).await )
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5487eb3

Please sign in to comment.