mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-08 01:42:51 +02:00
LocationAware
This commit is contained in:
+6
-1
@@ -107,8 +107,13 @@ def handle_wiki(message):
|
||||
|
||||
def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel):
|
||||
global llmRunCounter, llmTotalRuntime
|
||||
|
||||
location = get_node_location(message_from_id, deviceID)
|
||||
location_name = where_am_i(str(location[0]), str(location[1], short=True))
|
||||
if location_enabled:
|
||||
location_name = where_am_i(str(location[0]), str(location[1], short=True))
|
||||
else:
|
||||
location_name = "Unknown"
|
||||
|
||||
if "ask:" in message.lower():
|
||||
user_input = message.split(":")[1]
|
||||
elif "askai" in message.lower():
|
||||
|
||||
+14
-4
@@ -33,15 +33,24 @@ PROMPT
|
||||
{input}
|
||||
user={userID}
|
||||
|
||||
|
||||
"""
|
||||
|
||||
if llmContext_fromGoogle:
|
||||
meshBotAI = meshBotAI + """
|
||||
CONTEXT
|
||||
The following is the location the user
|
||||
{location_name}
|
||||
|
||||
The following is for context around the prompt to help guide your response.
|
||||
{context}
|
||||
|
||||
"""
|
||||
else:
|
||||
meshBotAI = meshBotAI + """
|
||||
CONTEXT
|
||||
The following is the location the user
|
||||
{location_name}
|
||||
|
||||
"""
|
||||
|
||||
if llmEnableHistory:
|
||||
@@ -80,10 +89,10 @@ def llm_query(input, nodeID=0, location_name=None):
|
||||
# SearchResult object has url= title= description= just grab title and description
|
||||
googleResults.append(f"{result.title} {result.description}")
|
||||
else:
|
||||
googleResults = ['no context provided']
|
||||
googleResults = ['no other context provided']
|
||||
except Exception as e:
|
||||
logger.debug(f"System: LLM Query: context gathering error: {e}")
|
||||
googleResults = ['no context provided']
|
||||
googleResults = ['no other context provided']
|
||||
|
||||
|
||||
if googleResults:
|
||||
@@ -93,7 +102,8 @@ def llm_query(input, nodeID=0, location_name=None):
|
||||
|
||||
response = ""
|
||||
result = ""
|
||||
result = chain_prompt_model.invoke({"input": input, "llmModel": llmModel, "userID": nodeID, "history": llmChat_history, "context": googleResults})
|
||||
result = chain_prompt_model.invoke({"input": input, "llmModel": llmModel, "userID": nodeID, \
|
||||
"history": llmChat_history, "context": googleResults, "location_name": location_name})
|
||||
#logger.debug(f"System: LLM Response: " + result.strip().replace('\n', ' '))
|
||||
|
||||
response = result.strip().replace('\n', ' ')
|
||||
|
||||
Reference in New Issue
Block a user