nimoracle

package
v0.207.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nimoracle adapts a remote NIM chat model into the structured counterfactual-oracle contract the shadow-labeling flywheel expects (shadow.LabelDeps.RunTier). The local cascade returns grammar-constrained core.Result values; a NIM endpoint returns free text. This package closes that gap per task type: it builds a JSON-only instruction prompt, calls the endpoint, and parser-extracts + validates the reply into exactly the Data shape the shadow judges (pipeline.AnswersAgree, grounding.Check, the B2 summarize judge) consume.

Scope guard: only the ESCALATION (oracle) call is routed remotely. The B1 router-label path inside shadow.LabelQueue reruns the E2B tier through the same RunTier hook — WrapRunTier dispatches any non-oracle model alias to the local RunTier untouched, so router/kNN labels keep their local provenance. NIM calls never enter the savings ledger (deliberate experiment, not defer-avoidance), matching the nimclient package contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(task core.TaskType, req core.Request, raw string) (core.Result, bool)

Adapt converts the remote model's free-text reply into the core.Result shape the shadow judges expect for task. ok=false means un-adaptable — the caller skips the item (the flywheel's normal un-judgeable path). Validation is strict on the fields the judges compare: a classify label outside the request's label set, or a triage decision outside yes/no/unsure, is a malformed oracle answer, not a disagreement — reporting it as Data would poison the agreement label, so it is rejected here instead.

func Preflight

func Preflight(ctx context.Context, chat ChatFunc, model string, cfgMax int) error

Preflight proves the remote oracle can serve a full-size judged reply BEFORE the caller destructively drains the shadow queue: one real chat roundtrip with the SUMMARIZE prompt (the structurally largest instructed shape) at its real budget, adapted through the same path items will take. A classify-sized probe would prove auth but pass at budgets that then truncate every summarize item mid-run. Returns nil when the reply arrived un-truncated and adapted cleanly.

func Prompt

func Prompt(task core.TaskType, req core.Request) (system, user string, ok bool)

Prompt builds the per-task system+user prompt instructing the remote model to answer in exactly the JSON shape the shadow judges parse. ok=false for task types the shadow flywheel does not label (vision/audio tasks never enter the shadow queue).

func SupportedTasks

func SupportedTasks() []string

SupportedTasks is the closed set of shadow-labelable tasks this oracle serves, for the CLI's usage text so the flag help never drifts from the code.

Types

type ChatFunc

type ChatFunc func(ctx context.Context, model, system, user string, maxTokens int, temperature float64) (nimclient.ChatResult, error)

ChatFunc matches (*nimclient.Client).Chat so the client plugs in directly and tests fake the network with a closure.

type RunTierFunc

type RunTierFunc func(ctx context.Context, req core.Request, model string) (core.Result, bool)

RunTierFunc matches shadow.LabelDeps.RunTier / (*pipeline.Pipeline).RunTier.

func WrapRunTier

func WrapRunTier(chat ChatFunc, nimModel string, maxTokens int, oracleAlias string, local RunTierFunc, stats *Stats) RunTierFunc

WrapRunTier returns a RunTier that routes calls for oracleAlias (the escalation slot) through the NIM endpoint via chat+Adapt, and every other model alias (the E2B counterfactual) through local. ok=false on any remote failure, truncation, or un-adaptable reply — shadow.LabelQueue then skips the item, which is the flywheel's normal un-judgeable path, never an abort; stats (optional) records the per-cause counts so the CLI can surface a systemic failure. local is REQUIRED: a nil local would silently starve the B1 router/kNN feed while confhead labeling looked healthy, so it panics at wiring time (a programming error, not a runtime condition).

type Stats

type Stats struct {
	Remote       int // oracle calls attempted against the remote endpoint
	ChatErr      int // transport/HTTP errors (retryable operator problems)
	Truncated    int // finish_reason=length (nim_max_tokens too small for this model)
	Empty        int // empty content (e.g. reasoning model burned the budget thinking)
	Unpromptable int // task the oracle does not serve — skipped FREE, before any call
	Unadaptable  int // a PAID reply that Adapt rejected (actionable: the model's answers are unusable)
	FirstErr     error
}

Stats counts remote-oracle outcomes per skip cause, so a whole-run systemic failure (endpoint dead mid-run, rate limit, model truncating on every item) is distinguishable from a genuinely un-judgeable queue at the CLI summary — per-item ok=false alone collapses transport errors, truncation, empty replies, and malformed answers into one invisible skip. Single-goroutine use (shadow.LabelQueue is sequential); FirstErr keeps the first transport error verbatim because nimclient's errors carry the actionable HTTP status + body.

func (*Stats) String

func (s *Stats) String() string

String renders the counters for the CLI run summary. Unpromptable (free, expected for tasks the oracle does not serve) is deliberately separate from Unadaptable (paid calls whose answers were rejected — a nim_model problem).

Jump to

Keyboard shortcuts

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