Documentation
¶
Overview ¶
Package vision implements pdfsmart's optional vision-LLM fallback stage: transcribing a rendered PDF page image via a vision-capable LLM when neither native text extraction nor docling could produce usable text for it. See pdfsmart.VisionTranscriber for the interface this implements and pdfsmart.Convert's own doc comment for where this slots into the page-processing pipeline.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Model is the vision-capable model to send page images to.
Model types.ModelIdentifier
// Registry is consulted by IsAvailable to check whether Model actually
// supports image content blocks (see model.Registry.VisionCapable) -
// this is what gates the whole fallback behind "don't attempt this
// against a text-only model". Defaults to model.Global (populated at
// startup by internal/providers) when nil; tests can inject their own
// via model.NewRegistry(), per that package's own doc comment.
Registry *model.Registry
// Timeout is the per-page call deadline. Default: 60s.
Timeout time.Duration
}
Config controls Transcriber behavior. Zero-value fields are replaced with defaults by New, except Model, which must be set to a real, vision-capable model identifier for IsAvailable to ever report true.
type LLMCaller ¶
type LLMCaller interface {
CreateMessage(ctx context.Context, req types.APIRequest) (*types.APIResponse, error)
}
LLMCaller is the minimal interface for calling the provider API. *providers.Client satisfies this - defined here as an interface (not imported from internal/providers) so Transcriber can be tested without a live network call, and so internal/pdfsmart never has to depend on internal/providers. Mirrors internal/rag/enricher's and internal/memory/longterm's identically-shaped LLMCaller, for the same reason.
type Transcriber ¶
type Transcriber struct {
// contains filtered or unexported fields
}
Transcriber sends a rendered PDF page image to a vision-capable LLM and returns its transcription - see pdfsmart.VisionTranscriber for the interface this implements (duck-typed, no import needed - see that interface's own doc comment for why).
func New ¶
func New(caller LLMCaller, cfg Config) *Transcriber
New creates a Transcriber. caller is normally the same *providers.Client already used elsewhere for chat completions - see LLMCaller's doc comment for why that's an interface here, not the concrete type.
func (*Transcriber) IsAvailable ¶
func (t *Transcriber) IsAvailable(context.Context) bool
IsAvailable reports whether Model is actually configured as vision-capable - see Config.Registry. A nil caller or an empty Model also reports false.