allow overriding default generate options
This commit is contained in:
parent
268e362fa7
commit
f5e2e150b8
2 changed files with 9 additions and 4 deletions
|
@ -33,8 +33,8 @@ type GenerateRequest struct {
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Prompt string `json:"prompt"`
|
Prompt string `json:"prompt"`
|
||||||
|
|
||||||
ModelOptions `json:"model_opts,omitempty"`
|
ModelOptions *ModelOptions `json:"model_opts,omitempty"`
|
||||||
PredictOptions `json:"predict_opts,omitempty"`
|
PredictOptions *PredictOptions `json:"predict_opts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModelOptions struct {
|
type ModelOptions struct {
|
||||||
|
|
|
@ -38,8 +38,13 @@ func cacheDir() string {
|
||||||
|
|
||||||
func generate(c *gin.Context) {
|
func generate(c *gin.Context) {
|
||||||
var req api.GenerateRequest
|
var req api.GenerateRequest
|
||||||
req.ModelOptions = api.DefaultModelOptions
|
if req.ModelOptions == nil {
|
||||||
req.PredictOptions = api.DefaultPredictOptions
|
req.ModelOptions = &api.DefaultModelOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.PredictOptions == nil {
|
||||||
|
req.PredictOptions = &api.DefaultPredictOptions
|
||||||
|
}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue