Compare commits

..

2 Commits

Author SHA1 Message Date
javis-bot
b4f8f71dd2 chore(app): version 0.1.29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:08:15 +09:00
javis-bot
9ba26c5bac feat(weather): districts such as 부산 연제구 found on OpenStreetMap
open-meteo's geocoder knows cities only, in Latin spellings, and matches a
non-Latin name loosely: "부산" gave a village called Pusan 140 km from
Busan. A non-Latin name now goes to OpenStreetMap's Nominatim first (any
language, down to districts), and a Latin name open-meteo does not know
goes there before the LLM romanisation and the wider-area retries. The
answer names the place in the user's own words, and KMA gets that spot's
grid point. Eval: evals/test_weather_district_place.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:08:15 +09:00
9 changed files with 193 additions and 23 deletions

View File

@@ -36,7 +36,7 @@
- 원하면 게임 중에는 봇을 일시정지할 수 있습니다. - 원하면 게임 중에는 봇을 일시정지할 수 있습니다.
- **안티치트 보호**: 뱅가드 같은 안티치트가 걸린 게임이 실행 중이면 키보드·마우스 자동 조작을 막고 그 이유를 알려 줍니다. - **안티치트 보호**: 뱅가드 같은 안티치트가 걸린 게임이 실행 중이면 키보드·마우스 자동 조작을 막고 그 이유를 알려 줍니다.
- **기존 기능 유지**: 메모리, 날씨, 웹 검색, 식단 기록, MCP, 브라우저 제어를 그대로 가져갑니다. - **기존 기능 유지**: 메모리, 날씨, 웹 검색, 식단 기록, MCP, 브라우저 제어를 그대로 가져갑니다.
- **기상청 날씨**: 관리 앱 "기능" 화면에 기상청 API허브 인증키를 넣으면 한국 안의 현재 날씨와 10일 뒤까지의 예보("내일 날씨", "주말 날씨")를 기상청에서 받습니다(초단기실황조회, 초단기예보조회, 단기예보조회, 중기기온조회, 중기육상예보조회 활용신청 필요). 키가 없거나 한국 밖이면 open-meteo에서 받고, 현재 날씨는 그다음 met.no에서 받습니다. - **기상청 날씨**: 관리 앱 "기능" 화면에 기상청 API허브 인증키를 넣으면 한국 안의 현재 날씨와 10일 뒤까지의 예보("내일 날씨", "주말 날씨")를 기상청에서 받습니다. "부산 연제구"처럼 구 단위로 물으면 그 구의 날씨를 답합니다(장소는 OpenStreetMap에서 찾습니다)(초단기실황조회, 초단기예보조회, 단기예보조회, 중기기온조회, 중기육상예보조회 활용신청 필요). 키가 없거나 한국 밖이면 open-meteo에서 받고, 현재 날씨는 그다음 met.no에서 받습니다.
- **관리 앱**: - **관리 앱**:
- 첫 실행 마법사, 대시보드, 모델 다운로드, 기능별 켜기/끄기를 제공합니다. - 첫 실행 마법사, 대시보드, 모델 다운로드, 기능별 켜기/끄기를 제공합니다.
- 로그 화면에서 로그를 보고, 복사하고, 내려받을 수 있습니다. 비밀값은 자동으로 가립니다. - 로그 화면에서 로그를 보고, 복사하고, 내려받을 수 있습니다. 비밀값은 자동으로 가립니다.

2
app/Cargo.lock generated
View File

@@ -1520,7 +1520,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]] [[package]]
name = "jarvis-app" name = "jarvis-app"
version = "0.1.28" version = "0.1.29"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"base64 0.22.1", "base64 0.22.1",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "jarvis-app" name = "jarvis-app"
version = "0.1.28" version = "0.1.29"
edition = "2021" edition = "2021"
rust-version = "1.85" rust-version = "1.85"
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels" description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"

4
app/shell/Cargo.lock generated
View File

@@ -2637,7 +2637,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]] [[package]]
name = "jarvis-app" name = "jarvis-app"
version = "0.1.28" version = "0.1.29"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"base64 0.22.1", "base64 0.22.1",
@@ -2666,7 +2666,7 @@ dependencies = [
[[package]] [[package]]
name = "jarvis-shell" name = "jarvis-shell"
version = "0.1.28" version = "0.1.29"
dependencies = [ dependencies = [
"jarvis-app", "jarvis-app",
"serde_json", "serde_json",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "jarvis-shell" name = "jarvis-shell"
version = "0.1.28" version = "0.1.29"
edition = "2021" edition = "2021"
rust-version = "1.85" rust-version = "1.85"
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)" description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"

View File

@@ -0,0 +1,25 @@
"""
Eval: a district the user names reaches getWeather whole ("부산 연제구"), not only its city.
getWeather finds districts on OpenStreetMap (2026-11-18), so the place argument must keep
the district for the answer to be about that spot.
Run: EVAL_JUDGE_MODEL=qwen3:8b ./scripts/run_evals.sh weather_district_place
"""
import pytest
from conftest import requires_judge_llm
from test_weather_forecast_days import _ask
@pytest.mark.eval
@requires_judge_llm
@pytest.mark.parametrize("query,district", [
("부산 연제구 날씨 어때?", "연제"),
("서울 강남구 내일 날씨 알려 줘", "강남"),
])
def test_the_district_is_in_the_place(mock_config, eval_db, eval_dialogue_memory, query, district):
args = _ask(mock_config, eval_db, eval_dialogue_memory, query)
assert args is not None, "getWeather was not called"
assert district in (args.get("location") or ""), args

View File

@@ -207,6 +207,28 @@ _MET_NO_URL = "https://api.met.no/weatherapi/locationforecast/2.0/compact"
_MET_NO_HEADERS = {"User-Agent": "jarvis-voice-assistant/2 github.com/isair/jarvis"} _MET_NO_HEADERS = {"User-Agent": "jarvis-voice-assistant/2 github.com/isair/jarvis"}
# OpenStreetMap's place search: any language, down to districts (부산 연제구), which open-meteo's
# geocoder (cities, Latin spellings) does not know. Its policy asks for an identifying User-Agent.
_NOMINATIM_URL = "https://nominatim.openstreetmap.org/search"
def _osm_place(name: str) -> Optional[Dict[str, Any]]:
"""The place OpenStreetMap finds for a name: {'lat', 'lon', 'country_code'}; None if none or on failure."""
try:
resp = requests.get(_NOMINATIM_URL, headers=_MET_NO_HEADERS, timeout=_OPEN_METEO_TIMEOUT_SEC,
params={"q": name, "format": "jsonv2", "limit": 1, "addressdetails": 1})
resp.raise_for_status()
found = resp.json()
if not isinstance(found, list) or not found:
return None
place = found[0]
code = ((place.get("address") or {}).get("country_code") or "").upper() or None
return {"lat": float(place["lat"]), "lon": float(place["lon"]), "country_code": code}
except Exception as e:
debug_log(f" ⚠️ OpenStreetMap place search failed ({type(e).__name__})", "tools")
return None
def _met_no_wmo(symbol: str) -> Optional[int]: def _met_no_wmo(symbol: str) -> Optional[int]:
"""The WMO code closest to a met.no symbol code ('lightrainshowers_night' -> 80).""" """The WMO code closest to a met.no symbol code ('lightrainshowers_night' -> 80)."""
s = (symbol or "").split("_")[0] s = (symbol or "").split("_")[0]
@@ -708,13 +730,24 @@ class WeatherTool(Tool):
"format": "json" "format": "json"
} }
geo_response = requests.get(geocode_url, params=geocode_params, timeout=10) # Open-Meteo knows cities only, in Latin spellings, and matches a
geo_response.raise_for_status() # non-Latin name loosely (live 2026-11-18: "부산" gave a village
geo_data = geo_response.json() # called Pusan 140 km away). A non-Latin name, and a Latin one
# open-meteo does not know (a district), is looked up on
# OpenStreetMap in the words the user used.
geo_data: Dict[str, Any] = {}
if location_str.isascii():
geo_response = requests.get(geocode_url, params=geocode_params, timeout=10)
geo_response.raise_for_status()
geo_data = geo_response.json()
osm = None if geo_data.get("results") else _osm_place(location_str)
if osm:
debug_log(" 📍 found on OpenStreetMap", "tools")
geo_data = {"results": [{"latitude": osm["lat"], "longitude": osm["lon"],
"name": location_str, "country_code": osm["country_code"]}]}
# Open-Meteo only matches Latin spellings, so a non-Latin name # Not on OpenStreetMap either (or it failed): retry open-meteo
# (e.g. Korean "서울") returns nothing. Retry once with an # once with an LLM-romanised name before giving up.
# LLM-romanised name before giving up.
if not geo_data.get("results"): if not geo_data.get("results"):
romanised = _romanise_place(location_str, getattr(context, "cfg", None)) romanised = _romanise_place(location_str, getattr(context, "cfg", None))
if romanised: if romanised:

View File

@@ -297,7 +297,10 @@ which carry Discord's own time.
rain), then 중기예보 for the nearest of the KMA cities in `weather.py` and its region (중기기온, rain), then 중기예보 for the nearest of the KMA cities in `weather.py` and its region (중기기온,
중기육상). Days KMA does not give, and every KMA failure, come from open-meteo (now: then 중기육상). Days KMA does not give, and every KMA failure, come from open-meteo (now: then
met.no; later days: open-meteo's daily forecast only). The key is in KMA's URLs, so a failure is met.no; later days: open-meteo's daily forecast only). The key is in KMA's URLs, so a failure is
logged by its kind only. logged by its kind only. The place is found by open-meteo's geocoder (cities, Latin spellings)
or OpenStreetMap's Nominatim (any language, down to districts such as 부산 연제구; a non-Latin
name goes there first, since open-meteo matches it loosely); only the place name is sent, with
the app's User-Agent, and the answer names the place in the user's own words.
- `prepare` tells the brain that `user` is saying a call whose partial transcript is `text` (the app - `prepare` tells the brain that `user` is saying a call whose partial transcript is `text` (the app
sends it while the speaker is still talking, `app/src/conversation.spec.md`). The brain runs the sends it while the speaker is still talking, `app/src/conversation.spec.md`). The brain runs the
intent judge's tool pick for it on its own thread, with the asker's dialogue memory and the tool intent judge's tool pick for it on its own thread, with the asker's dialogue memory and the tool

View File

@@ -107,16 +107,13 @@ class TestWeatherTool:
def test_run_non_latin_location_romanises_and_retries(self, mock_get, mock_romanise): def test_run_non_latin_location_romanises_and_retries(self, mock_get, mock_romanise):
"""A Korean city name Open-Meteo can't geocode is romanised and retried. """A Korean city name Open-Meteo can't geocode is romanised and retried.
Open-Meteo's geocoder only matches Latin spellings, so ``서울`` returns Open-Meteo's geocoder only matches Latin spellings, so ``서울`` is first
no results. The tool must romanise to ``Seoul`` and retry rather than looked up on OpenStreetMap (any language). When that finds nothing,
the tool must romanise to ``Seoul`` and retry rather than
dead-ending with "could not find location" (the failure the Korean- dead-ending with "could not find location" (the failure the Korean-
locked deployment hit on every weather request).""" locked deployment hit on every weather request)."""
mock_romanise.return_value = "Seoul" mock_romanise.return_value = "Seoul"
geo_empty = Mock()
geo_empty.raise_for_status = Mock()
geo_empty.json.return_value = {} # no "results"
geo_seoul = Mock() geo_seoul = Mock()
geo_seoul.raise_for_status = Mock() geo_seoul.raise_for_status = Mock()
geo_seoul.json.return_value = { geo_seoul.json.return_value = {
@@ -154,14 +151,16 @@ class TestWeatherTool:
}, },
} }
mock_get.side_effect = [geo_empty, geo_seoul, weather_response] osm_empty = Mock(raise_for_status=Mock())
osm_empty.json.return_value = []
mock_get.side_effect = [osm_empty, geo_seoul, weather_response]
result = self.tool.run({"location": "서울"}, self.context) result = self.tool.run({"location": "서울"}, self.context)
assert result.success is True assert result.success is True
assert "Seoul" in result.reply_text assert "Seoul" in result.reply_text
mock_romanise.assert_called_once() mock_romanise.assert_called_once()
# The romanised name must be what the second geocode actually queried. # The romanised name must be what the geocode actually queried.
assert mock_get.call_args_list[1].kwargs["params"]["name"] == "Seoul" assert mock_get.call_args_list[1].kwargs["params"]["name"] == "Seoul"
@patch('requests.get') @patch('requests.get')
@@ -427,7 +426,7 @@ class TestWeatherTool:
return met return met
mock_get.side_effect = get mock_get.side_effect = get
result = self.tool.run({"location": "서울"}, self.context) result = self.tool.run({"location": "Seoul"}, self.context)
assert result.success is True assert result.success is True
assert "서울" in result.reply_text assert "서울" in result.reply_text
@@ -454,7 +453,7 @@ class TestWeatherTool:
raise requests.exceptions.Timeout("timed out") raise requests.exceptions.Timeout("timed out")
mock_get.side_effect = get mock_get.side_effect = get
result = self.tool.run({"location": "서울"}, self.context) result = self.tool.run({"location": "Seoul"}, self.context)
assert result.success is False assert result.success is False
assert "unavailable" in result.reply_text.lower() assert "unavailable" in result.reply_text.lower()
@@ -1042,3 +1041,113 @@ class TestForecast:
result = self.tool.run({"location": "X", "days_ahead": 2}, self.context) result = self.tool.run({"location": "X", "days_ahead": 2}, self.context)
assert result.success is False and "forecast" in result.reply_text.lower() assert result.success is False and "forecast" in result.reply_text.lower()
class TestDistrictPlaces:
"""A district such as 부산 연제구 is found by OpenStreetMap's search (any language) when
open-meteo's geocoder, which knows cities only, does not find it; the weather is for that spot."""
KEY = "kma-test-key-123"
def setup_method(self):
self.tool = WeatherTool()
self.context = Mock(spec=ToolContext)
self.context.user_print = Mock()
self.context.cfg = Mock()
self.context.cfg.location_name = None
self.context.redacted_text = ""
@staticmethod
def _ok(payload):
r = Mock(status_code=200, raise_for_status=Mock())
r.json.return_value = payload
return r
def _routes(self, calls, osm=None, osm_fails=False):
def get(url, *a, **k):
params = k.get("params") or {}
calls.append((url, params, k.get("headers") or {}))
if "geocoding-api.open-meteo.com" in url:
return self._ok({})
if "nominatim.openstreetmap.org" in url:
if osm_fails:
raise requests.exceptions.Timeout("timed out")
return self._ok(osm if osm is not None else [{
"lat": "35.1762", "lon": "129.0797", "name": "연제구", "addresstype": "borough",
"address": {"borough": "연제구", "city": "부산광역시", "country_code": "kr"}}])
if "getUltraSrtNcst" in url:
return self._ok({"response": {"header": {"resultCode": "00"}, "body": {"items": {"item": [
{"category": c, "obsrValue": v} for c, v in
[("PTY", "0"), ("REH", "60"), ("T1H", "8.2"), ("WSD", "3.1")]]}}}})
if "getUltraSrtFcst" in url:
return self._ok({"response": {"header": {"resultCode": "00"}, "body": {"items": {"item": [
{"category": "SKY", "fcstDate": "20261118", "fcstTime": "1200", "fcstValue": "1"}]}}}})
assert "api.open-meteo.com/v1/forecast" in url, url
return self._ok({"current": {"temperature_2m": 11.0, "weather_code": 0}})
return get
@patch('src.jarvis.tools.builtin.weather._romanise_place')
def test_a_district_gets_its_own_spots_weather_from_kma(self, mock_romanise, monkeypatch):
from src.jarvis.tools.builtin.weather import _kma_grid
monkeypatch.setenv("JARVIS_KMA_API_KEY", self.KEY)
calls = []
with patch('requests.get', side_effect=self._routes(calls)):
result = self.tool.run({"location": "부산 연제구"}, self.context)
assert result.success is True
assert result.reply_text.startswith("지금 부산 연제구 날씨는 맑음") and "기온 8도" in result.reply_text
kma = [p for u, p, _ in calls if "apihub.kma.go.kr" in u]
assert kma and all((p["nx"], p["ny"]) == _kma_grid(35.1762, 129.0797) for p in kma)
mock_romanise.assert_not_called()
def test_the_place_search_asks_for_one_place_with_its_country_and_names_the_app(self, monkeypatch):
monkeypatch.delenv("JARVIS_KMA_API_KEY", raising=False)
calls = []
with patch('requests.get', side_effect=self._routes(calls)):
self.tool.run({"location": "부산 연제구"}, self.context)
((_, params, headers),) = [c for c in calls if "nominatim.openstreetmap.org" in c[0]]
assert params["q"] == "부산 연제구" and params["limit"] == 1 and params["addressdetails"] == 1
assert "jarvis" in headers.get("User-Agent", "").lower()
@pytest.mark.parametrize("osm,osm_fails", [([], False), (None, True), ({"error": "x"}, False)])
@patch('src.jarvis.tools.builtin.weather._romanise_place', return_value=None)
def test_when_the_place_search_finds_nothing_or_fails_the_place_is_not_found(
self, _rom, osm, osm_fails, monkeypatch):
monkeypatch.delenv("JARVIS_KMA_API_KEY", raising=False)
calls = []
with patch('requests.get', side_effect=self._routes(calls, osm=osm, osm_fails=osm_fails)):
result = self.tool.run({"location": "없는 동네"}, self.context)
assert result.success is False and "could not find" in result.reply_text.lower()
@patch('src.jarvis.tools.builtin.weather._romanise_place')
def test_a_non_latin_city_name_is_not_matched_loosely_by_open_meteo(self, mock_romanise, monkeypatch):
"""Live 2026-11-18: open-meteo matched "부산" to a village called Pusan 140 km from Busan."""
monkeypatch.delenv("JARVIS_KMA_API_KEY", raising=False)
calls = []
osm = [{"lat": "35.1799", "lon": "129.0752", "name": "부산광역시", "address": {"country_code": "kr"}}]
with patch('requests.get', side_effect=self._routes(calls, osm=osm)):
result = self.tool.run({"location": "부산"}, self.context)
assert result.reply_text.startswith("지금 부산 날씨는")
assert not any("geocoding-api.open-meteo.com" in u for u, _, _ in calls)
(_, p, _), = [c for c in calls if "api.open-meteo.com/v1/forecast" in c[0]]
assert (p["latitude"], p["longitude"]) == (35.1799, 129.0752)
mock_romanise.assert_not_called()
def test_a_latin_name_open_meteo_knows_does_not_ask_openstreetmap(self, monkeypatch):
monkeypatch.delenv("JARVIS_KMA_API_KEY", raising=False)
calls = []
base = self._routes(calls)
def get(url, *a, **k):
if "geocoding-api.open-meteo.com" in url:
calls.append((url, k.get("params"), {}))
return self._ok({"results": [{"latitude": 51.5, "longitude": -0.12, "name": "London",
"country_code": "GB"}]})
return base(url, *a, **k)
with patch('requests.get', side_effect=get):
result = self.tool.run({"location": "London"}, self.context)
assert result.success and not any("nominatim" in u for u, _, _ in calls)