fix: UTF-8 boundary issue in compactor and remove openfang-runtime from bundle
This commit is contained in:
@@ -306,20 +306,24 @@ impl ContextCompactor {
|
||||
fn extract_topic(&self, content: &str) -> Option<String> {
|
||||
let trimmed = content.trim();
|
||||
|
||||
// First sentence or first 50 chars
|
||||
// Find sentence end markers (byte position)
|
||||
let sentence_end = trimmed.find(|c| c == '。' || c == '!' || c == '?' || c == '\n');
|
||||
|
||||
if let Some(pos) = sentence_end {
|
||||
if pos <= 80 {
|
||||
return Some(trimmed[..=pos].to_string());
|
||||
if let Some(byte_pos) = sentence_end {
|
||||
if byte_pos <= 80 {
|
||||
// Find the char boundary after the sentence end marker
|
||||
// The marker itself is a single char (1-3 bytes for Chinese)
|
||||
let end_boundary = byte_pos + trimmed[byte_pos..].chars().next().map(|c| c.len_utf8()).unwrap_or(1);
|
||||
return Some(trimmed[..end_boundary].to_string());
|
||||
}
|
||||
}
|
||||
|
||||
if trimmed.len() <= 50 {
|
||||
if trimmed.chars().count() <= 50 {
|
||||
return Some(trimmed.to_string());
|
||||
}
|
||||
|
||||
Some(format!("{}...", &trimmed[..50]))
|
||||
// Use chars() to safely handle UTF-8 boundaries
|
||||
Some(format!("{}...", trimmed.chars().take(50).collect::<String>()))
|
||||
}
|
||||
|
||||
/// Extract key conclusions/decisions from assistant messages
|
||||
|
||||
@@ -26,13 +26,6 @@
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "nsis",
|
||||
"useLocalToolsDir": true,
|
||||
"resources": [
|
||||
"resources/openfang-runtime/"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/ov"
|
||||
],
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
|
||||
Reference in New Issue
Block a user