From bf48a61766db86c56593a31acadcaf6f59bc69c9 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 14 Oct 2024 18:00:20 -0700 Subject: [PATCH] Update llm.py --- modules/llm.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/llm.py b/modules/llm.py index ade6f65..6521543 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -168,17 +168,20 @@ def llm_query(input, nodeID=0, location_name=None): location_name += f" at the current time of {datetime.now().strftime('%Y-%m-%d %H:%M:%S %Z')}" try: - # Build the query from the template - modelPrompt = meshBotAI.format(input=input, context='\n'.join(googleResults), location_name=location_name, llmModel=llmModel, history=history) - # RAG context inclusion testing + ragContext = False if ragDEV: ragContext = query_collection(input) + if ragContext: + ragContextGooogle = ragContext + '\n'.join(googleResults) + # Build the query from the template + modelPrompt = meshBotAI.format(input=input, context=ragContext, location_name=location_name, llmModel=llmModel, history=history) # Query the model with RAG context - if ragContext: - result = ollamaClient.generate(model=llmModel, prompt=f"Using this data: {ragContext}. Respond to this prompt: {input}") + result = ollamaClient.generate(model=llmModel, prompt=f"Using this data: {ragContext}. Respond to this prompt: {input}") else: + # Build the query from the template + modelPrompt = meshBotAI.format(input=input, context='\n'.join(googleResults), location_name=location_name, llmModel=llmModel, history=history) # Query the model without RAG context result = ollamaClient.generate(model=llmModel, prompt=modelPrompt)