From 43067cfb07f955360a4d0f84e8e7fbd5b923d910 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 27 Oct 2024 16:58:05 -0700 Subject: [PATCH] Update llm.py --- modules/llm.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/modules/llm.py b/modules/llm.py index 7f39731..fe31427 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -9,21 +9,12 @@ from modules.log import * from ollama import Client as OllamaClient from googlesearch import search # pip install googlesearch-python -# enahanced workflow with OpenWebUI, allowing queries with the OpenWebUI API -openWebUI = False -openWebUI_api_key = "your_api_key" -openWebUI_collection_id = "your_collection_id" -openWebUI_base_url = 'http://localhost:3000/api' - # This is my attempt at a simple RAG implementation it will require some setup # you will need to have the RAG data in a folder named rag in the data directory (../data/rag) # This is lighter weight and can be used in a standalone environment, needs chromadb # "chat with a file" is the use concept here, the file is the RAG data ragDEV = False -if openWebUI: - import requests - if ragDEV: import os import ollama # pip install ollama @@ -146,18 +137,6 @@ def query_collection(prompt): data = results['documents'][0][0] return data -def llm_query_openWebUI(input, nodeID=0, location_name=None): - # passes the message-rx to the OpenWebUI API directly - headers = {'Authorization': f'Bearer {openWebUI_api_key}', 'Content-Type': 'application/json'} - payload = {'model': llmModel, 'messages': [{'role': 'user', 'content': input}], 'files': [{'type': 'collection', 'id': openWebUI_collection_id}]} - response = requests.post(f"{openWebUI_base_url}/chat/completions", headers=headers, json=payload) - - if response.status_code == 200: - return response.json()["choices"][0]["message"]["content"] - else: - logger.debug(f"System: LLM: {response.status_code} - {response.text}") - return "I am having trouble processing your request, please try again later." - def llm_query(input, nodeID=0, location_name=None): global antiFloodLLM, llmChat_history googleResults = []