feat: set unused text outputs to null based on method options
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -223,6 +223,26 @@ impl TextMetaPlugin {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
// If content is binary, set all text-related outputs to None
|
||||
if is_binary_result {
|
||||
let text_outputs = vec![
|
||||
"text_word_count",
|
||||
"text_line_count",
|
||||
"text_line_max_len",
|
||||
"text_line_mean_len",
|
||||
"text_line_median_len",
|
||||
];
|
||||
for output_name in text_outputs {
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
output_name,
|
||||
serde_yaml::Value::Null,
|
||||
self.base.outputs()
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(metadata, is_binary_result)
|
||||
}
|
||||
|
||||
@@ -489,6 +509,23 @@ impl MetaPlugin for TextMetaPlugin {
|
||||
if is_binary {
|
||||
self.buffer = None; // Drop the buffer
|
||||
self.is_finalized = true;
|
||||
// Set all text-related outputs to None since content is binary
|
||||
let text_outputs = vec![
|
||||
"text_word_count",
|
||||
"text_line_count",
|
||||
"text_line_max_len",
|
||||
"text_line_mean_len",
|
||||
"text_line_median_len",
|
||||
];
|
||||
for output_name in text_outputs {
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
output_name,
|
||||
serde_yaml::Value::Null,
|
||||
self.base.outputs()
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
return MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
@@ -504,6 +541,27 @@ impl MetaPlugin for TextMetaPlugin {
|
||||
metadata.extend(word_line_metadata);
|
||||
}
|
||||
|
||||
// Set disabled outputs to None
|
||||
let outputs_to_check = vec![
|
||||
("text_word_count", self.track_word_count),
|
||||
("text_line_count", self.track_line_count),
|
||||
("text_line_max_len", self.output_line_max_len),
|
||||
("text_line_mean_len", self.output_line_mean_len),
|
||||
("text_line_median_len", self.output_line_median_len),
|
||||
];
|
||||
|
||||
for (output_name, is_enabled) in outputs_to_check {
|
||||
if !is_enabled {
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
output_name,
|
||||
serde_yaml::Value::Null,
|
||||
self.base.outputs()
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drop the buffer since we're done with it
|
||||
self.buffer = None;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user