mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-13 09:17:02 +00:00
Support for bert and nomic-bert embedding models
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user