extractor

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package extractor resolves and wraps the OASF taxonomy extractor for both dirctl and the server gateway. The extractor turns free-form text into OASF skills, domains, modules, and keywords; it is reachable two ways — an in-process library over locally-provisioned assets, or a remote gRPC OASF-SDK server — and ResolveExtractor picks between them so callers never need to know where they run.

Index

Constants

View Source
const DefaultOASFURL = "https://schema.oasf.outshift.com"

DefaultOASFURL is the official OASF schema endpoint used when none is chosen.

Variables

This section is empty.

Functions

func DefaultAssetDir

func DefaultAssetDir() string

DefaultAssetDir returns the default local asset directory (~/.agntcy/oasf-sdk/extractor), matching the oasf-sdk default, and falling back to a temp dir when the home directory cannot be determined.

func IsProvisioned

func IsProvisioned(cfg Config) bool

IsProvisioned reports whether the asset dir already holds provisioned assets, detected by the presence of the SDK manifest.

func Load

func Load(cfg Config, opts ...sdk.Option) (*sdk.Extractor, error)

Load builds a ready-to-use in-process extractor from the assets a prior Provision (dirctl init) wrote to cfg.AssetDir. It NEVER provisions: it errors when the extractor has not been set up, so read-path consumers fail clearly instead of implicitly triggering an ~89 MB download.

func LoadConfigured

func LoadConfigured(opts ...sdk.Option) (*sdk.Extractor, error)

LoadConfigured loads the extractor using the OASF URL / asset dir persisted by dirctl init, erroring clearly when init has not been run. This is the entry point for read-path consumers (import enrichment, search): they get a ready client or an actionable error, and never provision implicitly.

func Provision

func Provision(ctx context.Context, cfg Config, opts ...sdk.Option) error

Provision downloads and caches the extractor's assets (model + embedded OASF taxonomy) under cfg.AssetDir, pulling the taxonomy from cfg.OASFURL. It is idempotent: the SDK skips the model load and re-embed when the on-disk assets already match the endpoint and taxonomy. Extra opts are forwarded to the SDK (e.g. a test embedder).

func SmokeCheck

func SmokeCheck(ctx context.Context, cfg Config, opts ...sdk.Option) error

SmokeCheck loads the provisioned assets and runs one extraction, returning an error if the client can't be built or the round-trip yields no skills and no domains. It confirms the assets are usable in-process by consumers.

func Teardown

func Teardown(cfg Config) error

Teardown removes the provisioned asset dir. It refuses to remove an empty path, the filesystem root, or the user's home directory, so a misconfigured asset dir can never wipe unrelated files. Removing an absent dir is a no-op.

Types

type Config

type Config struct {
	OASFURL    string
	AssetDir   string
	RemoteAddr string // gRPC OASF-SDK server address; empty => local assets
}

Config selects how the extractor is reached. When RemoteAddr is set, the resolver dials that gRPC OASF-SDK server; otherwise it loads the in-process assets provisioned under AssetDir from the taxonomy at OASFURL.

func (Config) Resolve

func (c Config) Resolve() Config

Resolve returns a copy of c with any empty local field filled by its default. RemoteAddr has no default: it is empty unless explicitly configured.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the local-assets config is usable for provisioning: the OASF URL must be a non-empty absolute http(s) URL and the asset dir must be absolute. It does not validate RemoteAddr (a remote backend needs no local assets).

type ExtractOptions

type ExtractOptions struct {
	// Versions pins the OASF schema versions to consider. Empty means all.
	Versions []string
}

ExtractOptions carries the backend-agnostic, per-query knobs. It deliberately omits construction-time tuning (embedding weights, default thresholds), which only a local extractor can honor and are supplied when it is built.

type Extractor

type Extractor interface {
	Extract(ctx context.Context, text string, opts ExtractOptions) (Result, error)
	// Close releases resources held by the extractor, such as the remote
	// backend's gRPC connection. Callers that resolve an extractor own its
	// lifecycle and should Close it when done. The local backend holds no
	// closable resources and returns nil.
	Close() error
}

Extractor turns free-form text into OASF skills, domains, modules, and keywords. It is satisfied by both the in-process local backend and the remote gRPC OASF-SDK backend, so callers depend only on this interface.

func ResolveConfigured

func ResolveConfigured(localOpts ...sdk.Option) (Extractor, error)

ResolveConfigured resolves the extractor from the machine-wide config saved by `dirctl init`, returning the Extractor interface. It honors a persisted RemoteAddr (remote backend) and otherwise loads the provisioned local assets. localOpts tune the local backend only. It errors clearly when init has not run.

func ResolveExtractor

func ResolveExtractor(cfg Config, localOpts ...sdk.Option) (Extractor, error)

ResolveExtractor returns a ready Extractor for cfg: the remote gRPC backend when RemoteAddr is set, otherwise the in-process local backend loaded from provisioned assets. localOpts tune only the local backend (e.g. embedding weights); they are ignored by the remote backend, whose weighting is fixed by the server. It errors when neither backend is available.

type Result

type Result = sdk.Result

Result is the extractor output: skills, domains, modules, and keywords found in the input text. It is the SDK type so downstream consumers (e.g. the nlsearch decomposer) work unchanged regardless of which backend produced it.

Jump to

Keyboard shortcuts

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