Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "AviCore"
version = "2.2.0"
version = "2.2.1"
edition = "2024"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/actions/intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl IntentAction {
let intent = Intent {
input: intent.input,
intent: Some(IntentInfo(*intent.intent)),
slots: intent.slots.unwrap().into_iter().map(|s| Slot(s)).collect(),
slots: intent.slots.unwrap().into_iter().map(Slot).collect(),
};
let mut mg = skill_manager.lock().await;

Expand Down
3 changes: 1 addition & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use avi_nlu_client::models::{
use log::trace;

fn box_err<E: std::fmt::Display>(e: E) -> Box<dyn std::error::Error> {
Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
Box::new(std::io::Error::other(
e.to_string(),
))
}
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ContextManager {
if let Some(ctx_value) = self.load_persistent(scope, key) {
if !ctx_value.is_expired() {
debug!("Found {} in persistent storage for scope {:?}", key, scope);
self.save(scope, &key, &ctx_value);
self.save(scope, key, &ctx_value);
return Some(ctx_value.value);
} else {
debug!("Found expired {} in persistent storage, deleting", key);
Expand Down
3 changes: 1 addition & 2 deletions src/dialogue/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ impl LanguageSystem {
.map(|i| match &i.value {
serde_yaml::Value::Sequence(seq) if !seq.is_empty() => {
let mut rng = rand::rng();
seq.choose(&mut rng)
.map(|v| v.clone())
seq.choose(&mut rng).cloned()
.unwrap_or_else(|| i.value.clone())
}
_ => i.value.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/skills/avi_script/module/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod context_module {
pub fn get(ctx: NativeCallContext, key: ImmutableString) -> Dynamic {
skill_context_def(ctx, |v| {
get_ctx!(skill: v.info.name.clone(), &key)
.map(|v| json_to_dynamic(v))
.map(json_to_dynamic)
.unwrap_or(Dynamic::UNIT)
})
}
Expand Down
5 changes: 2 additions & 3 deletions src/skills/avi_script/module/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod locale_module {
"Could not get the skill context".to_string().into(),
Position::NONE,
)))
.map(|v| ImmutableString::from(v))
.map(ImmutableString::from)
}

/// Gets a formatted translation for a given ID in the current locale
Expand All @@ -49,7 +49,7 @@ pub mod locale_module {
"Could not get the skill context".to_string().into(),
Position::NONE,
)))
.map(|v| ImmutableString::from(v))
.map(ImmutableString::from)
}

/// Lists all translations for a given locale code
Expand Down Expand Up @@ -84,7 +84,6 @@ pub mod locale_module {
///
/// # Returns
/// The current language code (e.g., 'en-US')

pub fn current(_ctx: NativeCallContext) -> ImmutableString {
ImmutableString::from(lang())
}
Expand Down
32 changes: 16 additions & 16 deletions src/skills/avi_script/module/ml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ pub mod ml {
) -> Result<Model, Box<EvalAltResult>> {
// Make x array
let array_as_vec_vec_float = &x
.into_iter()
.iter_mut()
.map(|observation| array_to_vec_float(&mut observation.clone().into_array().unwrap()))
.collect::<Vec<Vec<FLOAT>>>();

// Check if x array is empty
if array_as_vec_vec_float.len() == 0 {
if array_as_vec_vec_float.is_empty() {
Err(EvalAltResult::ErrorArrayBounds(0, 0, Position::NONE).into())
} else {
let algorithm_string = algorithm.as_str();
Expand Down Expand Up @@ -147,12 +147,12 @@ pub mod ml {
pub fn predict_with_model(x: &mut Array, model: Model) -> Result<Array, Box<EvalAltResult>> {
// Make x array
let array_as_vec_vec_float = &x
.into_iter()
.iter_mut()
.map(|observation| array_to_vec_float(&mut observation.clone().into_array().unwrap()))
.collect::<Vec<Vec<FLOAT>>>();

// Check if x array is empty
if array_as_vec_vec_float.len() == 0 {
if array_as_vec_vec_float.is_empty() {
Err(EvalAltResult::ErrorArrayBounds(0, 0, Position::NONE).into())
} else {
let xvec = DenseMatrix::from_2d_vec(array_as_vec_vec_float).map_err(|e| {
Expand All @@ -169,48 +169,48 @@ pub mod ml {
FLOAT,
DenseMatrix<FLOAT>,
Vec<FLOAT>,
> = bincode::deserialize(&*model.saved_model).unwrap();
return match model_ready.predict(&xvec) {
> = bincode::deserialize(&model.saved_model).unwrap();
match model_ready.predict(&xvec) {
Ok(y) => Ok(y
.into_iter()
.map(|observation| Dynamic::from_float(observation))
.map(Dynamic::from_float)
.collect::<Vec<Dynamic>>()),
Err(e) => Err(EvalAltResult::ErrorArithmetic(
format!("{e}"),
Position::NONE,
)
.into()),
};
}
}
"lasso" => {
let model_ready: Lasso<FLOAT, FLOAT, DenseMatrix<FLOAT>, Vec<FLOAT>> =
bincode::deserialize(&*model.saved_model).unwrap();
return match model_ready.predict(&xvec) {
bincode::deserialize(&model.saved_model).unwrap();
match model_ready.predict(&xvec) {
Ok(y) => Ok(y
.into_iter()
.map(|observation| Dynamic::from_float(observation))
.map(Dynamic::from_float)
.collect::<Vec<Dynamic>>()),
Err(e) => Err(EvalAltResult::ErrorArithmetic(
format!("{e}"),
Position::NONE,
)
.into()),
};
}
}
"logistic" => {
let model_ready: LogisticRegression<FLOAT, INT, DenseMatrix<FLOAT>, Vec<INT>> =
bincode::deserialize(&*model.saved_model).unwrap();
return match model_ready.predict(&xvec) {
bincode::deserialize(&model.saved_model).unwrap();
match model_ready.predict(&xvec) {
Ok(y) => Ok(y
.into_iter()
.map(|observation| Dynamic::from_int(observation))
.map(Dynamic::from_int)
.collect::<Vec<Dynamic>>()),
Err(e) => Err(EvalAltResult::ErrorArithmetic(
format!("{e}"),
Position::NONE,
)
.into()),
};
}
}
&_ => Err(EvalAltResult::ErrorArithmetic(
format!("{} is not a recognized model type.", algorithm_string),
Expand Down
2 changes: 1 addition & 1 deletion src/skills/avi_script/module/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub mod rand_functions {
/// ```
#[rhai_fn(name = "rand_bool", return_raw)]
pub fn rand_bool_with_probability(probability: FLOAT) -> Result<bool, Box<EvalAltResult>> {
if probability < 0.0 || probability > 1.0 {
if !(0.0..=1.0).contains(&probability) {
Err(EvalAltResult::ErrorArithmetic(
format!(
"Invalid probability (must be between 0.0 and 1.0): {}",
Expand Down
2 changes: 1 addition & 1 deletion src/skills/avi_script/module/skill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub mod skill_module {
pub fn get_permissions(ctx: NativeCallContext) -> Vec<ImmutableString> {
skill_context_def(ctx, |v| v.info.permissions.clone())
.iter()
.map(|v| ImmutableString::from(v))
.map(ImmutableString::from)
.collect()
}

Expand Down
1 change: 0 additions & 1 deletion src/skills/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ impl SkillManager {
for skill in self
.skills
.values()
.into_iter()
.map(|skill| skill.pathname())
.collect::<Vec<PathBuf>>()
{
Expand Down
2 changes: 1 addition & 1 deletion src/skills/skill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Skill {

self.engine.run_ast_with_scope(
&mut *self.scope.write().map_err(|e| e.to_string())?,
&*ast_guard,
&ast_guard,
)?;
Ok(())
}
Expand Down
Loading