From c963ecf84dd6b22214523ea3b1325df4e7a95ee7 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Wed, 28 May 2025 21:41:54 +0200 Subject: [PATCH] osm: Give LLM the distance sort method used. --- CHANGELOG.md | 4 ++++ osm.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f2875..cc93274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Initial release. # OpenStreetMap Tool +**2.2.2:** + - Inform model of distance sorting method used to attempt to improve + reasoning model performance. + **2.2.1:** - Round distances to 3 decimal places. diff --git a/osm.py b/osm.py index 1068611..2f81c23 100644 --- a/osm.py +++ b/osm.py @@ -2,7 +2,7 @@ title: OpenStreetMap Tool author: projectmoon author_url: https://git.agnos.is/projectmoon/open-webui-filters -version: 2.2.1 +version: 2.2.2 license: AGPL-3.0+ required_open_webui_version: 0.4.3 requirements: openrouteservice, pygments @@ -1128,8 +1128,12 @@ class OsmSearcher: things_nearby = sort_by_closeness(origin, things_nearby, 'distance') if self.attempt_ors(origin, things_nearby): + sort_method = "travel distance" things_nearby = sort_by_closeness(origin, things_nearby, 'nav_distance', 'distance') - return things_nearby + else: + sort_method = "haversine distance" + + return [things_nearby, sort_method] async def search_nearby( self, place: str, tags: List[str], limit: int=5, radius: int=4000, @@ -1174,7 +1178,7 @@ class OsmSearcher: } print(f"[OSM] Searching for {category} near {place_display_name}") - things_nearby = await self.get_things_nearby(nominatim_result, place, tags, + things_nearby, sort_method = await self.get_things_nearby(nominatim_result, place, tags, bbox, limit, radius) if not things_nearby or len(things_nearby) == 0: @@ -1187,7 +1191,7 @@ class OsmSearcher: # Only print the full result instructions if we # actually have something. - search_results = convert_and_validate_results(place, things_nearby) + search_results = convert_and_validate_results(place, things_nearby, sort_message=sort_method) if search_results: result_instructions = self.get_result_instructions(tag_type_str) else: