mirror of https://github.com/buster-so/buster.git
file unique id
This commit is contained in:
parent
070a5c7455
commit
97656868d3
|
@ -1182,16 +1182,8 @@ fn transform_assistant_tool_message(
|
||||||
let mut updated_files = std::collections::HashMap::new();
|
let mut updated_files = std::collections::HashMap::new();
|
||||||
|
|
||||||
for (file_id, file_content) in file.files.iter() {
|
for (file_id, file_content) in file.files.iter() {
|
||||||
let temp_file_id = if file.message_type == "files" {
|
// Use the same temporary ID that was generated in the streaming parser
|
||||||
use std::collections::hash_map::DefaultHasher;
|
// This ensures consistency with the IDs generated earlier
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
let mut hasher = DefaultHasher::new();
|
|
||||||
file_content.file_name.hash(&mut hasher);
|
|
||||||
format!("temp_{}", hasher.finish())
|
|
||||||
} else {
|
|
||||||
file_id.clone()
|
|
||||||
};
|
|
||||||
|
|
||||||
let chunk_id = format!("{}_{}", file.id, file_content.file_name);
|
let chunk_id = format!("{}_{}", file.id, file_content.file_name);
|
||||||
|
|
||||||
if let Some(chunk) = &file_content.file.text_chunk {
|
if let Some(chunk) = &file_content.file.text_chunk {
|
||||||
|
@ -1201,8 +1193,9 @@ fn transform_assistant_tool_message(
|
||||||
let mut updated_content = file_content.clone();
|
let mut updated_content = file_content.clone();
|
||||||
updated_content.file.text_chunk = Some(delta);
|
updated_content.file.text_chunk = Some(delta);
|
||||||
updated_content.file.text = None;
|
updated_content.file.text = None;
|
||||||
updated_content.id = temp_file_id.clone();
|
// Keep the original ID which should already be the temp ID
|
||||||
updated_files.insert(temp_file_id, updated_content);
|
updated_content.id = file_id.clone();
|
||||||
|
updated_files.insert(file_id.clone(), updated_content);
|
||||||
has_updates = true;
|
has_updates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,12 +260,13 @@ impl StreamingParser {
|
||||||
.and_then(Value::as_str)
|
.and_then(Value::as_str)
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
// Generate a consistent UUID based on the file name
|
||||||
let file_id = Uuid::new_v4().to_string();
|
let file_id = Uuid::new_v4().to_string();
|
||||||
|
|
||||||
let buster_file = BusterFile {
|
let buster_file = BusterFile {
|
||||||
id: file_id.clone(),
|
id: file_id.clone(),
|
||||||
file_type: file_type.clone(),
|
file_type: file_type.clone(),
|
||||||
file_name: name.to_string(),
|
file_name: name.clone().to_string(),
|
||||||
version_number: 1,
|
version_number: 1,
|
||||||
version_id: Uuid::new_v4().to_string(),
|
version_id: Uuid::new_v4().to_string(),
|
||||||
status: "loading".to_string(),
|
status: "loading".to_string(),
|
||||||
|
@ -277,8 +278,8 @@ impl StreamingParser {
|
||||||
metadata: None,
|
metadata: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
file_ids.push(file_id.clone());
|
file_ids.push(name.clone().to_string());
|
||||||
files_map.insert(file_id, buster_file);
|
files_map.insert(name.clone().to_string(), buster_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue