Run clippy fix
This commit is contained in:
@@ -63,7 +63,7 @@ pub fn strip_summary_boilerplate(summary: &str) -> String {
|
||||
text = text[phrase.len()..].trim_start().to_string();
|
||||
// Remove leading punctuation/articles after stripping phrase
|
||||
text = text
|
||||
.trim_start_matches(|c| c == ',' || c == ':' || c == '-')
|
||||
.trim_start_matches([',', ':', '-'])
|
||||
.trim_start()
|
||||
.to_string();
|
||||
break;
|
||||
@@ -71,13 +71,12 @@ pub fn strip_summary_boilerplate(summary: &str) -> String {
|
||||
}
|
||||
|
||||
// Remove any remaining leading markdown bold markers
|
||||
if text.starts_with("**") {
|
||||
if let Some(end) = text[2..].find("**") {
|
||||
if text.starts_with("**")
|
||||
&& let Some(end) = text[2..].find("**") {
|
||||
// Keep the content between ** but remove the markers
|
||||
let bold_content = &text[2..2 + end];
|
||||
text = format!("{}{}", bold_content, &text[4 + end..]);
|
||||
}
|
||||
}
|
||||
|
||||
text.trim().to_string()
|
||||
}
|
||||
@@ -144,7 +143,7 @@ pub async fn generate_daily_summaries(
|
||||
if date >= start && date <= end {
|
||||
messages_by_date
|
||||
.entry(date)
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ pub async fn embed_contact_messages(
|
||||
log::info!(
|
||||
"Processing batch {}/{}: messages {}-{} ({:.1}% complete)",
|
||||
batch_idx + 1,
|
||||
(to_embed + batch_size - 1) / batch_size,
|
||||
to_embed.div_ceil(batch_size),
|
||||
batch_start + 1,
|
||||
batch_end,
|
||||
(batch_end as f64 / to_embed as f64) * 100.0
|
||||
|
||||
@@ -84,13 +84,11 @@ impl InsightGenerator {
|
||||
let components: Vec<_> = path.components().collect();
|
||||
|
||||
// If path has at least 2 components (directory + file), extract first directory
|
||||
if components.len() >= 2 {
|
||||
if let Some(component) = components.first() {
|
||||
if let Some(os_str) = component.as_os_str().to_str() {
|
||||
if components.len() >= 2
|
||||
&& let Some(component) = components.first()
|
||||
&& let Some(os_str) = component.as_os_str().to_str() {
|
||||
return Some(os_str.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
@@ -191,8 +189,8 @@ impl InsightGenerator {
|
||||
.into_iter()
|
||||
.filter(|msg| {
|
||||
// Extract date from formatted daily summary "[2024-08-15] Contact ..."
|
||||
if let Some(bracket_end) = msg.find(']') {
|
||||
if let Some(date_str) = msg.get(1..bracket_end) {
|
||||
if let Some(bracket_end) = msg.find(']')
|
||||
&& let Some(date_str) = msg.get(1..bracket_end) {
|
||||
// Parse just the date (daily summaries don't have time)
|
||||
if let Ok(msg_date) =
|
||||
chrono::NaiveDate::parse_from_str(date_str, "%Y-%m-%d")
|
||||
@@ -206,7 +204,6 @@ impl InsightGenerator {
|
||||
return time_diff > exclusion_window;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
})
|
||||
.take(limit)
|
||||
@@ -521,7 +518,7 @@ impl InsightGenerator {
|
||||
"searches about {} {} {}",
|
||||
DateTime::from_timestamp(timestamp, 0)
|
||||
.map(|dt| dt.format("%B %Y").to_string())
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
.unwrap_or_default(),
|
||||
location.unwrap_or(""),
|
||||
contact
|
||||
.map(|c| format!("involving {}", c))
|
||||
|
||||
132
src/ai/ollama.rs
132
src/ai/ollama.rs
@@ -78,12 +78,11 @@ impl OllamaClient {
|
||||
// Check cache first
|
||||
{
|
||||
let cache = MODEL_LIST_CACHE.lock().unwrap();
|
||||
if let Some(entry) = cache.get(url) {
|
||||
if !entry.is_expired() {
|
||||
if let Some(entry) = cache.get(url)
|
||||
&& !entry.is_expired() {
|
||||
log::debug!("Returning cached model list for {}", url);
|
||||
return Ok(entry.data.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::debug!("Fetching fresh model list from {}", url);
|
||||
@@ -93,7 +92,7 @@ impl OllamaClient {
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()?;
|
||||
|
||||
let response = client.get(&format!("{}/api/tags", url)).send().await?;
|
||||
let response = client.get(format!("{}/api/tags", url)).send().await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
return Err(anyhow::anyhow!("Failed to list models from {}", url));
|
||||
@@ -157,7 +156,7 @@ impl OllamaClient {
|
||||
}
|
||||
|
||||
let response = client
|
||||
.post(&format!("{}/api/show", url))
|
||||
.post(format!("{}/api/show", url))
|
||||
.json(&ShowRequest {
|
||||
model: model_name.to_string(),
|
||||
})
|
||||
@@ -188,12 +187,11 @@ impl OllamaClient {
|
||||
// Check cache first
|
||||
{
|
||||
let cache = MODEL_CAPABILITIES_CACHE.lock().unwrap();
|
||||
if let Some(entry) = cache.get(url) {
|
||||
if !entry.is_expired() {
|
||||
if let Some(entry) = cache.get(url)
|
||||
&& !entry.is_expired() {
|
||||
log::debug!("Returning cached model capabilities for {}", url);
|
||||
return Ok(entry.data.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::debug!("Fetching fresh model capabilities from {}", url);
|
||||
@@ -260,7 +258,7 @@ impl OllamaClient {
|
||||
|
||||
let response = self
|
||||
.client
|
||||
.post(&format!("{}/api/generate", url))
|
||||
.post(format!("{}/api/generate", url))
|
||||
.json(&request)
|
||||
.send()
|
||||
.await?;
|
||||
@@ -421,42 +419,40 @@ Return ONLY the title, nothing else."#,
|
||||
sms_str
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if let Some(contact_name) = contact {
|
||||
format!(
|
||||
r#"Create a short title (maximum 8 words) about this moment:
|
||||
} else if let Some(contact_name) = contact {
|
||||
format!(
|
||||
r#"Create a short title (maximum 8 words) about this moment:
|
||||
|
||||
Date: {}
|
||||
Location: {}
|
||||
Person/Contact: {}
|
||||
Messages: {}
|
||||
Date: {}
|
||||
Location: {}
|
||||
Person/Contact: {}
|
||||
Messages: {}
|
||||
|
||||
Use specific details from the context above. The photo is from a folder for {}, so they are likely related to this moment. If no specific details are available, use a simple descriptive title.
|
||||
Use specific details from the context above. The photo is from a folder for {}, so they are likely related to this moment. If no specific details are available, use a simple descriptive title.
|
||||
|
||||
Return ONLY the title, nothing else."#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
contact_name,
|
||||
sms_str,
|
||||
contact_name
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
r#"Create a short title (maximum 8 words) about this moment:
|
||||
Return ONLY the title, nothing else."#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
contact_name,
|
||||
sms_str,
|
||||
contact_name
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
r#"Create a short title (maximum 8 words) about this moment:
|
||||
|
||||
Date: {}
|
||||
Location: {}
|
||||
Messages: {}
|
||||
Date: {}
|
||||
Location: {}
|
||||
Messages: {}
|
||||
|
||||
Use specific details from the context above. If no specific details are available, use a simple descriptive title.
|
||||
Use specific details from the context above. If no specific details are available, use a simple descriptive title.
|
||||
|
||||
Return ONLY the title, nothing else."#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
sms_str
|
||||
)
|
||||
}
|
||||
};
|
||||
Return ONLY the title, nothing else."#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
sms_str
|
||||
)
|
||||
};
|
||||
|
||||
let system = custom_system.unwrap_or("You are my long term memory assistant. Use only the information provided. Do not invent details.");
|
||||
|
||||
@@ -512,39 +508,37 @@ Analyze the image and use specific details from both the visual content and the
|
||||
sms_str
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if let Some(contact_name) = contact {
|
||||
format!(
|
||||
r#"Write a 1-3 paragraph description of this moment based on the available information:
|
||||
} else if let Some(contact_name) = contact {
|
||||
format!(
|
||||
r#"Write a 1-3 paragraph description of this moment based on the available information:
|
||||
|
||||
Date: {}
|
||||
Location: {}
|
||||
Person/Contact: {}
|
||||
Messages: {}
|
||||
Date: {}
|
||||
Location: {}
|
||||
Person/Contact: {}
|
||||
Messages: {}
|
||||
|
||||
Use only the specific details provided above. The photo is from a folder for {}, so they are likely related to this moment. Mention people's names (especially {}), places, or activities if they appear in the context. Write in first person as Cameron with the tone of a journal entry. If limited information is available, keep it simple and factual. If the location is unknown omit it"#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
contact_name,
|
||||
sms_str,
|
||||
contact_name,
|
||||
contact_name
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
r#"Write a 1-3 paragraph description of this moment based on the available information:
|
||||
Use only the specific details provided above. The photo is from a folder for {}, so they are likely related to this moment. Mention people's names (especially {}), places, or activities if they appear in the context. Write in first person as Cameron with the tone of a journal entry. If limited information is available, keep it simple and factual. If the location is unknown omit it"#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
contact_name,
|
||||
sms_str,
|
||||
contact_name,
|
||||
contact_name
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
r#"Write a 1-3 paragraph description of this moment based on the available information:
|
||||
|
||||
Date: {}
|
||||
Location: {}
|
||||
Messages: {}
|
||||
Date: {}
|
||||
Location: {}
|
||||
Messages: {}
|
||||
|
||||
Use only the specific details provided above. Mention people's names, places, or activities if they appear in the context. Write in first person as Cameron with the tone of a journal entry. If limited information is available, keep it simple and factual. If the location is unknown omit it"#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
sms_str
|
||||
)
|
||||
}
|
||||
};
|
||||
Use only the specific details provided above. Mention people's names, places, or activities if they appear in the context. Write in first person as Cameron with the tone of a journal entry. If limited information is available, keep it simple and factual. If the location is unknown omit it"#,
|
||||
date.format("%B %d, %Y"),
|
||||
location_str,
|
||||
sms_str
|
||||
)
|
||||
};
|
||||
|
||||
let system = custom_system.unwrap_or("You are a memory refreshing assistant who is able to provide insights through analyzing past conversations. Use only the information provided. Do not invent details.");
|
||||
|
||||
@@ -671,7 +665,7 @@ Use only the specific details provided above. Mention people's names, places, or
|
||||
|
||||
let response = self
|
||||
.client
|
||||
.post(&format!("{}/api/embed", url))
|
||||
.post(format!("{}/api/embed", url))
|
||||
.json(&request)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user