Fix browser closure timing in search agent
Move defer statement to ensure browser closure occurs only after assigning the browser to the context. This prevents potential issues of premature resource release.
This commit is contained in:
@@ -7,10 +7,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitea.stevedudenhoeffer.com/steve/answer/pkg/agents"
|
||||
gollm "gitea.stevedudenhoeffer.com/steve/go-llm"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"gitea.stevedudenhoeffer.com/steve/answer/pkg/agents"
|
||||
)
|
||||
|
||||
func getKey(key string, env string) string {
|
||||
@@ -80,7 +81,7 @@ func main() {
|
||||
llm = gollm.OpenAI(getKey(c.String("llm-key"), "OPENAI_API_KEY"))
|
||||
|
||||
case "anthropic":
|
||||
llm = gollm.Anthropic(getKey(c.String("llm-key"), "ANTHROPI_API_KEY"))
|
||||
llm = gollm.Anthropic(getKey(c.String("llm-key"), "ANTHROPIC_API_KEY"))
|
||||
|
||||
case "google":
|
||||
llm = gollm.Google(getKey(c.String("llm-key"), "GOOGLE_API_KEY"))
|
||||
@@ -96,7 +97,7 @@ func main() {
|
||||
}
|
||||
question := strings.Join(c.Args(), " ")
|
||||
|
||||
agent := agents.NewAgent(m, nil).WithMaxCalls(200)
|
||||
agent := agents.NewAgent(m, gollm.ToolBox{}).WithMaxCalls(200)
|
||||
|
||||
knowledge, err := agent.SearchAndRead(ctx, question, []string{question}, true, 10)
|
||||
|
||||
|
Reference in New Issue
Block a user