docling

package
v1.2.13 Latest Latest
Warning

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

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

Documentation

Overview

Package docling groups the explicit, agent-invocable tools built on docling-serve: read_document_url (fetch+convert a remote document) and docling_convert (convert a local file that native extraction can't handle well - scanned PDFs, complex slide decks, audio). Both are opt-in: the agent reaches for them deliberately, as opposed to internal/tools/files/read's own docling fallback, which stays in place so a scanned PDF or audio file still "just works" through plain FileRead without the agent needing to know docling exists.

Index

Constants

View Source
const (
	// ConvertToolName is the name of the docling_convert tool.
	ConvertToolName = "docling_convert"

	// ConvertDisplayName is the display name of the docling_convert tool.
	ConvertDisplayName = "Docling Convert"

	// ConvertSearchHint is a hint for tool search functionality.
	ConvertSearchHint = "OCR a scanned PDF, extract a complex slide deck, or transcribe audio via docling"

	// ConvertDescription is the description of the docling_convert tool.
	ConvertDescription = "Convert a local file to markdown using docling-serve: OCR, layout analysis, table structure, and audio transcription.\n\n" +
		"## When to use\n\n" +
		"- A scanned/image-only PDF that FileRead reports as having little or no extractable text\n" +
		"- A PPTX slide deck — most slide decks are mostly visual (screenshots, diagrams, charts) with only a title or two of real text, so FileRead's native extraction routinely \"succeeds\" while missing almost everything that actually matters. FileRead already auto-falls-back to docling for a PPTX whose extracted text is sparse relative to its slide count, but if you're unsure or FileRead returned something that looks thin, don't hesitate to call this directly rather than trying to work around it with other tools (terminal, ad-hoc scripts, per-slide image extraction, etc.) — none of that gets better OCR than docling does in one shot\n" +
		"- Audio files (WAV, MP3) that need transcription\n" +
		"- A DOCX/PPTX/XLSX that FileRead's native extraction failed on\n\n" +
		"## When NOT to use\n\n" +
		"- Plain text-native PDFs, or text-heavy DOCX/XLSX — use FileRead instead, it extracts them natively without the network round-trip to docling-serve\n" +
		"- FileRead already tries docling automatically as a last resort for unreadable or sparse files, so you usually don't need this tool for a first read. Reach for it when you want deliberate control: forcing a reconversion, or converting a file FileRead didn't route to docling.\n\n" +
		"## Rules\n\n" +
		"- Requires docling-serve to be configured (DOCLING_URL).\n" +
		"- Pass the whole file in one call (`path` is the deck/document itself, e.g. \"deck.pptx\") — docling-serve converts every slide/page in a single request. Never split a deck into individual slide images and OCR them one at a time: it's slower, it's more tool calls, and it throws away the layout/reading-order/table-structure analysis docling does for a whole document at once.\n"
)
View Source
const (
	// ReadURLToolName is the name of the read_document_url tool.
	ReadURLToolName = "read_document_url"

	// ReadURLDisplayName is the display name of the read_document_url tool.
	ReadURLDisplayName = "Read Document URL"

	// ReadURLSearchHint is a hint for tool search functionality.
	ReadURLSearchHint = "fetch and convert a remote document or web page to markdown"

	// ReadURLDescription is the description of the read_document_url tool.
	ReadURLDescription = "Fetch a document at a URL and convert it to readable markdown. " +
		"Supports PDF, DOCX, PPTX, XLSX, HTML pages, and arXiv papers. " +
		"Requires docling-serve to be configured. " +
		"Optionally saves the extracted markdown to a workspace path."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DoclingURL is the base URL of a running docling-serve instance.
	// When empty, tools register but always report "not configured".
	DoclingURL string
}

Config holds the shared configuration for every tool in this package.

type ConvertTool

type ConvertTool struct {
	// contains filtered or unexported fields
}

ConvertTool converts a local file to markdown via docling-serve.

func NewConvertTool

func NewConvertTool(cfg Config, workingDir string) *ConvertTool

NewConvertTool creates a new docling_convert tool.

func (*ConvertTool) BackfillInput

func (t *ConvertTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*ConvertTool) Call

func (t *ConvertTool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

func (*ConvertTool) CheckPermissions

func (t *ConvertTool) CheckPermissions(_ context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult

func (*ConvertTool) Definition

func (t *ConvertTool) Definition() tool.Definition

func (*ConvertTool) Description

func (t *ConvertTool) Description(_ context.Context) (string, error)

func (*ConvertTool) FormatResult

func (t *ConvertTool) FormatResult(data any) string

func (*ConvertTool) IsConcurrencySafe

func (t *ConvertTool) IsConcurrencySafe(_ map[string]any) bool

func (*ConvertTool) IsEnabled

func (t *ConvertTool) IsEnabled() bool

func (*ConvertTool) IsReadOnly

func (t *ConvertTool) IsReadOnly(_ map[string]any) bool

func (*ConvertTool) ValidateInput

func (t *ConvertTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type ReadURLTool

type ReadURLTool struct {
	// contains filtered or unexported fields
}

ReadURLTool fetches a remote document and converts it to markdown via docling-serve.

func NewReadURLTool

func NewReadURLTool(cfg Config) *ReadURLTool

NewReadURLTool creates a new read_document_url tool.

func (*ReadURLTool) BackfillInput

func (t *ReadURLTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*ReadURLTool) Call

func (t *ReadURLTool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

func (*ReadURLTool) CheckPermissions

func (t *ReadURLTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*ReadURLTool) Definition

func (t *ReadURLTool) Definition() tool.Definition

func (*ReadURLTool) Description

func (t *ReadURLTool) Description(_ context.Context) (string, error)

func (*ReadURLTool) FormatResult

func (t *ReadURLTool) FormatResult(data any) string

func (*ReadURLTool) IsConcurrencySafe

func (t *ReadURLTool) IsConcurrencySafe(_ map[string]any) bool

func (*ReadURLTool) IsEnabled

func (t *ReadURLTool) IsEnabled() bool

func (*ReadURLTool) IsReadOnly

func (t *ReadURLTool) IsReadOnly(_ map[string]any) bool

func (*ReadURLTool) ValidateInput

func (t *ReadURLTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

Jump to

Keyboard shortcuts

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