Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agents:add parameter validation when setting options #1040

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions agents/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ func (co Options) getConversationalPrompt(tools []tools.Tool) prompts.PromptTemp
}

// WithMaxIterations is an option for setting the max number of iterations the executor
// will complete.
// will complete.It must be a positive integer.
func WithMaxIterations(iterations int) Option {
return func(co *Options) {
co.maxIterations = iterations
if iterations > 0 {
co.maxIterations = iterations
}
}
}

Expand Down Expand Up @@ -157,7 +159,9 @@ func WithCallbacksHandler(handler callbacks.Handler) Option {
// WithParserErrorHandler is an option for setting a parser error handler to an executor.
func WithParserErrorHandler(errorHandler *ParserErrorHandler) Option {
return func(co *Options) {
co.errorHandler = errorHandler
if errorHandler != nil {
co.errorHandler = errorHandler
}
}
}

Expand Down