summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/input.rs8
-rw-r--r--src/config/role.rs8
-rw-r--r--src/config/session.rs22
-rw-r--r--src/function.rs6
4 files changed, 22 insertions, 22 deletions
diff --git a/src/config/input.rs b/src/config/input.rs
index 78da9f2..fd42bf8 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -167,14 +167,14 @@ impl Input {
let mut functions = None;
if self.config.read().function_calling && model.supports_function_calling() {
let config = self.config.read();
- let function_filter = if let Some(session) = self.session(&config.session) {
- session.function_filter()
+ let function_matcher = if let Some(session) = self.session(&config.session) {
+ session.function_matcher()
} else if let Some(role) = self.role() {
- role.function_filter.as_deref()
+ role.function_matcher.as_deref()
} else {
None
};
- functions = config.function.filtered_declarations(function_filter);
+ functions = config.function.select(function_matcher);
};
Ok(SendData {
messages,
diff --git a/src/config/role.rs b/src/config/role.rs
index c477ee4..515810c 100644
--- a/src/config/role.rs
+++ b/src/config/role.rs
@@ -29,7 +29,7 @@ pub struct Role {
#[serde(skip_serializing_if = "Option::is_none")]
pub top_p: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
- pub function_filter: Option<String>,
+ pub function_matcher: Option<String>,
}
impl Role {
@@ -40,7 +40,7 @@ impl Role {
temperature: None,
model_id: None,
top_p: None,
- function_filter: None,
+ function_matcher: None,
}
}
@@ -74,13 +74,13 @@ async function timeout(ms) {
("%functions%", String::new(), Some(".*".into())),
]
.into_iter()
- .map(|(name, prompt, function_filter)| Self {
+ .map(|(name, prompt, function_matcher)| Self {
name: name.into(),
prompt,
model_id: None,
temperature: None,
top_p: None,
- function_filter,
+ function_matcher,
})
.collect()
}
diff --git a/src/config/session.rs b/src/config/session.rs
index ef1eab1..8f2ac7e 100644
--- a/src/config/session.rs
+++ b/src/config/session.rs
@@ -22,7 +22,7 @@ pub struct Session {
#[serde(skip_serializing_if = "Option::is_none")]
top_p: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
- function_filter: Option<String>,
+ function_matcher: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
save_session: Option<bool>,
messages: Vec<Message>,
@@ -50,7 +50,7 @@ impl Session {
model_id: config.model.id(),
temperature: config.temperature,
top_p: config.top_p,
- function_filter: None,
+ function_matcher: None,
save_session: config.save_session,
messages: Default::default(),
compressed_messages: Default::default(),
@@ -96,8 +96,8 @@ impl Session {
self.top_p
}
- pub fn function_filter(&self) -> Option<&str> {
- self.function_filter.as_deref()
+ pub fn function_matcher(&self) -> Option<&str> {
+ self.function_matcher.as_deref()
}
pub fn save_session(&self) -> Option<bool> {
@@ -134,8 +134,8 @@ impl Session {
if let Some(top_p) = self.top_p() {
data["top_p"] = top_p.into();
}
- if let Some(function_filter) = self.function_filter() {
- data["function_filter"] = function_filter.into();
+ if let Some(function_matcher) = self.function_matcher() {
+ data["function_matcher"] = function_matcher.into();
}
if let Some(save_session) = self.save_session() {
data["save_session"] = save_session.into();
@@ -170,8 +170,8 @@ impl Session {
items.push(("top_p", top_p.to_string()));
}
- if let Some(function_filter) = self.function_filter() {
- items.push(("function_filter", function_filter.into()));
+ if let Some(function_matcher) = self.function_matcher() {
+ items.push(("function_matcher", function_matcher.into()));
}
if let Some(save_session) = self.save_session() {
@@ -247,14 +247,14 @@ impl Session {
}
}
- pub fn set_functions(&mut self, function_filter: Option<&str>) {
- self.function_filter = function_filter.map(|v| v.to_string());
+ pub fn set_function_matcher(&mut self, function_matcher: Option<&str>) {
+ self.function_matcher = function_matcher.map(|v| v.to_string());
}
pub fn set_role_properties(&mut self, role: &Role) {
self.set_temperature(role.temperature);
self.set_top_p(role.top_p);
- self.set_functions(role.function_filter.as_deref());
+ self.set_function_matcher(role.function_matcher.as_deref());
}
pub fn set_save_session(&mut self, value: Option<bool>) {
diff --git a/src/function.rs b/src/function.rs
index f2eb0c6..a644185 100644
--- a/src/function.rs
+++ b/src/function.rs
@@ -126,9 +126,9 @@ impl Function {
})
}
- pub fn filtered_declarations(&self, filter: Option<&str>) -> Option<Vec<FunctionDeclaration>> {
- let filter = filter?;
- let regex = Regex::new(&format!("^({filter})$")).ok()?;
+ pub fn select(&self, matcher: Option<&str>) -> Option<Vec<FunctionDeclaration>> {
+ let matcher = matcher?;
+ let regex = Regex::new(&format!("^({matcher})$")).ok()?;
let output: Vec<FunctionDeclaration> = self
.declarations
.iter()