Add max iterations
This commit is contained in:
@@ -446,6 +446,8 @@ type Request struct {
|
||||
Model string `json:"model,omitempty"`
|
||||
// SystemMessage overrides the configured system message for this request.
|
||||
SystemMessage string `json:"system_message,omitempty"`
|
||||
// MaxIterations caps the number of agent loop turns (0 = unlimited).
|
||||
MaxIterations int `json:"max_iterations,omitempty"`
|
||||
}
|
||||
|
||||
// Response is the response format for chat and voice endpoints.
|
||||
@@ -541,7 +543,7 @@ func (svc *Service) chat(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
res, err := llmc.Completions(
|
||||
ctx, model, req.SystemMessage, 0, req.Messages,
|
||||
ctx, model, req.SystemMessage, req.MaxIterations, req.Messages,
|
||||
)
|
||||
if err != nil {
|
||||
log.ErrorContext(
|
||||
@@ -713,7 +715,7 @@ func (svc *Service) chatStream(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
go func() {
|
||||
errs <- llmc.CompletionsStream(
|
||||
ctx, model, req.SystemMessage, 0, req.Messages, events,
|
||||
ctx, model, req.SystemMessage, req.MaxIterations, req.Messages, events,
|
||||
)
|
||||
close(errs)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user