Unverified Commit 63861f58 authored by Jeffrey Morgan's avatar Jeffrey Morgan Committed by GitHub
Browse files

Support for `bert` and `nomic-bert` embedding models

parent f0425d3d
...@@ -52,6 +52,10 @@ type Model struct { ...@@ -52,6 +52,10 @@ type Model struct {
Messages []Message Messages []Message
} }
func (m *Model) IsEmbedding() bool {
return slices.Contains(m.Config.ModelFamilies, "bert") || slices.Contains(m.Config.ModelFamilies, "nomic-bert")
}
type Message struct { type Message struct {
Role string `json:"role"` Role string `json:"role"`
Content string `json:"content"` Content string `json:"content"`
......
...@@ -191,6 +191,11 @@ func GenerateHandler(c *gin.Context) { ...@@ -191,6 +191,11 @@ func GenerateHandler(c *gin.Context) {
return return
} }
if model.IsEmbedding() {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "model does not support generate"})
return
}
opts, err := modelOptions(model, req.Options) opts, err := modelOptions(model, req.Options)
if err != nil { if err != nil {
if errors.Is(err, api.ErrInvalidOpts) { if errors.Is(err, api.ErrInvalidOpts) {
...@@ -1143,6 +1148,11 @@ func ChatHandler(c *gin.Context) { ...@@ -1143,6 +1148,11 @@ func ChatHandler(c *gin.Context) {
return return
} }
if model.IsEmbedding() {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "model does not support chat"})
return
}
opts, err := modelOptions(model, req.Options) opts, err := modelOptions(model, req.Options)
if err != nil { if err != nil {
if errors.Is(err, api.ErrInvalidOpts) { if errors.Is(err, api.ErrInvalidOpts) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment