Add dry run option for chat request
This commit is contained in:
parent
c9a46140e6
commit
38cd80d52c
@ -103,6 +103,10 @@ type ChatRequest struct {
|
|||||||
// Tools is an optional list of tools the model has access to.
|
// Tools is an optional list of tools the model has access to.
|
||||||
Tools `json:"tools,omitempty"`
|
Tools `json:"tools,omitempty"`
|
||||||
|
|
||||||
|
// DryRun when true will prepare and validate the request but stop before sending it to the model.
|
||||||
|
// This allows inspecting how the prompt would be constructed and what parameters would be used.
|
||||||
|
DryRun bool `json:"dry_run,omitempty"`
|
||||||
|
|
||||||
// Options lists model-specific options.
|
// Options lists model-specific options.
|
||||||
Options map[string]interface{} `json:"options"`
|
Options map[string]interface{} `json:"options"`
|
||||||
}
|
}
|
||||||
@ -189,6 +193,7 @@ type ChatResponse struct {
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
Message Message `json:"message"`
|
Message Message `json:"message"`
|
||||||
DoneReason string `json:"done_reason,omitempty"`
|
DoneReason string `json:"done_reason,omitempty"`
|
||||||
|
DryRunOutput string `json:"dry_run_output,omitempty"`
|
||||||
|
|
||||||
Done bool `json:"done"`
|
Done bool `json:"done"`
|
||||||
|
|
||||||
|
@ -1572,6 +1572,18 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.DryRun {
|
||||||
|
c.JSON(http.StatusOK, api.ChatResponse{
|
||||||
|
Model: req.Model,
|
||||||
|
CreatedAt: time.Now().UTC(),
|
||||||
|
Message: api.Message{Role: "assistant", Content: ""},
|
||||||
|
Done: true,
|
||||||
|
DoneReason: "dry_run",
|
||||||
|
DryRunOutput: prompt,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
slog.Debug("chat request", "images", len(images), "prompt", prompt)
|
slog.Debug("chat request", "images", len(images), "prompt", prompt)
|
||||||
|
|
||||||
ch := make(chan any)
|
ch := make(chan any)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user