From ec078666aeb3a61a22d8a419c682f1b412553157 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 4 Sep 2024 00:50:57 -0700 Subject: [PATCH] saveSomeAPIcalls --- mesh_bot.py | 14 ++++++++++---- modules/settings.py | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 6937744..d108714 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -106,11 +106,17 @@ def handle_wiki(message): return "Please add a search term example:wiki: travelling gnome" def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel): - global llmRunCounter, llmTotalRuntime - - location = get_node_location(message_from_id, deviceID) + global llmRunCounter, llmTotalRuntime, llmLocationTable + if location_enabled: - location_name = where_am_i(str(location[0]), str(location[1]), short = True) + location = get_node_location(message_from_id, deviceID) + # if message_from_id is is the llmLocationTable use the location from the table to save on API calls + if message_from_id in llmLocationTable: + location = llmLocationTable[message_from_id] + else: + location_name = where_am_i(str(location[0]), str(location[1]), short = True) + llmLocationTable.append({message_from_id: location_name}) + if NO_DATA_NOGPS in location_name: location_name = "no location provided " else: diff --git a/modules/settings.py b/modules/settings.py index 6c6b3e8..46c5ea6 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -28,6 +28,7 @@ scheduler_enabled = False # enable the scheduler currently config via code only wiki_return_limit = 3 # limit the number of sentences returned off the first paragraph first hit llmRunCounter = 0 llmTotalRuntime = [] +llmLocationTable = [] # Read the config file, if it does not exist, create basic config file config = configparser.ConfigParser()