ReasoningUtils class

Utilities for handling reasoning/thinking content

Constructors

ReasoningUtils()

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

checkReasoningStatus({required Map<String, dynamic>? delta, required bool hasReasoningContent, required String lastChunk}) → ReasoningDetectionResult
Check if reasoning just finished based on delta content This matches the TypeScript isReasoningJustDone function
containsThinkingTags(String content) → bool
Check if content contains thinking tags
extractContentWithoutThinking(String content) → String
Extract content without thinking tags
extractReasoningContent(Map<String, dynamic>? delta) → String?
Extract reasoning content from delta
filterThinkingContent(String content) → String
Filter thinking content from text for display purposes Removes <think>...</think> tags and their content
getMaxTokensParams({required String model, int? maxTokens}) → Map<String, dynamic>
Get appropriate max tokens parameter for reasoning models
getReasoningEffortParams({required String providerId, required String model, ReasoningEffort? reasoningEffort, int? maxTokens}) → Map<String, dynamic>
Get reasoning effort parameter for different providers
hasReasoningContent(Map<String, dynamic>? delta) → bool
Check if delta contains reasoning content
isKnownReasoningModel(String model) → bool
Check if the model is known to support reasoning (broader check) This is a hint for UI behavior, but actual reasoning detection should be based on response content, not model name
isOpenAIReasoningModel(String model) → bool
Check if the model is an OpenAI reasoning model
parseReasoningMetrics({required DateTime startTime, DateTime? firstTokenTime, DateTime? firstContentTime, int? completionTokens}) → Map<String, dynamic>
Parse reasoning metrics from response
shouldDisableTemperature(String model) → bool
Check if temperature should be disabled for reasoning models
shouldDisableTopP(String model) → bool
Check if top_p should be disabled for reasoning models