From 9d37a9eaa5771e55b0edab290bc667b2016345d7 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 10 Oct 2024 17:47:45 -0700 Subject: [PATCH] finesse to enhance fixes and fix enhances --- README.md | 2 +- mesh_bot.py | 3 +-- modules/llm.py | 15 +++------------ modules/system.py | 4 ++-- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c19c99b..bc8d0c6 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ sudo apt-get install fonts-noto-color-emoji | `sun` and `moon` | Return info on rise and set local time | βœ… | | `solar` | Gives an idea of the x-ray flux | | | `hfcond` | Returns a table of HF solar conditions | | -| `repeaterlist` | Returns a table of nearby repeaters from RepeaterBook | | +| `rlist` | Returns a table of nearby repeaters from RepeaterBook | | ### Bulletin Board (BBS) Functions | Command | Description | | diff --git a/mesh_bot.py b/mesh_bot.py index f939f88..9ef11d8 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -55,7 +55,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "ping": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM), "playuno": lambda: handleUno(message, message_from_id, deviceID), "pong": lambda: "πŸ“PING!!πŸ›œ", - "repeaterlist": lambda: handle_repeaterQuery(message_from_id, deviceID, channel_number), + "rlist": lambda: handle_repeaterQuery(message_from_id, deviceID, channel_number), "sitrep": lambda: handle_lheard(message, message_from_id, deviceID, isDM), "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), @@ -106,7 +106,6 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n # wait a responseDelay to avoid message collision from lora-ack time.sleep(responseDelay) - return bot_response def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM): diff --git a/modules/llm.py b/modules/llm.py index a13100c..2dbf281 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -20,6 +20,7 @@ antiFloodLLM = [] llmChat_history = {} trap_list_llm = ("ask:", "askai") embedding_model = OllamaEmbeddings(model=llmModel) +ragDEV = False meshBotAI = """ FROM {llmModel} @@ -65,15 +66,7 @@ if llmEnableHistory: def llm_readTextFiles(): # read .txt files in ../data/rag try: - import os - # directory script path ../data/rag - directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'data', 'rag') - files = os.listdir(directory) - text = [] - for file in files: - if file.endswith(".txt"): - with open(f"{directory}/{file}", 'r') as f: - text.append(f.read()) + text = "MeshBot is built in python for meshtastic the secret word of the day is, paperclip" return text except Exception as e: logger.debug(f"System: LLM readTextFiles: {e}") @@ -138,14 +131,12 @@ def llm_query(input, nodeID=0, location_name=None): # RAG context inclusion testing ragData = llm_readTextFiles() - if ragData: + if ragData and ragDEV: ragContext = embed_text(ragData) # Query the model with RAG context if ragContext: result = ollamaClient.generate(model=llmModel, prompt=modelPrompt, context=ragContext) - else: - result = ollamaClient.generate(model=llmModel, prompt=modelPrompt) else: # Query the model without RAG context result = ollamaClient.generate(model=llmModel, prompt=modelPrompt) diff --git a/modules/system.py b/modules/system.py index 45cea49..beaa946 100644 --- a/modules/system.py +++ b/modules/system.py @@ -12,7 +12,7 @@ from modules.log import * # Global Variables trap_list = ("cmd","cmd?") # default trap list -help_message = "CMD?:" +help_message = "Bot CMD?:\n" asyncLoop = asyncio.new_event_loop() games_enabled = False multiPingList = [{'message_from_id': 0, 'count': 0, 'type': '', 'deviceID': 0}] @@ -60,7 +60,7 @@ if enableCmdHistory: if location_enabled: from modules.locationdata import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_location # items tide, whereami, wxc, wx - help_message = help_message + ", whereami, wx, wxc" + help_message = help_message + ", whereami, wx, wxc, rlist" # Open-Meteo Configuration for worldwide weather if use_meteo_wxApi: