Skip to main content

Module utils

Module utils 

Source

Structs§

CheckResult
Check result with actionable error message
RetryConfig
Retry configuration
Tokenizer
Token counting utility using character-based estimation. Uses ~4 characters per token as a reasonable approximation.

Traits§

MutexExt
Extension trait for Mutex to provide safe lock operations

Functions§

check_ollama_available
Check if Ollama is running and responding
check_ollama_model
Check if a specific model is available in Ollama
drain_complete_lines
Drain all complete newline-terminated lines out of buf, decoding each as UTF-8 and dropping the trailing \n. Any partial trailing line stays in buf so the caller can append more bytes and try again.
drain_sse_events
Drain all complete SSE events out of buf, returning the payload of each data: field. The [DONE] sentinel and non-data: fields are filtered out. Each returned String is exactly one event’s data (multi-line data: fields are joined with \n, per the SSE spec).
format_duration
Format a duration in seconds as a human-readable string.
format_relative_timestamp
Format a timestamp as a relative, human-readable string
format_tokens
Format token count for display: “X.Xk” for >= 1000, raw number otherwise.
init_logger
Initialize the logging system with tracing
lock_arc_mutex_safe
Safe lock for Arc<Mutex> - standalone function since we can’t impl on Arc
log_debug
Log a debug message (backward compatible)
log_error
Log an error message with category prefix (backward compatible)
log_info
Log an info message with category prefix (backward compatible)
log_progress
Progress indicator for startup sequence
log_warn
Log a warning message with category prefix (backward compatible)
open_file
Open a file with the platform’s default application. Silently spawns the opener in the background (does not block).
resolve_api_key
Resolve an API key from the environment.
retry_async
Retry an async operation with exponential backoff
truncate_content
Truncate content to a maximum character count (char-boundary safe)
truncate_web_content
Truncate web content using the default limit