-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solver support Sonnet via OpenRouter #657
Comments
Implementation plan for Sonnet support via OpenRouter:
// Add to existing constants
const SONNET_MODEL: &str = "anthropic/claude-3-sonnet";
// Modify handle_planning to use OpenRouter for initial file selection
fn handle_planning(context: &PlanningContext) -> Result<Plan> {
let openrouter = OpenRouterService::new()?;
// First pass: Use Sonnet to select relevant files
let file_selection_prompt = format!(
"Given this issue:\n{}\n\nAnalyze this repository map and select the most relevant files we need to examine, with reasoning for each:\n{}",
context.issue.body,
context.repomap
);
let (files_response, _) = openrouter.chat(
file_selection_prompt,
SONNET_MODEL,
true // Use reasoning mode
)?;
// Parse file selections and reasons
let selected_files = parse_file_selections(&files_response)?;
// Second pass: Generate detailed implementation plan using local model
let plan_prompt = format!(
"Given these selected files:\n{}\n\nGenerate a detailed implementation plan for:\n{}",
selected_files,
context.issue.body
);
// Use local model for detailed planning
let plan = generate_local_plan(context, &plan_prompt)?;
Ok(plan)
}
#[derive(Debug, Deserialize)]
pub struct FileSelection {
pub path: String,
pub reason: String,
}
#[derive(Debug, Deserialize)]
pub struct FileSelections {
pub files: Vec<FileSelection>,
}
pub fn parse_file_selections(response: &str) -> Result<FileSelections> {
// Extract JSON from markdown response
let json = extract_json_from_markdown(response)?;
// Parse into FileSelections struct
let selections: FileSelections = serde_json::from_str(&json)?;
// Validate paths exist
validate_file_paths(&selections)?;
Ok(selections)
}
impl OpenRouterService {
pub fn chat(
&self,
prompt: String,
model: &str,
use_reasoner: bool
) -> Result<(String, Option<String>)> {
let messages = self.prepare_messages(prompt, use_reasoner);
let response = self.make_request(messages, model)?;
Ok((
response.choices[0].message.content.clone(),
if use_reasoner {
Some(response.choices[0].message.reasoning.clone())
} else {
None
}
))
}
} This implementation:
The flow will be:
This approach:
(Comment from OpenAgents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related to #609
We'll use local for some things and heavy-hitter models on occasion via OpenRouter
We have an existing OpenRouter service
Let's modify the flow specified in docs/solver.md to have Sonnet do the initial selection of files from the repomap and reasons we want to see each one
The text was updated successfully, but these errors were encountered: