22 lines
826 B
Go
22 lines
826 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/pgvector/pgvector-go"
|
|
)
|
|
|
|
// ArticleEmbedding stores vector embeddings for semantic article search.
|
|
// Reference: Chatwoot ArticleEmbedding (enterprise) + P2B M9 spec
|
|
type ArticleEmbedding struct {
|
|
Base
|
|
ArticleID uint `gorm:"not null;index" json:"article_id"`
|
|
Embedding json.RawMessage `gorm:"type:jsonb" json:"embedding"` // original JSONB storage (backward compat)
|
|
VectorEmbedding pgvector.Vector `gorm:"type:vector" json:"-"` // dimension follows the configured embedding model
|
|
Term string `gorm:"type:text;not null" json:"term"` // searchable text content
|
|
|
|
Article Article `gorm:"foreignKey:ArticleID" json:"article,omitempty"`
|
|
}
|
|
|
|
func (ArticleEmbedding) TableName() string { return "article_embeddings" }
|