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()