Table of Contents

Class StreamingContentParser

Namespace
JD.AI.Core.Agents
Assembly
JD.AI.Core.dll

Parses streaming LLM output to detect and separate thinking content from response content. Handles <think>...</think> tags that may span chunk boundaries (used by Qwen, DeepSeek, and similar models).

public sealed class StreamingContentParser
Inheritance
StreamingContentParser
Inherited Members

Properties

IsThinking

Whether the parser is currently inside a thinking block.

public bool IsThinking { get; }

Property Value

bool

Methods

Flush()

Flush any buffered content (e.g., an incomplete tag at end of stream).

public IReadOnlyList<StreamSegment> Flush()

Returns

IReadOnlyList<StreamSegment>

ProcessChunk(string)

Process a streaming chunk and return classified segments. The returned list is reused across calls — consume before the next call.

public IReadOnlyList<StreamSegment> ProcessChunk(string chunk)

Parameters

chunk string

Returns

IReadOnlyList<StreamSegment>

Reset()

Reset to initial state.

public void Reset()