add clippy warning for string_slice (#5422)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -1365,17 +1365,9 @@ impl Agent {
|
||||
.unwrap_or(&content)
|
||||
.trim()
|
||||
.to_string();
|
||||
tracing::debug!(
|
||||
"Cleaned content for parsing: {}",
|
||||
&clean_content[..std::cmp::min(200, clean_content.len())]
|
||||
);
|
||||
|
||||
// try to parse json response from the LLM
|
||||
tracing::debug!("Attempting to parse recipe content as JSON");
|
||||
let (instructions, activities) =
|
||||
if let Ok(json_content) = serde_json::from_str::<Value>(&clean_content) {
|
||||
tracing::debug!("Successfully parsed JSON content");
|
||||
|
||||
let instructions = json_content
|
||||
.get("instructions")
|
||||
.ok_or_else(|| anyhow!("Missing 'instructions' in json response"))?
|
||||
|
||||
@@ -249,7 +249,7 @@ fn extract_json_from_line(line: &str) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let potential_json = &line[start..=end];
|
||||
let potential_json = line.get(start..=end)?;
|
||||
if serde_json::from_str::<Value>(potential_json).is_ok() {
|
||||
Some(potential_json.to_string())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user