Support for bert
and nomic-bert
embedding models
This commit is contained in:
parent
f0425d3de9
commit
63861f58cc
2 changed files with 14 additions and 0 deletions
|
@ -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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in a new issue