summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-06-28 19:17:43 +0800
committerGitHub <noreply@github.com>2025-06-28 19:17:43 +0800
commit419790fb74fbaf47d54519238b5a542a3875961e (patch)
tree8917db58a4a77a514079bf115d670a3f82003c03 /src/config
parentbad300bbce72dff6f085fc8b94e8ffbdd103f47f (diff)
downloadaichat-419790fb74fbaf47d54519238b5a542a3875961e.tar.gz
chore: clippy (#1334)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/input.rs2
-rw-r--r--src/config/mod.rs8
-rw-r--r--src/config/role.rs8
-rw-r--r--src/config/session.rs4
4 files changed, 11 insertions, 11 deletions
diff --git a/src/config/input.rs b/src/config/input.rs
index a47001b..e2cce21 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -537,7 +537,7 @@ fn read_media_to_data_url(image_path: &str) -> Result<String> {
file.read_to_end(&mut buffer)?;
let encoded_image = base64_encode(buffer);
- let data_url = format!("data:{};base64,{}", mime_type, encoded_image);
+ let data_url = format!("data:{mime_type};base64,{encoded_image}");
Ok(data_url)
}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 135e6ca..7e35c47 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -1270,7 +1270,7 @@ impl Config {
.clone()
.unwrap_or_else(|| SUMMARY_PROMPT.into());
if let Some(session) = config.write().session.as_mut() {
- session.compress(format!("{}{}", summary_prompt, summary));
+ session.compress(format!("{summary_prompt}{summary}"));
}
config.write().discontinuous_last_message();
Ok(())
@@ -1620,7 +1620,7 @@ impl Config {
None => return Ok(()),
};
- let err_msg = || format!("Invalid prelude '{}", prelude);
+ let err_msg = || format!("Invalid prelude '{prelude}");
match prelude.split_once(':') {
Some(("role", name)) => {
self.use_role(name).with_context(err_msg)?;
@@ -1748,7 +1748,7 @@ impl Config {
self.list_autoname_sessions()
.iter()
.rev()
- .map(|v| format!("_/{}", v))
+ .map(|v| format!("_/{v}"))
.collect::<Vec<String>>(),
)
} else {
@@ -2192,7 +2192,7 @@ impl Config {
let config: Self = serde_yaml::from_str(&content)
.map_err(|err| {
let err_msg = err.to_string();
- let err_msg = if err_msg.starts_with(&format!("{}: ", CLIENTS_FIELD)) {
+ let err_msg = if err_msg.starts_with(&format!("{CLIENTS_FIELD}: ")) {
// location is incorrect, get rid of it
err_msg
.split_once(" at line")
diff --git a/src/config/role.rs b/src/config/role.rs
index 9bdfe6c..829c0d1 100644
--- a/src/config/role.rs
+++ b/src/config/role.rs
@@ -118,16 +118,16 @@ impl Role {
pub fn export(&self) -> String {
let mut metadata = vec![];
if let Some(model) = self.model_id() {
- metadata.push(format!("model: {}", model));
+ metadata.push(format!("model: {model}"));
}
if let Some(temperature) = self.temperature() {
- metadata.push(format!("temperature: {}", temperature));
+ metadata.push(format!("temperature: {temperature}"));
}
if let Some(top_p) = self.top_p() {
- metadata.push(format!("top_p: {}", top_p));
+ metadata.push(format!("top_p: {top_p}"));
}
if let Some(use_tools) = self.use_tools() {
- metadata.push(format!("use_tools: {}", use_tools));
+ metadata.push(format!("use_tools: {use_tools}"));
}
if metadata.is_empty() {
format!("{}\n", self.prompt)
diff --git a/src/config/session.rs b/src/config/session.rs
index a895e64..f3a86de 100644
--- a/src/config/session.rs
+++ b/src/config/session.rs
@@ -79,7 +79,7 @@ impl Session {
let content = read_to_string(path)
.with_context(|| format!("Failed to load session {} at {}", name, path.display()))?;
let mut session: Self =
- serde_yaml::from_str(&content).with_context(|| format!("Invalid session {}", name))?;
+ serde_yaml::from_str(&content).with_context(|| format!("Invalid session {name}"))?;
session.model = Model::retrieve_model(config, &session.model_id, ModelType::Chat)?;
@@ -158,7 +158,7 @@ impl Session {
data["max_input_tokens"] = max_input_tokens.into();
}
if percent != 0.0 {
- data["total/max"] = format!("{}%", percent).into();
+ data["total/max"] = format!("{percent}%").into();
}
data["messages"] = json!(self.messages);