Skip to content

Commit 6d9ca57

Browse files
committed
lint
1 parent 24cb705 commit 6d9ca57

File tree

20 files changed

+540
-49
lines changed

20 files changed

+540
-49
lines changed

llm/anthropic/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn process_response(response: MessagesResponse) -> ChatEvent {
130130
Err(e) => {
131131
return ChatEvent::Error(Error {
132132
code: ErrorCode::InvalidRequest,
133-
message: format!("Failed to decode base64 image data: {}", e),
133+
message: format!("Failed to decode base64 image data: {e}"),
134134
provider_error_json: None,
135135
});
136136
}

llm/grok/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn convert_content_parts(contents: Vec<ContentPart>) -> crate::client::Content {
183183
let media_type = &image_source.mime_type; // This is already a string
184184
result.push(crate::client::ContentPart::ImageInput {
185185
image_url: crate::client::ImageUrl {
186-
url: format!("data:{};base64,{}", media_type, base64_data),
186+
url: format!("data:{media_type};base64,{base64_data}"),
187187
detail: image_source.detail.map(|d| d.into()),
188188
},
189189
});

llm/llm/src/event_source/ndjson_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn try_parse_line(
126126
return Ok(None);
127127
}
128128

129-
trace!("Parsed NDJSON line: {}", line);
129+
trace!("Parsed NDJSON line: {line}");
130130

131131
// Create a MessageEvent with the JSON line as data
132132
let event = MessageEvent {

llm/llm/src/event_source/stream.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ where
5656
{
5757
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5858
match self {
59-
Self::Utf8(err) => f.write_fmt(format_args!("UTF8 error: {}", err)),
60-
Self::Parser(err) => f.write_fmt(format_args!("Parse error: {}", err)),
61-
Self::Transport(err) => f.write_fmt(format_args!("Transport error: {}", err)),
59+
Self::Utf8(err) => f.write_fmt(format_args!("UTF8 error: {err}")),
60+
Self::Parser(err) => f.write_fmt(format_args!("Parse error: {err}")),
61+
Self::Transport(err) => f.write_fmt(format_args!("Transport error: {err}")),
6262
}
6363
}
6464
}

llm/ollama/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn image_to_base64(source: &str) -> Result<String, Box<dyn std::error::Error
335335
pub fn from_reqwest_error(context: &str, err: reqwest::Error) -> Error {
336336
Error {
337337
code: ErrorCode::InternalError,
338-
message: format!("{}: {}", context, err),
338+
message: format!("{context}: {err}"),
339339
provider_error_json: None,
340340
}
341341
}

llm/ollama/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn process_response(response: CompletionsResponse) -> ChatEvent {
214214
};
215215

216216
ChatEvent::Message(CompleteResponse {
217-
id: format!("ollama-{}", timestamp),
217+
id: format!("ollama-{timestamp}"),
218218
content,
219219
tool_calls,
220220
metadata,

llm/openai/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn content_part_to_inner_input_item(content_part: ContentPart) -> InnerInput
138138
ImageReference::Inline(image_source) => {
139139
let base64_data = general_purpose::STANDARD.encode(&image_source.data);
140140
let mime_type = &image_source.mime_type; // This is already a string
141-
let data_url = format!("data:{};base64,{}", mime_type, base64_data);
141+
let data_url = format!("data:{mime_type};base64,{base64_data}");
142142

143143
InnerInputItem::ImageInput {
144144
image_url: data_url,

llm/openrouter/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn convert_content_parts(contents: Vec<ContentPart>) -> crate::client::Content {
184184
let media_type = &image_source.mime_type; // This is already a string
185185
result.push(crate::client::ContentPart::ImageInput {
186186
image_url: crate::client::ImageUrl {
187-
url: format!("data:{};base64,{}", media_type, base64_data),
187+
url: format!("data:{media_type};base64,{base64_data}"),
188188
detail: image_source.detail.map(|d| d.into()),
189189
},
190190
});

web-search/brave/src/client.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,12 @@ fn parse_response(response: Response) -> Result<BraveSearchResponse, SearchError
369369
match response.status() {
370370
StatusCode::OK => {
371371
let body = response.text().map_err(|e| {
372-
SearchError::BackendError(format!("Failed to read response body: {}", e))
372+
SearchError::BackendError(format!("Failed to read response body: {e}"))
373373
})?;
374374
match serde_json::from_str::<BraveSearchResponse>(&body) {
375375
Ok(parsed) => Ok(parsed),
376376
Err(e) => Err(SearchError::BackendError(format!(
377-
"Failed to parse response: {} \nRaw body: {}",
378-
e, body
377+
"Failed to parse response: {e} \nRaw body: {body}"
379378
))),
380379
}
381380
}
@@ -387,8 +386,7 @@ fn parse_response(response: Response) -> Result<BraveSearchResponse, SearchError
387386
.text()
388387
.unwrap_or_else(|_| "<failed to read body>".into());
389388
Err(SearchError::BackendError(format!(
390-
"Request failed: {} \nRaw body: {}",
391-
status, body
389+
"Request failed: {status} \nRaw body: {body}"
392390
)))
393391
}
394392
}

web-search/brave/src/conversions.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ use golem_web_search::golem::web_search::types::{
88
pub fn convert_params_to_request(params: &SearchParams, offset: Option<u32>) -> BraveSearchRequest {
99
let mut request = BraveSearchRequest {
1010
q: params.query.clone(),
11-
country: country_code_to_brave(params.region.as_ref().unwrap_or(&"us".to_string())),
12-
search_lang: language_code_to_brave(params.language.as_ref().unwrap_or(&"en".to_string())),
11+
country: params
12+
.region
13+
.as_ref()
14+
.and_then(|r| country_code_to_brave(r)),
15+
search_lang: params
16+
.language
17+
.as_ref()
18+
.and_then(|l| language_code_to_brave(l)),
1319
ui_lang: None,
1420
count: params.max_results,
1521
offset,
@@ -35,7 +41,7 @@ pub fn convert_params_to_request(params: &SearchParams, offset: Option<u32>) ->
3541
if !include_domains.is_empty() {
3642
let domain_query = include_domains
3743
.iter()
38-
.map(|domain| format!("site:{}", domain))
44+
.map(|domain| format!("site:{domain}"))
3945
.collect::<Vec<_>>()
4046
.join(" OR ");
4147
request.q = format!("{} ({})", request.q, domain_query);
@@ -44,7 +50,7 @@ pub fn convert_params_to_request(params: &SearchParams, offset: Option<u32>) ->
4450
if !exclude_domains.is_empty() {
4551
let domain_query = exclude_domains
4652
.iter()
47-
.map(|domain| format!("-site:{}", domain))
53+
.map(|domain| format!("-site:{domain}"))
4854
.collect::<Vec<_>>()
4955
.join(" ");
5056
request.q = format!("{} {}", request.q, domain_query);
@@ -110,13 +116,13 @@ pub fn country_code_to_brave(country_code: &str) -> Option<String> {
110116

111117
pub fn language_code_to_brave(language_code: &str) -> Option<String> {
112118
let input = language_code.to_lowercase();
113-
119+
114120
let lang_code = if input.starts_with("lang_") {
115121
input.strip_prefix("lang_").unwrap_or(&input)
116122
} else {
117123
&input
118124
};
119-
125+
120126
match lang_code {
121127
"en" | "english" => Some("en".to_string()),
122128
"es" | "spanish" => Some("es".to_string()),
@@ -423,7 +429,7 @@ mod tests {
423429
assert_eq!(request.q, "test query (site:example.com OR site:test.org)");
424430
assert_eq!(request.country, Some("us".to_string()));
425431
assert_eq!(request.search_lang, Some("en".to_string()));
426-
assert_eq!(request.ui_lang, Some("en".to_string()));
432+
assert_eq!(request.ui_lang, None);
427433
assert_eq!(request.count, Some(10));
428434
assert_eq!(request.offset, Some(20));
429435
assert_eq!(request.safesearch, Some("moderate".to_string()));

0 commit comments

Comments
 (0)