add clippy warning for string_slice (#5422)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -8,7 +8,7 @@ use tokio::process::Command;
|
||||
|
||||
use super::base::{Provider, ProviderMetadata, ProviderUsage, Usage};
|
||||
use super::errors::ProviderError;
|
||||
use super::utils::RequestLog;
|
||||
use super::utils::{filter_extensions_from_system_prompt, RequestLog};
|
||||
use crate::conversation::message::{Message, MessageContent};
|
||||
|
||||
use crate::model::ModelConfig;
|
||||
@@ -103,28 +103,6 @@ impl GeminiCliProvider {
|
||||
None
|
||||
}
|
||||
|
||||
/// Filter out the Extensions section from the system prompt
|
||||
fn filter_extensions_from_system_prompt(&self, system: &str) -> String {
|
||||
// Find the Extensions section and remove it
|
||||
if let Some(extensions_start) = system.find("# Extensions") {
|
||||
// Look for the next major section that starts with #
|
||||
let after_extensions = &system[extensions_start..];
|
||||
if let Some(next_section_pos) = after_extensions[1..].find("\n# ") {
|
||||
// Found next section, keep everything before Extensions and after the next section
|
||||
let before_extensions = &system[..extensions_start];
|
||||
let next_section_start = extensions_start + next_section_pos + 1;
|
||||
let after_next_section = &system[next_section_start..];
|
||||
format!("{}{}", before_extensions.trim_end(), after_next_section)
|
||||
} else {
|
||||
// No next section found, just remove everything from Extensions onward
|
||||
system[..extensions_start].trim_end().to_string()
|
||||
}
|
||||
} else {
|
||||
// No Extensions section found, return original
|
||||
system.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute gemini CLI command with simple text prompt
|
||||
async fn execute_command(
|
||||
&self,
|
||||
@@ -135,8 +113,7 @@ impl GeminiCliProvider {
|
||||
// Create a simple prompt combining system + conversation
|
||||
let mut full_prompt = String::new();
|
||||
|
||||
// Add system prompt
|
||||
let filtered_system = self.filter_extensions_from_system_prompt(system);
|
||||
let filtered_system = filter_extensions_from_system_prompt(system);
|
||||
full_prompt.push_str(&filtered_system);
|
||||
full_prompt.push_str("\n\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user