Jeffrey Morgan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
5 additions and
7 deletions
-
api/types.go
-
docs/api.md
-
server/routes.go
|
|
|
@ -121,7 +121,6 @@ type Runner struct { |
|
|
|
VocabOnly bool `json:"vocab_only,omitempty"` |
|
|
|
UseMMap bool `json:"use_mmap,omitempty"` |
|
|
|
UseMLock bool `json:"use_mlock,omitempty"` |
|
|
|
EmbeddingOnly bool `json:"embedding_only,omitempty"` |
|
|
|
RopeFrequencyBase float32 `json:"rope_frequency_base,omitempty"` |
|
|
|
RopeFrequencyScale float32 `json:"rope_frequency_scale,omitempty"` |
|
|
|
NumThread int `json:"num_thread,omitempty"` |
|
|
|
@ -395,7 +394,6 @@ func DefaultOptions() Options { |
|
|
|
UseMLock: false, |
|
|
|
UseMMap: true, |
|
|
|
UseNUMA: false, |
|
|
|
EmbeddingOnly: true, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -321,7 +321,6 @@ curl http://localhost:11434/api/generate -d '{ |
|
|
|
"vocab_only": false, |
|
|
|
"use_mmap": true, |
|
|
|
"use_mlock": false, |
|
|
|
"embedding_only": false, |
|
|
|
"rope_frequency_base": 1.1, |
|
|
|
"rope_frequency_scale": 0.8, |
|
|
|
"num_thread": 8 |
|
|
|
|
|
|
|
@ -385,7 +385,7 @@ func GenerateHandler(c *gin.Context) { |
|
|
|
streamResponse(c, ch) |
|
|
|
} |
|
|
|
|
|
|
|
func EmbeddingHandler(c *gin.Context) { |
|
|
|
func EmbeddingsHandler(c *gin.Context) { |
|
|
|
loaded.mu.Lock() |
|
|
|
defer loaded.mu.Unlock() |
|
|
|
|
|
|
|
@ -438,8 +438,9 @@ func EmbeddingHandler(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if !loaded.Options.EmbeddingOnly { |
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "embedding option must be set to true"}) |
|
|
|
// an empty request loads the model
|
|
|
|
if req.Prompt == "" { |
|
|
|
c.JSON(http.StatusOK, api.EmbeddingResponse{Embedding: []float64{}}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@ -948,7 +949,7 @@ func (s *Server) GenerateRoutes() http.Handler { |
|
|
|
r.POST("/api/pull", PullModelHandler) |
|
|
|
r.POST("/api/generate", GenerateHandler) |
|
|
|
r.POST("/api/chat", ChatHandler) |
|
|
|
r.POST("/api/embeddings", EmbeddingHandler) |
|
|
|
r.POST("/api/embeddings", EmbeddingsHandler) |
|
|
|
r.POST("/api/create", CreateModelHandler) |
|
|
|
r.POST("/api/push", PushModelHandler) |
|
|
|
r.POST("/api/copy", CopyModelHandler) |
|
|
|
|