Skip to content

Commit 8b39dfa

Browse files
committed
[FMT] made clippy happy, and ran cargo fmt
1 parent fc8911c commit 8b39dfa

File tree

16 files changed

+76
-61
lines changed

16 files changed

+76
-61
lines changed

core/examples/advanced_tool_calls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ async fn main() -> Result<(), seedframe::error::Error> {
9595
.send()
9696
.await?;
9797

98-
println!("Meeting scheduled: {:#?}", response);
98+
println!("Meeting scheduled: {response:#?}");
9999

100100
let response = client
101101
.prompt("convert the temperature 32.2 from Celcius to Fahrenheit")
102102
.send()
103103
.await?;
104104

105-
println!("Temprature converted : {:#?}", response);
105+
println!("Temprature converted : {response:#?}");
106106

107107
Ok(())
108108
}

core/examples/extractors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn main() -> Result<(), seedframe::error::Error> {
3939
let person = client.prompt(person_text)
4040
.extract::<Person>()
4141
.await?;
42-
println!("Extracted Person:\n{:#?}\n", person);
42+
println!("Extracted Person:\n{person:#?}\n");
4343

4444
let meeting_text = "We have a team meeting scheduled for 2026-2-15 at 11:30. \
4545
Purpose is quarterly planning. Attendees include: \
@@ -49,7 +49,7 @@ async fn main() -> Result<(), seedframe::error::Error> {
4949
let meeting = client.prompt(meeting_text)
5050
.extract::<MeetingDetails>()
5151
.await?;
52-
println!("Extracted Meeting:\n{:#?}\n", meeting);
52+
println!("Extracted Meeting:\n{meeting:#?}\n");
5353

5454
Ok(())
5555
}

core/src/completion/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,34 @@ impl<'a, M: CompletionModel> PromptBuilder<'a, M> {
140140
}
141141

142142
/// Execute the tool calls if the LLM responds with a Tool call request, `true` by default
143-
pub fn execute_tools(mut self, execute: bool) -> Self {
143+
#[must_use] pub fn execute_tools(mut self, execute: bool) -> Self {
144144
self.execute_tools = execute;
145145
self
146146
}
147147

148148
/// Wether to send any tool definitions with the prompt, `true` by default
149-
pub fn with_tools(mut self, no_tools: bool) -> Self {
149+
#[must_use] pub fn with_tools(mut self, no_tools: bool) -> Self {
150150
self.with_tools = no_tools;
151151
self
152152
}
153153

154154
/// Create a `Message::User` with the tool reponses and append it to the client history, `false` by default
155-
pub fn append_tool_response(mut self, append: bool) -> Self {
155+
#[must_use] pub fn append_tool_response(mut self, append: bool) -> Self {
156156
self.append_tool_response = append;
157157
self
158158
}
159159

160160
/// Wether to retrieve and append the context to the prompt, true by default.
161161
/// If true, the client's vector store will get looked up for the top matches to the prompt and
162162
/// the context will get appended to the prompt before being sent.
163-
pub fn with_context(mut self, append_context: bool) -> Self {
163+
#[must_use] pub fn with_context(mut self, append_context: bool) -> Self {
164164
self.with_context = append_context;
165165
self
166166
}
167167

168168
/// Prompt the LLM with a custom history, and get a response.
169169
/// Response won't be stored in the client's history
170-
pub fn one_shot(mut self, one_shot: bool, history: Option<MessageHistory>) -> Self {
170+
#[must_use] pub fn one_shot(mut self, one_shot: bool, history: Option<MessageHistory>) -> Self {
171171
self.one_shot = (one_shot, history);
172172
self
173173
}
@@ -254,14 +254,14 @@ impl<'a, M: CompletionModel> PromptBuilder<'a, M> {
254254
} = response.clone()
255255
{
256256
if self.one_shot.0 {
257-
self.client.history.push(response)
257+
self.client.history.push(response);
258258
}
259259
let values = self.client.run_tools(Some(&calls)).await?;
260260
if self.one_shot.0 {
261261
self.client.history.pop();
262262
}
263263
response = Message::User {
264-
content: "".to_owned(),
264+
content: String::new(),
265265
tool_responses: Some(values.clone()),
266266
};
267267
if self.append_tool_response && !self.one_shot.0 {
@@ -304,7 +304,7 @@ impl<M: CompletionModel + Send> Client<M> {
304304
self.history = history;
305305
}
306306

307-
pub fn export_history(&self) -> &MessageHistory {
307+
#[must_use] pub fn export_history(&self) -> &MessageHistory {
308308
&self.history
309309
}
310310

@@ -408,7 +408,7 @@ impl<M: CompletionModel + Send> Client<M> {
408408
};
409409

410410
let message_with_context = Message::User {
411-
content: format!("{}{}", prompt, context),
411+
content: format!("{prompt}{context}"),
412412
tool_responses: None,
413413
};
414414

@@ -431,7 +431,7 @@ impl<M: CompletionModel + Send> Client<M> {
431431
return Ok(None);
432432
}
433433
let mut context = String::new();
434-
for embedder in self.embedders.iter() {
434+
for embedder in &self.embedders {
435435
let query_results = embedder.query(prompt, DEFAULT_TOP_N).await?;
436436
if query_results.is_empty() {
437437
return Ok(None);
@@ -476,11 +476,11 @@ fn process_json_value(value: &mut serde_json::Value) {
476476
match value {
477477
serde_json::Value::Object(obj) => {
478478
let fields_to_remove = ["$schema", "format", "title", "minimum"];
479-
fields_to_remove.iter().for_each(|&f| {
479+
for &f in &fields_to_remove {
480480
if obj.get(f).map_or(false, |v| v.is_string() || v.is_number()) {
481481
obj.remove(f);
482482
}
483-
});
483+
}
484484
if let Some(v) = obj.get("oneOf").cloned() {
485485
obj.remove("oneOf");
486486
obj.insert("anyOf".to_string(), v);
@@ -521,7 +521,7 @@ where
521521
S: Serializer,
522522
{
523523
let combined_content = match tool_calls {
524-
Some(calls) => &format!("{} {:?}", content, calls),
524+
Some(calls) => &format!("{content} {calls:?}"),
525525
None => content,
526526
};
527527
serializer.serialize_newtype_struct("assistant", &combined_content)

core/src/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct Document {
99
}
1010

1111
impl Document {
12-
pub fn new(id: String, data: String) -> Self {
12+
#[must_use] pub fn new(id: String, data: String) -> Self {
1313
Self { id, data }
1414
}
1515
}

core/src/loader/builtins/file_loaders/file_once_loader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl FileOnceLoaderBuilder {
5353
let documents = load_initial(&self.evaluated);
5454
if documents.is_empty() {
5555
error!("No documents matched the provided glob patterns");
56-
Err(FileLoaderError::NoMatchingDocuments)?
56+
Err(FileLoaderError::NoMatchingDocuments)?;
5757
};
5858
let (tx, _rx) = broadcast::channel(documents.len());
5959
debug!(
@@ -100,7 +100,7 @@ impl Loader for FileOnceLoader {
100100
if let Err(e) = self.tx.send(doc.clone()) {
101101
error!("Loader failed to send document: {} to subscribers", e.0.id);
102102
} else {
103-
sent_docs_count += 1
103+
sent_docs_count += 1;
104104
}
105105
}
106106
info!(
@@ -147,7 +147,7 @@ mod tests {
147147
"*.txt *.pdf",
148148
]
149149
.iter()
150-
.map(|p| p.to_string())
150+
.map(|p| (*p).to_string())
151151
.collect::<Vec<String>>();
152152
let result = FileOnceLoaderBuilder::new(invalid_patterns);
153153
assert!(result.is_err());

core/src/loader/builtins/file_loaders/file_updating_loader.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl FileUpdatingLoaderBuilder {
7070
/// # Returns
7171
/// * `FileUpdatingLoader` - A new `FileUpdatingLoader` instance.
7272
pub fn build(self) -> FileUpdatingLoader {
73-
let files = resolve_input_to_files(self.glob_patterns.iter().map(|s| s.as_str()).collect())
73+
let files = resolve_input_to_files(self.glob_patterns.iter().map(std::string::String::as_str).collect())
7474
.unwrap();
7575
let capacity = if files.is_empty() {
7676
DEFAULT_CHANNEL_CAPACITY
@@ -122,13 +122,13 @@ impl Loader for FileUpdatingLoader {
122122
let initial_docs = load_initial(&self.patterns);
123123
let mut sent_docs_count = 0;
124124
let total_docs_count = initial_docs.len();
125-
initial_docs.into_iter().for_each(|doc| {
125+
for doc in initial_docs {
126126
if let Err(e) = self.tx.send(doc) {
127127
error!("Loader failed to send document: {} to subscribers", e.0.id);
128128
} else {
129129
sent_docs_count += 1;
130130
}
131-
});
131+
}
132132
info!(
133133
"Loader sent {} of {} initial documents to subscribers",
134134
sent_docs_count, total_docs_count
@@ -169,7 +169,7 @@ impl Loader for FileUpdatingLoader {
169169
loop {
170170
let now = Instant::now();
171171
if now.duration_since(last_event_time) >= debounce_duration {
172-
for event in evt_rx.iter() {
172+
for event in &evt_rx {
173173
let event = event.unwrap();
174174
let out = process_event(&event, &pc);
175175
if out.is_none() {
@@ -199,7 +199,7 @@ fn document_for_event(path: &str, et: EventType) -> Document {
199199
let file = std::path::Path::new(&path);
200200
let data = match et {
201201
EventType::Modify | EventType::Create => parse_file(file).unwrap(),
202-
EventType::Delete => "".to_string(),
202+
EventType::Delete => String::new(),
203203
};
204204
debug!("Created document for {} with event type {:?}", path, et);
205205
Document {
@@ -243,7 +243,7 @@ mod tests {
243243
paths: vec![PathBuf::from("test.txt")],
244244
attrs: Default::default(),
245245
};
246-
let result = process_event(&event, &vec![pattern]);
246+
let result = process_event(&event, &[pattern]);
247247
assert!(result.is_some());
248248
let (path, et) = result.unwrap();
249249
assert_eq!(path, "test.txt");
@@ -258,7 +258,7 @@ mod tests {
258258
paths: vec![PathBuf::from("test.txt")],
259259
attrs: Default::default(),
260260
};
261-
let result = process_event(&event, &vec![pattern]);
261+
let result = process_event(&event, &[pattern]);
262262
assert!(result.is_none());
263263
}
264264

core/src/loader/builtins/file_loaders/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub(super) fn parse_file(file_path: &Path) -> io::Result<String> {
9595
}
9696

9797
pub(super) fn load_initial(patterns: &[Pattern]) -> Vec<Document> {
98-
let files = resolve_input_to_files(patterns.iter().map(|s| s.as_str()).collect()).unwrap();
98+
let files = resolve_input_to_files(patterns.iter().map(glob::Pattern::as_str).collect()).unwrap();
9999
let mut documents: Vec<Document> = vec![];
100100
for file in files {
101101
let data = parse_file(&file).unwrap();

core/src/providers/completions/deepseek.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct DeepseekCompletionModel {
1616
}
1717

1818
impl DeepseekCompletionModel {
19-
pub fn new(api_key: String, api_url: String, model: String) -> Self {
19+
#[must_use] pub fn new(api_key: String, api_url: String, model: String) -> Self {
2020
Self {
2121
api_key,
2222
client: reqwest::Client::new(),

core/src/providers/completions/openai.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct OpenAICompletionModel {
1515
}
1616

1717
impl OpenAICompletionModel {
18-
pub fn new(api_key: String, api_url: String, model: String) -> Self {
18+
#[must_use] pub fn new(api_key: String, api_url: String, model: String) -> Self {
1919
Self {
2020
api_key,
2121
client: reqwest::Client::new(),
@@ -334,7 +334,7 @@ For this test to be considered successful, reply with "okay" without the quotes,
334334
content: _,
335335
tool_calls: Some(_)
336336
}
337-
))
337+
));
338338
}
339339

340340
fn get_tools() -> ToolSet {

core/src/providers/completions/xai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct XaiCompletionModel {
1616
}
1717

1818
impl XaiCompletionModel {
19-
pub fn new(api_key: String, api_url: String, model: String) -> Self {
19+
#[must_use] pub fn new(api_key: String, api_url: String, model: String) -> Self {
2020
Self {
2121
api_key,
2222
client: reqwest::Client::new(),

0 commit comments

Comments
 (0)