semantic

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBackend = "lancedb"
	FakeBackend    = "fake"
	SidecarSchema  = "pinax.kb.sidecar.v1"
)
View Source
const (
	DefaultProvider    = "gemini"
	DefaultModel       = "text-embedding-004"
	OpenAIDefaultModel = "text-embedding-3-small"
	OllamaDefaultModel = "nomic-embed-text"
	FakeProviderModel  = "fake-hash-v1"
)

Variables

This section is empty.

Functions

func Doctor

func Doctor(ctx context.Context, root, backend string, sidecar SidecarConfig) (map[string]any, error)

func DoctorProvider added in v0.1.3

func DoctorProvider(ctx context.Context, name, model string) (map[string]any, error)

func EnableSharedResolver added in v0.1.6

func EnableSharedResolver(r credentials.Resolver)

EnableSharedResolver attaches the credentialctl shared credential resolver so the OpenAI embedding provider falls back to the shared credential when OPENAI_API_KEY is unset. Passing nil disables the fallback.

func Save

func Save(ctx context.Context, root string, chunks []Chunk, backend string, sidecar SidecarConfig, documents int) (string, error)

Types

type BackendInfo added in v0.1.3

type BackendInfo struct {
	Name            string `json:"name"`
	LocalOnly       bool   `json:"local_only"`
	RequiresSidecar bool   `json:"requires_sidecar"`
	Description     string `json:"description,omitempty"`
}

func ListBackends added in v0.1.3

func ListBackends() []BackendInfo

type BatchProvider added in v0.1.3

type BatchProvider interface {
	EmbedBatch(ctx context.Context, texts []string) ([][]float64, error)
}

type Chunk

type Chunk struct {
	ChunkID        string    `json:"chunk_id"`
	NoteID         string    `json:"note_id,omitempty"`
	VaultPath      string    `json:"vault_path"`
	Title          string    `json:"title"`
	HeadingPath    string    `json:"heading_path,omitempty"`
	ChunkText      string    `json:"chunk_text"`
	Preview        string    `json:"preview"`
	ContentHash    string    `json:"content_hash"`
	ChunkHash      string    `json:"chunk_hash"`
	TokenCount     int       `json:"token_count"`
	Tags           []string  `json:"tags,omitempty"`
	Kind           string    `json:"kind,omitempty"`
	Status         string    `json:"status,omitempty"`
	EmbeddingModel string    `json:"embedding_model"`
	EmbeddingDim   int       `json:"embedding_dim"`
	Provider       string    `json:"provider"`
	Backend        string    `json:"backend"`
	Vector         []float64 `json:"vector"`
	IndexedAt      string    `json:"indexed_at"`
}

func BuildChunks

func BuildChunks(ctx context.Context, notes []domain.Note, provider Provider, backend string) ([]Chunk, error)

type FakeProvider

type FakeProvider struct{ ModelName string }

func (FakeProvider) Embed

func (p FakeProvider) Embed(_ context.Context, text string) ([]float64, error)

func (FakeProvider) EmbedBatch added in v0.1.3

func (p FakeProvider) EmbedBatch(_ context.Context, texts []string) ([][]float64, error)

func (FakeProvider) Model

func (p FakeProvider) Model() string

func (FakeProvider) Name

func (p FakeProvider) Name() string

type FileStore

type FileStore struct {
	Root    string
	Backend string
}

func NewFileStore

func NewFileStore(root, backend string) FileStore

func (FileStore) Load

func (s FileStore) Load() ([]Chunk, error)

func (FileStore) Path

func (s FileStore) Path() string

func (FileStore) Save

func (s FileStore) Save(chunks []Chunk) error

type GeminiProvider

type GeminiProvider struct {
	APIKey     string
	ModelName  string
	HTTPClient *http.Client
}

func (GeminiProvider) Embed

func (p GeminiProvider) Embed(ctx context.Context, text string) ([]float64, error)

func (GeminiProvider) Model

func (p GeminiProvider) Model() string

func (GeminiProvider) Name

func (p GeminiProvider) Name() string

type KBDomain added in v0.1.6

type KBDomain struct{}

KBDomain is the pinax knowledge-base adapter for the shared lance vector + RAG platform. It knows the table name, the redaction policy for note metadata, and the permission rules (filter by note status and kind).

The metadata field names mirror pinax's existing sidecarChunk schema (chunk_id, note_id, vault_path, heading_path, status, kind, ...).

func (KBDomain) Name added in v0.1.6

func (KBDomain) Name() string

Name returns the domain identifier "kb".

func (KBDomain) Redact added in v0.1.6

func (KBDomain) Redact(record map[string]any) map[string]any

Redact strips sensitive fields from a record's metadata before it leaves the knowledge-base domain. The safe-to-surface keys (chunk_id, note_id, vault_path, heading_path, title, preview, kind, status, tags, content_hash, chunk_hash, token_count) pass through untouched.

func (KBDomain) ResolvePermission added in v0.1.6

func (KBDomain) ResolvePermission(_ context.Context, records []lance.Record, filter lance.PermissionFilter) []string

ResolvePermission computes the set of allowed record IDs given an opaque filter. The filter may carry:

  • note_status: []string e.g. ["active"] — only records whose metadata["status"] is in this list are allowed.
  • note_kind: []string e.g. ["note","journal"] — only records whose metadata["kind"] is in this list are allowed.

A missing or empty filter dimension matches everything (no restriction). Records with no metadata pass unless a filter dimension is set.

func (KBDomain) TableName added in v0.1.6

func (KBDomain) TableName() string

TableName returns the LanceDB table name for knowledge-base chunks.

type OllamaProvider added in v0.1.3

type OllamaProvider struct {
	ModelName  string
	BaseURL    string
	HTTPClient *http.Client
}

func (OllamaProvider) Doctor added in v0.1.3

func (p OllamaProvider) Doctor(ctx context.Context) error

func (OllamaProvider) Embed added in v0.1.3

func (p OllamaProvider) Embed(ctx context.Context, text string) ([]float64, error)

func (OllamaProvider) EmbedBatch added in v0.1.3

func (p OllamaProvider) EmbedBatch(ctx context.Context, texts []string) ([][]float64, error)

func (OllamaProvider) Model added in v0.1.3

func (p OllamaProvider) Model() string

func (OllamaProvider) Name added in v0.1.3

func (p OllamaProvider) Name() string

type OpenAIProvider added in v0.1.3

type OpenAIProvider struct {
	APIKey     string
	ModelName  string
	BaseURL    string
	HTTPClient *http.Client
}

func (OpenAIProvider) Embed added in v0.1.3

func (p OpenAIProvider) Embed(ctx context.Context, text string) ([]float64, error)

func (OpenAIProvider) EmbedBatch added in v0.1.3

func (p OpenAIProvider) EmbedBatch(ctx context.Context, texts []string) ([][]float64, error)

func (OpenAIProvider) Model added in v0.1.3

func (p OpenAIProvider) Model() string

func (OpenAIProvider) Name added in v0.1.3

func (p OpenAIProvider) Name() string

type Provider

type Provider interface {
	Name() string
	Model() string
	Embed(ctx context.Context, text string) ([]float64, error)
}

func NewProvider

func NewProvider(name, model string) (Provider, error)

type ProviderInfo added in v0.1.3

type ProviderInfo struct {
	Name               string `json:"name"`
	DefaultModel       string `json:"default_model"`
	Configured         bool   `json:"configured"`
	CredentialSource   string `json:"credential_source,omitempty"`
	LocalOnly          bool   `json:"local_only"`
	RequiresCredential bool   `json:"requires_credential"`
}

func ListProviders added in v0.1.3

func ListProviders() []ProviderInfo

func ProviderInfoFor added in v0.1.3

func ProviderInfoFor(name string) (ProviderInfo, error)

type SearchHit

type SearchHit struct {
	ChunkID     string   `json:"chunk_id"`
	NoteID      string   `json:"note_id,omitempty"`
	Path        string   `json:"path"`
	Title       string   `json:"title"`
	HeadingPath string   `json:"heading_path,omitempty"`
	Preview     string   `json:"preview"`
	Score       float64  `json:"score"`
	Provider    string   `json:"provider,omitempty"`
	Model       string   `json:"model,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	Kind        string   `json:"kind,omitempty"`
	Status      string   `json:"status,omitempty"`
}
func Search(ctx context.Context, root, query string, provider Provider, backend string, limit int, sidecar SidecarConfig) ([]SearchHit, int, error)

type SidecarConfig

type SidecarConfig struct {
	Executable string
	Timeout    time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL