Language

LlmInputHelper.ToLlmInput Method

Definition

Converts a Content Understanding analysis result into LLM-friendly text.

Produces a YAML front matter block followed by markdown body, suitable for injecting into an LLM prompt, storing in a vector database, or passing as tool output.

The YAML front matter (delimited by ---) may include: mimeType (detected content MIME type), customMetadata (caller-supplied key-value pairs from customMetadata), metadata (analysis-result metadata from Metadata), pages (page range), timeRange (media time span), category (classification label), fields (extracted structured fields as YAML), and warnings (content safety flags).

The markdown body contains the extracted text with page-break markers (<!-- InputPageNumber: N -->) inserted at page boundaries so downstream consumers can locate content by page number. N is the original 1-based page number from the source document (i.e., the page index in the analyzed PDF), not a counter that restarts at 1 for each call. This matters when the analyze request specifies a ContentRange (e.g., "2-3,5"): the markers in the output will read InputPageNumber: 2, 3, 5 β€” not 1, 2, 3. Downstream consumers (RAG indexers, page-citation prompts) can rely on the marker value to cite the correct source page even when only a subset of pages was analyzed. If the service markdown already contains <!-- InputPageNumber: markers, the helper passes the markdown through unchanged to avoid duplicate markers.

Internal telemetry messages such as LLMStats: ... are filtered from the rendered warnings front matter.

public static string ToLlmInput(this Azure.AI.ContentUnderstanding.AnalysisResult result, System.Collections.Generic.IDictionary<string,object>? customMetadata = default, Azure.AI.ContentUnderstanding.LlmInputOptions? options = default);
static member ToLlmInput : Azure.AI.ContentUnderstanding.AnalysisResult * System.Collections.Generic.IDictionary<string, obj> * Azure.AI.ContentUnderstanding.LlmInputOptions -> string
<Extension()>
Public Function ToLlmInput (result As AnalysisResult, Optional customMetadata As IDictionary(Of String, Object) = Nothing, Optional options As LlmInputOptions = Nothing) As String

Parameters

result
AnalysisResult

The AnalysisResult from a Content Understanding analyze operation.

customMetadata
IDictionary<String,Object>

Optional caller-supplied key-value pairs emitted under a nested customMetadata YAML front-matter block (kept separate from service Metadata / metadata). Common keys include source, documentId, or department.

options
LlmInputOptions

Optional rendering options controlling field/markdown inclusion.

Returns

A formatted text string with YAML front matter followed by markdown content.

Exceptions

metadata contains a reserved front matter key.

result is null.

Applies to