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();
|
||||
|
||||
for (file_id, file_content) in file.files.iter() {
|
||||
let temp_file_id = if file.message_type == "files" {
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
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()
|
||||
};
|
||||
|
||||
// Use the same temporary ID that was generated in the streaming parser
|
||||
// This ensures consistency with the IDs generated earlier
|
||||
let chunk_id = format!("{}_{}", file.id, file_content.file_name);
|
||||
|
||||
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();
|
||||
updated_content.file.text_chunk = Some(delta);
|
||||
updated_content.file.text = None;
|
||||
updated_content.id = temp_file_id.clone();
|
||||
updated_files.insert(temp_file_id, updated_content);
|
||||
// Keep the original ID which should already be the temp ID
|
||||
updated_content.id = file_id.clone();
|
||||
updated_files.insert(file_id.clone(), updated_content);
|
||||
has_updates = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,12 +260,13 @@ impl StreamingParser {
|
|||
.and_then(Value::as_str)
|
||||
.unwrap_or("");
|
||||
|
||||
// Generate a consistent UUID based on the file name
|
||||
let file_id = Uuid::new_v4().to_string();
|
||||
|
||||
let buster_file = BusterFile {
|
||||
id: file_id.clone(),
|
||||
file_type: file_type.clone(),
|
||||
file_name: name.to_string(),
|
||||
file_name: name.clone().to_string(),
|
||||
version_number: 1,
|
||||
version_id: Uuid::new_v4().to_string(),
|
||||
status: "loading".to_string(),
|
||||
|
@ -277,8 +278,8 @@ impl StreamingParser {
|
|||
metadata: None,
|
||||
};
|
||||
|
||||
file_ids.push(file_id.clone());
|
||||
files_map.insert(file_id, buster_file);
|
||||
file_ids.push(name.clone().to_string());
|
||||
files_map.insert(name.clone().to_string(), buster_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue