SdkTextExtractor class

Pure-Dart extractor for LiteRT-LM SDK JSON response chunks.

Lives in core, not in flutter_edge_ai_litertlm's native lib/src/ffi/, so the web @litert-lm/core path can reuse the exact same text-extraction logic that the native FFI path uses — both inputs are the same OpenAI Chat Completions chunk JSON shape produced by liblitert_lm and @litert-lm/core respectively.

Handles two response formats:

  • Text: {"role":"assistant","content":[{"type":"text","text":"hello"}]} → returns "hello"
  • Thinking: {"role":"assistant","channels":{"thought":"reasoning..."}} → returns <|channel>thought\nreasoning...<channel|> (compatible with ThinkingFilter in core/extensions.dart)

Constructors

SdkTextExtractor()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

extractTextFromResponse(String jsonStr) → String
Extract text from a LiteRT-LM JSON response chunk.