Documentation
¶
Overview ¶
Package cortext is a pure-Go (no CGO) binding for the Cortext multimodal memory engine. Shared libraries and model shards come from the augmem/cortext GitHub Release asset tarball (see EnsureAssets), or from CORTEXT_LIBRARY_PATH / CORTEXT_ASSETS_DIR when set explicitly.
Index ¶
- Constants
- func AssetsDir() string
- func EnsureAssets() (string, error)
- func LastError() string
- func LibraryPath() string
- func LoadLibrary() error
- func MaterializeModel(dbPath string) (string, error)
- func Ptr[T any](value T) *T
- func ResetAssetsForTest()
- func ResetLibraryForTest()
- func Version() string
- type Config
- type EmbeddingResult
- type Handle
- func (h *Handle) Close()
- func (h *Handle) Consolidate() (map[string]any, error)
- func (h *Handle) ConsolidateJSON() ([]byte, error)
- func (h *Handle) EmbedAudio(pcm []float32) ([]float32, error)
- func (h *Handle) EmbedAudioJSON(pcm []float32) ([]byte, error)
- func (h *Handle) EmbedImage(data []byte, width int, height int, channels int) ([]float32, error)
- func (h *Handle) EmbedImageJSON(data []byte, width int, height int, channels int) ([]byte, error)
- func (h *Handle) EmbedText(text string) ([]float32, error)
- func (h *Handle) EmbedTextJSON(text string) ([]byte, error)
- func (h *Handle) Flush() error
- func (h *Handle) ProcessAudio(pcm []float32, sourceID string) (map[string]any, error)
- func (h *Handle) ProcessAudioJSON(pcm []float32, sourceID string) ([]byte, error)
- func (h *Handle) ProcessAudioJSONWithOptions(pcm []float32, sourceID string, options *ProcessOptions) ([]byte, error)
- func (h *Handle) ProcessAudioWithMedia(pcm []float32, sourceID string, media *Media) (map[string]any, error)
- func (h *Handle) ProcessAudioWithMediaAndOptions(pcm []float32, sourceID string, media *Media, options *ProcessOptions) (map[string]any, error)
- func (h *Handle) ProcessAudioWithMediaJSON(pcm []float32, sourceID string, media *Media) ([]byte, error)
- func (h *Handle) ProcessAudioWithMediaJSONWithOptions(pcm []float32, sourceID string, media *Media, options *ProcessOptions) ([]byte, error)
- func (h *Handle) ProcessAudioWithOptions(pcm []float32, sourceID string, options *ProcessOptions) (map[string]any, error)
- func (h *Handle) ProcessImage(data []byte, width int, height int, channels int, sourceID string) (map[string]any, error)
- func (h *Handle) ProcessImageJSON(data []byte, width int, height int, channels int, sourceID string) ([]byte, error)
- func (h *Handle) ProcessImageJSONWithOptions(data []byte, width int, height int, channels int, sourceID string, ...) ([]byte, error)
- func (h *Handle) ProcessImageWithMedia(data []byte, width int, height int, channels int, sourceID string, ...) (map[string]any, error)
- func (h *Handle) ProcessImageWithMediaAndOptions(data []byte, width int, height int, channels int, sourceID string, ...) (map[string]any, error)
- func (h *Handle) ProcessImageWithMediaJSON(data []byte, width int, height int, channels int, sourceID string, ...) ([]byte, error)
- func (h *Handle) ProcessImageWithMediaJSONWithOptions(data []byte, width int, height int, channels int, sourceID string, ...) ([]byte, error)
- func (h *Handle) ProcessImageWithOptions(data []byte, width int, height int, channels int, sourceID string, ...) (map[string]any, error)
- func (h *Handle) ProcessText(text string, sourceID string) (map[string]any, error)
- func (h *Handle) ProcessTextJSON(text string, sourceID string) ([]byte, error)
- func (h *Handle) ProcessTextJSONWithOptions(text string, sourceID string, options *ProcessOptions) ([]byte, error)
- func (h *Handle) ProcessTextWithOptions(text string, sourceID string, options *ProcessOptions) (map[string]any, error)
- func (h *Handle) Reset() error
- type Media
- type ProcessOptions
- type Retention
Constants ¶
const AssetsVersion = "1.2.4"
AssetsVersion is the augmem/cortext release that provides shared natives and model shards (cortext-assets-<version>.tar.gz). Override with CORTEXT_ASSETS_VERSION.
const ModuleVersion = "1.2.4"
ModuleVersion is this Go module's release line. It is independent of the bundled engine AssetsVersion but usually tracks the same minor line.
Variables ¶
This section is empty.
Functions ¶
func AssetsDir ¶ added in v1.2.4
func AssetsDir() string
AssetsDir returns the last EnsureAssets root, or empty if not yet loaded.
func EnsureAssets ¶ added in v1.2.4
EnsureAssets downloads (if needed) and unpacks the shared Cortext release asset tarball from github.com/augmem/cortext, then returns the root that contains native/ and models/.
Layout after unpack:
native/<platform-tag>/libcortext.* models/manifest.json models/AIST-87M-GGUF/chunks/… models/mdbr-leaf-ir/vocab.txt
Resolution order for the asset root:
- CORTEXT_ASSETS_DIR (pre-unpacked tree)
- User/cache dir for AssetsVersion (download once, reuse)
Override the release with CORTEXT_ASSETS_VERSION or the full archive URL with CORTEXT_ASSETS_URL. Checksum is verified from the release .sha256 asset unless CORTEXT_ASSETS_SHA256 is set.
func LastError ¶
func LastError() string
LastError returns the last error produced by this OS thread's C API calls. Note: goroutine migration between calls can lose thread-local error text; prefer the error returned from each method when available.
func LibraryPath ¶
func LibraryPath() string
LibraryPath returns the absolute path that was successfully loaded, if any.
func LoadLibrary ¶
func LoadLibrary() error
LoadLibrary loads the native Cortext shared library if it is not already loaded. New and Version call this automatically. This may download release assets.
func MaterializeModel ¶
MaterializeModel reassembles AIST model chunks from the release asset tree into a local cache and returns the full .gguf path.
Release natives embed AIST and assemble it inside the library on first create. Call MaterializeModel only when an external filesystem GGUF is required.
Chunks always come from EnsureAssets() (augmem/cortext release tarball).
Cache location (first match wins):
- CORTEXT_MODEL_CACHE_DIR
- sibling of dbPath: <dir(dbPath)>/.cortext-assets (":memory:" → cwd)
- user cache under augmem/cortext/models
func ResetAssetsForTest ¶ added in v1.2.4
func ResetAssetsForTest()
ResetAssetsForTest clears the process-wide assets singleton (tests only).
func ResetLibraryForTest ¶ added in v1.2.4
func ResetLibraryForTest()
ResetLibraryForTest clears the process-wide library singleton (tests only).
Types ¶
type Config ¶
type Config struct {
Focus *float64
Sensitivity *float64
Stability *float64
AffectInterrupt *bool
AffectRetrieval *bool
ReinforcementEnabled *bool
ProceduralEnabled *bool
SequentialEdgesEnabled *bool
SignalFilterAudio *bool
SignalFilterImage *bool
SignalFilterText *bool
}
Config overrides native defaults. Nil fields retain their native defaults.
type EmbeddingResult ¶
type EmbeddingResult struct {
Embedding []float32 `json:"embedding"`
Dimension int `json:"dimension"`
}
EmbeddingResult is the JSON shape returned by embed helpers.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is an open Cortext engine instance.
func New ¶
New opens a Cortext instance at dbPath (file path or ":memory:"). cfg may be nil for all native defaults.
The native library is loaded via EnsureAssets (augmem/cortext release tarball). Release natives embed AIST and assemble it on first create. Set CORTEXT_AIST_MODEL_PATH only to force a specific external GGUF file.
func (*Handle) Close ¶
func (h *Handle) Close()
Close frees the native handle. Safe to call multiple times.
func (*Handle) ConsolidateJSON ¶
func (*Handle) EmbedImage ¶
func (*Handle) EmbedImageJSON ¶
func (*Handle) ProcessAudio ¶
func (*Handle) ProcessAudioJSON ¶
func (*Handle) ProcessAudioJSONWithOptions ¶
func (*Handle) ProcessAudioWithMedia ¶
func (*Handle) ProcessAudioWithMediaAndOptions ¶
func (*Handle) ProcessAudioWithMediaJSON ¶
func (*Handle) ProcessAudioWithMediaJSONWithOptions ¶
func (*Handle) ProcessAudioWithOptions ¶
func (*Handle) ProcessImage ¶
func (*Handle) ProcessImageJSON ¶
func (*Handle) ProcessImageJSONWithOptions ¶
func (*Handle) ProcessImageWithMedia ¶
func (*Handle) ProcessImageWithMediaAndOptions ¶
func (*Handle) ProcessImageWithMediaJSON ¶
func (*Handle) ProcessImageWithMediaJSONWithOptions ¶
func (*Handle) ProcessImageWithOptions ¶
func (*Handle) ProcessText ¶
func (*Handle) ProcessTextJSON ¶
func (*Handle) ProcessTextJSONWithOptions ¶
func (*Handle) ProcessTextWithOptions ¶
type ProcessOptions ¶
type ProcessOptions struct {
OmitEmbedding bool
// Retention is Natural when zero-value / omitted.
Retention Retention
}
ProcessOptions configures JSON process result payloads.