Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to QueryRouter++ are documented here.
- Unused `RouterTrainer` and query-taxonomy loader classes.

### Fixed
- **Data loading**: non-finite CSV values (`inf`, `-inf`, `1e999`) are treated as missing like `nan`, instead of turning every min-max normalized score into NaN.
- **OpenAI proxy**: tool-calling turns keep `tool_calls` / `tool_call_id`, standard OpenAI params (`stop`, `seed`, `tools`, `tool_choice`, `response_format`, penalties, `max_completion_tokens`...) are forwarded upstream, and an unreachable provider returns 502 instead of 500.
- `QueryRouter()` without `data_dir` now finds `data_models/`.
- docker-compose health check (curl is not in the slim image); MongoDB password is required and bound to localhost.
Expand Down
7 changes: 5 additions & 2 deletions src/queryrouter/data/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ class ModelProfile:


def _parse_float(value: str) -> float | None:
"""Parse a CSV cell as float, returning None for empty or N/A values.
"""Parse a CSV cell as float, returning None for empty, N/A or non-finite values.

``inf`` / ``-inf`` / ``1e999`` are rejected like ``nan``: a single infinite
value would turn every min-max normalized score into NaN.

Args:
value: Raw string from CSV cell.
Expand All @@ -69,7 +72,7 @@ def _parse_float(value: str) -> float | None:
return None
try:
result = float(value)
return result if not math.isnan(result) else None
return result if math.isfinite(result) else None
except ValueError:
return None

Expand Down
4 changes: 4 additions & 0 deletions tests/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def test_nan(self) -> None:
def test_invalid(self) -> None:
assert _parse_float("not_a_number") is None

@pytest.mark.parametrize("value", ["inf", "-inf", "Infinity", "1e999"])
def test_non_finite(self, value: str) -> None:
assert _parse_float(value) is None


class TestParseInt:
def test_valid(self) -> None:
Expand Down