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
- func DefaultAssetDir() string
- func IsProvisioned(cfg Config) bool
- func Load(cfg Config, opts ...sdk.Option) (*sdk.Extractor, error)
- func LoadConfigured(opts ...sdk.Option) (*sdk.Extractor, error)
- func Provision(ctx context.Context, cfg Config, opts ...sdk.Option) error
- func SmokeCheck(ctx context.Context, cfg Config, opts ...sdk.Option) error
- func Teardown(cfg Config) error
- type Config
- type ExtractOptions
- type Extractor
- type Result
Constants ¶
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 ¶
IsProvisioned reports whether the asset dir already holds provisioned assets, detected by the presence of the SDK manifest.
func Load ¶
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 ¶
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 ¶
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 ¶
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.
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.
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 ¶
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 ¶
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.