From 5d53db42110acc0086a61c8831d19d9f7f026f00 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 3 Sep 2024 17:13:04 -0700 Subject: [PATCH] enhance --- README.md | 4 ++-- mesh_bot.py | 5 ++++- modules/llm.py | 2 +- modules/system.py | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a57aa12..c1451c2 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ Any messages that are over 160 characters are chunked into 160 message bytes to - `wx` and `wxc` returns local weather forecast, (wxc is metric value), NOAA or Open Meteo for weather forecasting. - `wxa` and `wxalert` return NOAA alerts. Short title or expanded details - `joke` tells a joke - - `wiki: ` search wikipedia, return the first few sentances of first result if a match `wiki: lora radio` - - `ask: ` ask Ollama LLM AI for a response `ask: what temp do I cook chicken` + - `wiki: ` will search wikipedia, return the first few sentances of first result if a match `wiki: lora radio` + - `askai` and `ask:` will ask Ollama LLM AI for a response `askai what temp do I cook chicken` - `messages` Replay the last messages heard, like Store and Forward - `motd` or to set the message `motd $New Message Of the day` - `lheard` returns the last 5 heard nodes with SNR, can also use `sitrep` diff --git a/mesh_bot.py b/mesh_bot.py index 534c019..b6f2071 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -24,6 +24,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), "wiki:": lambda: handle_wiki(message), "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), "joke": tell_joke, "bbslist": bbs_list_messages, "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), @@ -108,9 +109,11 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel global llmRunCounter, llmTotalRuntime if "ask:" in message.lower(): user_input = message.split(":")[1] - user_input = user_input.strip() + elif "askai" in message.lower(): + user_input = message.replace("askai", "") else: user_input = message + user_input = user_input.strip() if len(user_input) < 1: return "Please ask a question" diff --git a/modules/llm.py b/modules/llm.py index 3b6d041..2550e89 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -13,7 +13,7 @@ llmEnableHistory = False llm_history_limit = 6 # limit the history to 3 messages (come in pairs) antiFloodLLM = [] llmChat_history = [] -trap_list_llm = ("ask:",) +trap_list_llm = ("ask:", "askai") meshBotAI = """ FROM {llmModel} diff --git a/modules/system.py b/modules/system.py index fed86cc..03f10fe 100644 --- a/modules/system.py +++ b/modules/system.py @@ -74,7 +74,7 @@ if wikipedia_enabled: if llm_enabled: from modules.llm import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_llm # items ask: - help_message = help_message + ", ask:" + help_message = help_message + ", askai" # Scheduled Broadcast Configuration if scheduler_enabled: @@ -670,7 +670,6 @@ async def watchdog(): with contextlib.redirect_stdout(None): interface1.localNode.getMetadata() print(f"System: if you see this upgrade python to >3.4") - #if "device_state_version:" not in meta: except Exception as e: logger.error(f"System: communicating with interface1, trying to reconnect: {e}") retry_int1 = True