Discover Packages
github.com/Voxray-AI/Voxray
pkg
utils
package
Version:
v0.2.0
Opens a new window with list of versions in this module.
Published: May 16, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Utils
Package utils provides shared utilities: backoff, notifier, sentence-boundary detection, and text/pattern aggregation for LLM streams.
Purpose
backoff : Exponential backoff for retries/reconnection (e.g. WebSocket).
notifier : One-shot signal: one goroutine waits, another notifies (Wait/Notify).
sentence : Sentence-end detection (e.g. .!?) for aggregating text.
patternaggregator : Delimiter-based aggregation (e.g. ` … `) to extract tagged content from LLM output (IVR, DTMF).
textaggregator : Interface and implementations to aggregate incremental text (e.g. LLM tokens) into segments (e.g. sentences).
Utility tree
graph TD
Root["utils"] --> Backoff["backoff\nExponentialBackoff\nBackoffCap"]
Root --> Notifier["notifier\nNotifier\nWait / Notify"]
Root --> Sentence["sentence\nMatchEndOfSentence\nDefaultSentenceEnd"]
Root --> PatternAgg["patternaggregator\nAggregator\nFeed / Flush\nMatch"]
Root --> TextAgg["textaggregator\nAggregator interface\nSegment\nsentence impl"]
Exported symbols (root)
Symbol
Type
Description
BackoffCap
const
Max duration (60s) for ExponentialBackoff
ExponentialBackoff(attempt)
func
Returns 2^attempt seconds, capped at BackoffCap; attempt 1-based
Subpackages
Path
Exported symbols
Description
notifier
Notifier, New, Notify, Wait
One waiter unblocked per Notify; safe for concurrent use
sentence
DefaultSentenceEnd, MatchEndOfSentence(s, endChars)
Reports if trimmed s ends with sentence-ending rune
patternaggregator
Match, Aggregator, New(open, close), Feed, Flush
Emits text segments and delimiter matches from stream
textaggregator
Segment, Aggregator (interface: Aggregate, Flush, Reset, HandleInterruption)
Aggregate incremental text into segments; sentence implementation
Concurrency
backoff : Stateless; safe for concurrent use.
notifier : Notify and Wait are safe for concurrent use; mutex protects the channel.
sentence : Stateless; safe for concurrent use.
patternaggregator : Aggregator is not safe for concurrent use; one caller should Feed/Flush.
textaggregator : Implementations are typically single-threaded per aggregator instance.
Files
File
Description
backoff.go
BackoffCap, ExponentialBackoff
notifier/notifier.go
Notifier, New, Notify, Wait
sentence/sentence.go
DefaultSentenceEnd, MatchEndOfSentence
patternaggregator/patternaggregator.go
Match, Aggregator, New, Feed, Flush
textaggregator/textaggregator.go
Segment, Aggregator interface
textaggregator/sentence.go
Sentence-based aggregator implementation
See also
Expand ▾
Collapse ▴
Documentation
¶
Package utils provides shared utilities (backoff, etc.).
ExponentialBackoff returns a duration for the given attempt (1-based).
Duration is 2^attempt seconds, capped at BackoffCap.
Used for reconnection backoff in websocket and other retry logic.
Source Files
¶
Directories
¶
Package notifier provides a simple signal that one goroutine can wait on and another can trigger.
Package notifier provides a simple signal that one goroutine can wait on and another can trigger.
Package patternaggregator provides XML-style tag aggregation for LLM text streams.
Package patternaggregator provides XML-style tag aggregation for LLM text streams.
Package sentence provides helpers for sentence-boundary detection in aggregated text.
Package sentence provides helpers for sentence-boundary detection in aggregated text.
Package textaggregator provides an interface and implementations for aggregating incremental text (e.g.
Package textaggregator provides an interface and implementations for aggregating incremental text (e.g.
Click to show internal directories.
Click to hide internal directories.