mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(runner): gate llm source on --generator flag
This commit is contained in:
1 parent
dcf7c4a02a
commit
c7402e8f7d
2 files changed
+31
-22
No files matched your search
@@ -36,6 +36,10 @@ type Options struct {
|
||||
Verifier *verifier.Verifier
|
||||
TraceWriter *trace.Writer
|
||||
Logger *slog.Logger
|
||||
// Generator selects the action picker: "llm" drives selection with the
|
||||
// spec's generator = llm({...}) config; anything else (the default) uses the
|
||||
// seeded weighted picker. Both draw from the same actionsRoot candidate set.
|
||||
Generator string
|
||||
}
|
||||
|
||||
type Summary struct {
|
||||
|
||||
+27
-22
@@ -63,34 +63,39 @@ func (s webSource) ExtractorOverrides(ctx context.Context) (map[int]json.RawMess
|
||||
}
|
||||
|
||||
// pickSources selects the runtime's action and extractor sources ONCE at setup
|
||||
// from the driver's capabilities and the spec, so the step loop never
|
||||
// type-asserts. When the spec selected the LLM action backend (actions =
|
||||
// llm({...})) it constructs the chat-completions client and returns an
|
||||
// llmSource for selection while extractor overrides still come from the goja
|
||||
// path.
|
||||
// from the driver's capabilities, the --generator flag, and the spec, so the
|
||||
// step loop never type-asserts. With --generator llm and a spec-declared
|
||||
// generator = llm({...}) it constructs the chat-completions client and returns
|
||||
// an llmSource for selection while extractor overrides still come from the goja
|
||||
// path. Otherwise the seeded goja picker drives.
|
||||
func pickSources(options Options) (ActionSource, ExtractorSource, error) {
|
||||
if web, ok := options.Driver.(driver.WebDriver); ok {
|
||||
source := webSource{web: web}
|
||||
return source, source, nil
|
||||
}
|
||||
if config, ok := options.Verifier.LLMConfig(); ok {
|
||||
client, err := llmclient.New()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("llm action backend: %w", err)
|
||||
logger := options.Logger
|
||||
if logger == nil {
|
||||
logger = slog.Default()
|
||||
}
|
||||
if options.Generator == "llm" {
|
||||
config, ok := options.Verifier.LLMConfig()
|
||||
if !ok {
|
||||
logger.Warn("--generator llm requested but spec declares no generator = llm(); using the seeded picker")
|
||||
} else {
|
||||
client, err := llmclient.New()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("llm action generator: %w", err)
|
||||
}
|
||||
action := &llmSource{
|
||||
verifier: options.Verifier,
|
||||
client: client,
|
||||
model: config.Model,
|
||||
instructions: config.Instructions,
|
||||
logger: logger,
|
||||
history: newActionHistory(llmHistorySize),
|
||||
}
|
||||
return action, gojaSource{verifier: options.Verifier}, nil
|
||||
}
|
||||
logger := options.Logger
|
||||
if logger == nil {
|
||||
logger = slog.Default()
|
||||
}
|
||||
action := &llmSource{
|
||||
verifier: options.Verifier,
|
||||
client: client,
|
||||
model: config.Model,
|
||||
instructions: config.Instructions,
|
||||
logger: logger,
|
||||
history: newActionHistory(llmHistorySize),
|
||||
}
|
||||
return action, gojaSource{verifier: options.Verifier}, nil
|
||||
}
|
||||
source := gojaSource{verifier: options.Verifier}
|
||||
return source, source, nil
|
||||
|
||||
Reference in new issue
Block a user