From c1c68d4c101dc536ae21d158b4f8f94290ccac66 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 21 Jan 2025 20:02:58 -0800 Subject: [PATCH 1/5] Update mesh_bot.py --- mesh_bot.py | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 3bad7df..bf05804 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -368,17 +368,16 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel # consider this a command use for the cmdHistory list cmdHistory.append({'nodeID': message_from_id, 'cmd': 'llm-use', 'time': time.time()}) - # if the message_from_id is not in the llmLocationTable send the welcome message - for i in range(0, len(llmLocationTable)): - if not any(d['nodeID'] == message_from_id for d in llmLocationTable): - if (channel_number == publicChannel and antiSpam) or useDMForResponse: - # send via DM - send_message(welcome_message, channel_number, message_from_id, deviceID) - time.sleep(responseDelay) - else: - # send via channel - send_message(welcome_message, channel_number, 0, deviceID) - time.sleep(responseDelay) + # check for a welcome message (is this redundant?) + if not any(node['nodeID'] == message_from_id and node['welcome'] == True for node in seenNodes): + if (channel_number == publicChannel and antiSpam) or useDMForResponse: + # send via DM + send_message(welcome_message, channel_number, message_from_id, deviceID) + time.sleep(responseDelay) + else: + # send via channel + send_message(welcome_message, channel_number, 0, deviceID) + time.sleep(responseDelay) # update the llmLocationTable for future use for i in range(0, len(llmLocationTable)): @@ -397,26 +396,18 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel # information for the user on how long the query will take on average if llmRunCounter > 0: averageRuntime = sum(llmTotalRuntime) / len(llmTotalRuntime) - if averageRuntime > 25: - msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" - if (channel_number == publicChannel and antiSpam) or useDMForResponse: - # send via DM - send_message(msg, channel_number, message_from_id, deviceID) - time.sleep(responseDelay) - else: - # send via channel - send_message(msg, channel_number, 0, deviceID) - time.sleep(responseDelay) + msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else None else: msg = "Please wait, response could take 30+ seconds. Fund the SysOp's GPU budget!" + + if msg: if (channel_number == publicChannel and antiSpam) or useDMForResponse: # send via DM send_message(msg, channel_number, message_from_id, deviceID) - time.sleep(responseDelay) else: # send via channel send_message(msg, channel_number, 0, deviceID) - time.sleep(responseDelay) + time.sleep(responseDelay) start = time.time() @@ -1197,6 +1188,7 @@ def onReceive(packet, interface): else: # message is on a channel if messageTrap(message_string): + # message is for us to respond to if ignoreDefaultChannel and channel_number == publicChannel: logger.debug(f"System: ignoreDefaultChannel CMD:{message_string} From: {get_name_from_number(message_from_id, 'short', rxNode)}") else: @@ -1219,7 +1211,7 @@ def onReceive(packet, interface): send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode, isDM), channel_number, 0, rxNode) else: - # message is not for bot to respond to + # message is not for us to respond to # ignore the message but add it to the message history list if zuluTime: timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") From cea91477453ced6bc69597e33e841da5abfa4a2d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 21 Jan 2025 20:05:11 -0800 Subject: [PATCH 2/5] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index bf05804..76ab1ef 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -398,7 +398,7 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel averageRuntime = sum(llmTotalRuntime) / len(llmTotalRuntime) msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else None else: - msg = "Please wait, response could take 30+ seconds. Fund the SysOp's GPU budget!" + logger.debug(f"System: LLM: First Query, computing runtime") if msg: if (channel_number == publicChannel and antiSpam) or useDMForResponse: From fe8ba8aaf4163495293ddfa4f75cda76cc98073c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 21 Jan 2025 20:10:01 -0800 Subject: [PATCH 3/5] Update mesh_bot.py --- mesh_bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 76ab1ef..f4ba95f 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -343,6 +343,7 @@ def handle_satpass(message_from_id, deviceID, channel_number, message): def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel): global llmRunCounter, llmLocationTable, llmTotalRuntime, cmdHistory location_name = 'no location provided' + msg = '' if location_enabled: # if message_from_id is is the llmLocationTable use the location from the list to save on API calls @@ -396,11 +397,11 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel # information for the user on how long the query will take on average if llmRunCounter > 0: averageRuntime = sum(llmTotalRuntime) / len(llmTotalRuntime) - msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else None + msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else '' else: logger.debug(f"System: LLM: First Query, computing runtime") - if msg: + if msg != '': if (channel_number == publicChannel and antiSpam) or useDMForResponse: # send via DM send_message(msg, channel_number, message_from_id, deviceID) From 82880677f4454370f09b37e0b7b1a2149fdf3254 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 21 Jan 2025 20:21:32 -0800 Subject: [PATCH 4/5] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index f4ba95f..d585cd5 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -399,7 +399,7 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel averageRuntime = sum(llmTotalRuntime) / len(llmTotalRuntime) msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else '' else: - logger.debug(f"System: LLM: First Query, computing runtime") + msg = "Please wait, response could take 30+ seconds. Fund the SysOp's GPU budget!" if msg != '': if (channel_number == publicChannel and antiSpam) or useDMForResponse: From 73e8e063d268489b86ab667e5ebfaec622c73f82 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 21 Jan 2025 20:22:25 -0800 Subject: [PATCH 5/5] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index d585cd5..6922851 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -397,7 +397,7 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel # information for the user on how long the query will take on average if llmRunCounter > 0: averageRuntime = sum(llmTotalRuntime) / len(llmTotalRuntime) - msg = f"Please wait, average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else '' + msg = f"Average query time is: {int(averageRuntime)} seconds" if averageRuntime > 25 else '' else: msg = "Please wait, response could take 30+ seconds. Fund the SysOp's GPU budget!"