route: use numbered classification for reliability
Ask classifier to reply with 1 or 2 instead of full model names. Previous approach produced garbled partial names.
This commit is contained in:
parent
1b92c49c27
commit
8a995c1b13
|
|
@ -101,15 +101,14 @@ func Route(ctx context.Context, req RouteRequest) (RouteResult, error) {
|
|||
powerModel = "anthropic/claude-sonnet-4-20250514"
|
||||
}
|
||||
|
||||
classifyPrompt := fmt.Sprintf(`You are a task router. Given a task description, select the most appropriate model.
|
||||
classifyPrompt := fmt.Sprintf(`You are a task router. Given a task, reply with ONLY the number 1 or 2.
|
||||
|
||||
Available models:
|
||||
1. %s \u2014 fast, cheap, good for: simple edits, single-file changes, straightforward bugs, docs, tests, standard API usage
|
||||
2. %s \u2014 powerful, expensive, good for: multi-file architecture, security-sensitive code, complex algorithms, system design, subtle debugging, performance optimization
|
||||
1 = fast/cheap model, good for: simple edits, single-file changes, straightforward bugs, docs, tests, standard API usage
|
||||
2 = powerful/expensive model, good for: multi-file architecture, security-sensitive code, complex algorithms, system design, subtle debugging, performance optimization
|
||||
|
||||
Reply with ONLY the model name, nothing else.
|
||||
Reply with ONLY the digit 1 or 2. Nothing else.
|
||||
|
||||
Task: %s`, fastModel, powerModel, req.Task)
|
||||
Task: %s`, req.Task)
|
||||
|
||||
msgs := []Message{
|
||||
{Role: "user", Content: classifyPrompt},
|
||||
|
|
@ -124,9 +123,9 @@ Task: %s`, fastModel, powerModel, req.Task)
|
|||
}
|
||||
result := strings.TrimSpace(sb.String())
|
||||
|
||||
// Match result to one of the configured models
|
||||
// Match: if the response contains "2", pick the powerful model
|
||||
model := fastModel
|
||||
if strings.Contains(result, powerModel) {
|
||||
if strings.Contains(result, "2") {
|
||||
model = powerModel
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue