Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow Float Utils

From Leeroopedia
Revision as of 11:21, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Infiniflow_Ragflow_Float_Utils.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Data_Processing, Utilities
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete tool for safe numeric conversion and percentage normalization provided by the RAGFlow common library.

Description

The float_utils module provides get_float for safe string-to-float conversion (returns negative infinity on failure) and normalize_overlapped_percent for clamping overlap percentages to a valid 0-90 range, handling both decimal (0.0-1.0) and percentage (0-100) input formats.

Usage

Import these utilities when parsing numeric values from user input or configuration that may contain invalid strings, or when normalizing overlap percentage parameters for chunking operations.

Code Reference

Source Location

Signature

def get_float(v) -> float:
    """Convert value to float, returns -inf on failure."""

def normalize_overlapped_percent(overlapped_percent) -> int:
    """Normalize percentage to 0-90 range, auto-detecting decimal vs percentage."""

Import

from common.float_utils import get_float, normalize_overlapped_percent

I/O Contract

Inputs

Name Type Required Description
v any Yes Value to convert to float
overlapped_percent float/int Yes Overlap percentage (0-1.0 or 0-100)

Outputs

Name Type Description
get_float() returns float Parsed float or -inf on failure
normalize_overlapped_percent() returns int Normalized percentage (0-90)

Usage Examples

from common.float_utils import get_float, normalize_overlapped_percent

score = get_float("0.85")    # 0.85
bad = get_float("not_a_num") # -inf

pct = normalize_overlapped_percent(0.15)  # 15
pct2 = normalize_overlapped_percent(95)   # 90 (clamped)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment