You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's easy to make errors with the current options system, there's some cases where you're passing an option that is ignored.
For instance some objects like executors (Executor struct) and agents (OneShotZeroAgent, ConversationalAgent structs) share the same set of options but they don't use all of them.
There's probably the same problem in other parts of langchaingo but I only wanted to open a small discussion to know if this is relevant to others, or if we should consider that it's up to the developper to have a bit of "common sense" to know where it's relevant to use an option.
I was trying to build an agent :
import (
...
"github.com/tmc/langchaingo/agents"
)
...
agent := agents.NewOneShotAgent(llm,
[]tools.Tool{
tool1,
tool2,
},
agents.WithMaxIterations(5),
//agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- this options is useless here
)
executor := agents.NewExecutor(
agent,
agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- it works here
),
But agents.WithParserErrorHandler is ignored when passed to agents.NewOneShotAgent as an option.
To fix this we may introduce an executor package under agents:
import (
...
"github.com/tmc/langchaingo/agents"
agentExec "github.com/tmc/langchaingo/agents/executor"
)
...
agent := agents.NewOneShotAgent(llm,
[]tools.Tool{
tool1,
tool2,
},
agents.WithMaxIterations(5),
//agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- this options is useless here
)
executor := agentExec.New(
agent,
agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- it works here
),
In addition this allow to shorten names a bit in a way that may be more intuitive i.e. pkgName.New
By the way names like agents.NewOneShotAgent a bit redundant.
I know this kind of changes would introduce breaking changes and it's probably not the most urgent change to add but if it matters I may open a PR for this ?
Seems related to: #1007#862
I also saw that there's already some issues to reorg a bit the repository packages #369
The text was updated successfully, but these errors were encountered:
treywelsh
changed the title
agent/executore: ignored options
agent/executor: ignored options
Oct 18, 2024
It's easy to make errors with the current options system, there's some cases where you're passing an option that is ignored.
For instance some objects like executors (Executor struct) and agents (OneShotZeroAgent, ConversationalAgent structs) share the same set of options but they don't use all of them.
There's probably the same problem in other parts of langchaingo but I only wanted to open a small discussion to know if this is relevant to others, or if we should consider that it's up to the developper to have a bit of "common sense" to know where it's relevant to use an option.
I was trying to build an agent :
But
agents.WithParserErrorHandler
is ignored when passed toagents.NewOneShotAgent
as an option.To fix this we may introduce an executor package under agents:
In addition this allow to shorten names a bit in a way that may be more intuitive i.e. pkgName.New
By the way names like
agents.NewOneShotAgent
a bit redundant.I know this kind of changes would introduce breaking changes and it's probably not the most urgent change to add but if it matters I may open a PR for this ?
Seems related to: #1007 #862
I also saw that there's already some issues to reorg a bit the repository packages #369
The text was updated successfully, but these errors were encountered: