TextContentBuilder Class

Definition

Scoped builder for a text content part within a message. Owns its full lifecycle: EmitAddedEmitDelta (0+) → EmitTextDoneEmitAnnotationAdded (0+) → EmitDone.

public class TextContentBuilder
type TextContentBuilder = class
Public Class TextContentBuilder
Inheritance
TextContentBuilder

Constructors

Name Description
TextContentBuilder()

Initializes a new instance of TextContentBuilder for mocking.

Properties

Name Description
Annotations

The annotations emitted via EmitAnnotationAdded(Annotation).

ContentIndex

The content index assigned to this text content part.

FinalText

The final text set by EmitTextDone(String). Null if not yet finalized.

Methods

Name Description
EmitAdded()

Produces a response.content_part.added event with an empty text content part.

EmitAnnotationAdded(Annotation)

Produces a response.output_text.annotation.added event with the given annotation. The annotation is also tracked so that EmitDone() can include it in the content_part.done event.

EmitDelta(String)

Produces a response.output_text.delta event with the given text chunk.

EmitDone()

Produces a response.content_part.done event, closing this content part. Must be called after EmitTextDone(String).

EmitTextDone(String)

Produces a response.output_text.done event with the final complete text. Call this after all deltas have been emitted. After this, you may call EmitAnnotationAdded(Annotation) and then EmitDone().

Applies to