to enhance fixes and fix enhances
This commit is contained in:
SpudGunMan
2024-10-10 17:47:45 -07:00
parent 66d7f98716
commit 9d37a9eaa5
4 changed files with 7 additions and 17 deletions
+3 -12
View File
@@ -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)
+2 -2
View File
@@ -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: