Skip to content

Commit

Permalink
Add afforder strategy cli arg
Browse files Browse the repository at this point in the history
  • Loading branch information
noahshinn committed Dec 6, 2023
1 parent 51d6530 commit 9a1127a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions afforder/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package afforder

import (
"collaborativebrowser/afforder/afforderstrategy"
"collaborativebrowser/afforder/afforderstrategy/filterafforder"

Check failure on line 5 in afforder/strategy.go

View workflow job for this annotation

GitHub Actions / build

package collaborativebrowser/afforder/afforderstrategy/filterafforder is not in std (/opt/hostedtoolcache/go/1.21.0/x64/src/collaborativebrowser/afforder/afforderstrategy/filterafforder)
"collaborativebrowser/afforder/afforderstrategy/functionafforder"
"log"
)
Expand All @@ -10,6 +11,7 @@ type AfforderStrategyID string

const (
AfforderStrategyIDFunctionAfforder AfforderStrategyID = "function_afforder"
AfforderStrategyIDFilterAfforder AfforderStrategyID = "filter_afforder"
)

const DefaultAfforderStrategyID = AfforderStrategyIDFunctionAfforder
Expand All @@ -18,6 +20,8 @@ func AfforderStrategyByID(id AfforderStrategyID) afforderstrategy.AfforderStrate
switch id {
case AfforderStrategyIDFunctionAfforder:
return functionafforder.New()
case AfforderStrategyIDFilterAfforder:
return filterafforder.New()
default:
log.Printf("invalid afforder strategy ID: %s; defaulting to %s", id, DefaultAfforderStrategyID)
return functionafforder.New()
Expand Down
14 changes: 10 additions & 4 deletions cmd/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"collaborativebrowser/actor"
"collaborativebrowser/afforder"
"collaborativebrowser/browser"
"collaborativebrowser/runner/finiterunner"
"collaborativebrowser/trajectory"
Expand All @@ -21,6 +22,7 @@ func main() {
logPath := flag.String("log-path", "out", "the path to write the trajectory and browser display to")
initialURL := flag.String("url", "https://www.google.com", "the initial url to visit")
actorStrategy := flag.String("actor-strategy", "base_llm", "the actor strategy to use; one of [base_llm, reflexion]")
afforderStrategy := flag.String("afforder-strategy", "function_afforder", "the afforder strategy to use; one of [function_afforder, filter_afforder]")
verbose := flag.Bool("verbose", false, "whether to print verbose debug logs")
flag.Parse()

Expand All @@ -46,11 +48,15 @@ func main() {
if *actorStrategy == "" {
*actorStrategy = string(actor.DefaultActorStrategyID)
}
if *afforderStrategy == "" {
*afforderStrategy = string(afforder.DefaultAfforderStrategyID)
}
runner, err := finiterunner.NewFiniteRunnerFromInitialPage(ctx, *initialURL, apiKeys, &finiterunner.Options{
MaxNumSteps: 5,
BrowserOptions: browserOptions,
LogPath: *logPath,
ActorStrategyID: actor.ActorStrategyID(*actorStrategy),
MaxNumSteps: 5,
BrowserOptions: browserOptions,
LogPath: *logPath,
ActorStrategyID: actor.ActorStrategyID(*actorStrategy),
AfforderStrategyID: afforder.AfforderStrategyID(*afforderStrategy),
})
if err != nil {
panic(fmt.Errorf("failed to create runner: %w", err))
Expand Down

0 comments on commit 9a1127a

Please sign in to comment.