Parth Sareen
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
4 additions and
7 deletions
-
api/types.go
-
cmd/cmd.go
-
server/routes.go
|
|
|
@ -67,7 +67,7 @@ type GenerateRequest struct { |
|
|
|
Raw bool `json:"raw,omitempty"` |
|
|
|
|
|
|
|
// Format specifies the format to return a response in.
|
|
|
|
Format string `json:"format"` |
|
|
|
Format json.RawMessage `json:"format,omitempty"` |
|
|
|
|
|
|
|
// KeepAlive controls how long the model will stay loaded in memory following
|
|
|
|
// this request.
|
|
|
|
|
|
|
|
@ -1126,7 +1126,7 @@ func generate(cmd *cobra.Command, opts runOptions) error { |
|
|
|
Prompt: opts.Prompt, |
|
|
|
Context: generateContext, |
|
|
|
Images: opts.Images, |
|
|
|
Format: opts.Format, |
|
|
|
Format: json.RawMessage(opts.Format), |
|
|
|
System: opts.System, |
|
|
|
Options: opts.Options, |
|
|
|
KeepAlive: opts.KeepAlive, |
|
|
|
|
|
|
|
@ -148,10 +148,7 @@ func (s *Server) GenerateHandler(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if req.Format != "" && req.Format != "json" { |
|
|
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "format must be empty or \"json\""}) |
|
|
|
return |
|
|
|
} else if req.Raw && (req.Template != "" || req.System != "" || len(req.Context) > 0) { |
|
|
|
if req.Raw && (req.Template != "" || req.System != "" || len(req.Context) > 0) { |
|
|
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "raw mode does not support template, system, or context"}) |
|
|
|
return |
|
|
|
} |
|
|
|
@ -278,7 +275,7 @@ func (s *Server) GenerateHandler(c *gin.Context) { |
|
|
|
if err := r.Completion(c.Request.Context(), llm.CompletionRequest{ |
|
|
|
Prompt: prompt, |
|
|
|
Images: images, |
|
|
|
Format: json.RawMessage(req.Format), |
|
|
|
Format: req.Format, |
|
|
|
Options: opts, |
|
|
|
}, func(cr llm.CompletionResponse) { |
|
|
|
res := api.GenerateResponse{ |
|
|
|
|