Skip to content

Commit a587a3d

Browse files
chore: bump version to 1.11.0 (#163)
* chore: bump version to 1.11.0 * fix: increment tool tip to return a random index if deserialization fails
1 parent 4b13864 commit a587a3d

File tree

6 files changed

+78
-61
lines changed

6 files changed

+78
-61
lines changed

Cargo.lock

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ authors = [
2020
edition = "2021"
2121
homepage = "https://aws.amazon.com/q/"
2222
publish = false
23-
version = "1.10.2"
23+
version = "1.11.0"
2424
license = "MIT OR Apache-2.0"
2525

2626
[workspace.dependencies]

crates/chat-cli/src/api_client/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl ReasonCode for ApiClientError {
9292
ApiClientError::ContextWindowOverflow => "ContextWindowOverflow".to_string(),
9393
ApiClientError::SmithyBuild(_) => "SmithyBuildError".to_string(),
9494
ApiClientError::AuthError(_) => "AuthError".to_string(),
95+
ApiClientError::ModelOverloadedError { .. } => "ModelOverloadedError".to_string(),
9596
}
9697
}
9798
}

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ impl ChatContext {
833833

834834
execute!(self.output, style::Print(welcome_text), style::Print("\n\n"),)?;
835835

836-
let current_tip_index = database.get_increment_rotating_tip().unwrap_or(0) % ROTATING_TIPS.len();
836+
let current_tip_index = database.increment_rotating_tip(ROTATING_TIPS.len());
837837

838838
let tip = ROTATING_TIPS[current_tip_index];
839839
if is_small_screen {

crates/chat-cli/src/database/mod.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use serde_json::{
2828
use settings::Settings;
2929
use thiserror::Error;
3030
use tracing::{
31+
error,
3132
info,
3233
trace,
3334
};
@@ -302,10 +303,21 @@ impl Database {
302303
}
303304

304305
/// Get the rotating tip used for chat then post increment.
305-
pub fn get_increment_rotating_tip(&mut self) -> Result<usize, DatabaseError> {
306-
let tip: usize = self.get_entry(Table::State, ROTATING_TIP_KEY)?.unwrap_or(0);
307-
self.set_entry(Table::State, ROTATING_TIP_KEY, tip.wrapping_add(1))?;
308-
Ok(tip)
306+
///
307+
/// If any error is encountered while reading the database, a random index is returned instead.
308+
pub fn increment_rotating_tip(&mut self, max_size: usize) -> usize {
309+
let tip: usize = match self.get_entry(Table::State, ROTATING_TIP_KEY) {
310+
Ok(v) => v.unwrap_or(rand::random_range(0..max_size)),
311+
Err(err) => {
312+
error!(?err, "failed to get incrementing rotating tip");
313+
rand::random_range(0..max_size)
314+
},
315+
};
316+
let next_tip = tip.wrapping_add(1) % max_size;
317+
self.set_entry(Table::State, ROTATING_TIP_KEY, next_tip)
318+
.map_err(|err| error!(?err, next_tip, "failed to update rotating tip key"))
319+
.ok();
320+
tip
309321
}
310322

311323
// /// Get the model id used for last conversation state.

0 commit comments

Comments
 (0)