Skip to content

Bug: False-Positive Weather Query Triggered by Non-Location Keywords #11

Description

@suprch4rg3d

Description:

The current implementation of is_weather_query() relies solely on the presence of weather-related keywords (e.g., “flow”, “humidity”, “wind”) to decide whether a query is weather-related. As a result, non-weather queries that coincidentally include such keywords (e.g., “adjust flow in the copper ion system”) are incorrectly routed to the weather handler — even when no location is mentioned.

Steps to Reproduce

Use a query like:
How do I adjust the flow rate of the DEBCURON system?

The system falsely identifies this as a weather query due to the word "flow".

It proceeds to call handle_weather_query(), which then returns:

No locations found in your query.

Expected Behavior

Only queries that both (a) contain weather-related keywords and (b) mention at least one geographic location should be classified as weather queries.

Root Cause

The is_weather_query() function checks only for keyword count:

def is_weather_query(text: str) -> bool: threshold = int(os.getenv("WEATHER_KEYWORD_THRESHOLD", 2)) keyword_hits = [kw for kw in weather_keywords if kw in text.lower()] return len(keyword_hits) >= threshold

This leads to false positives when keywords are used in technical or domain-specific contexts unrelated to weather.

Proposed Solution

Update the handle_weather_trigger() function to perform an additional location check using HuggingFace NER before invoking the weather handler.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions