mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-06 09:51:24 +02:00
openWebUI
This commit is contained in:
@@ -9,8 +9,19 @@ from modules.log import *
|
||||
from ollama import Client as OllamaClient
|
||||
from googlesearch import search # pip install googlesearch-python
|
||||
|
||||
# enahanced workflow with OpenWebUI
|
||||
openWebUI = False
|
||||
|
||||
# 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
|
||||
ragDEV = False
|
||||
|
||||
if openWebUI:
|
||||
import requests
|
||||
openWebUI_api_key = "your_api_key"
|
||||
openWebUI_base_url = "http://localhost:3000/api/v1"
|
||||
|
||||
if ragDEV:
|
||||
import os
|
||||
import ollama # pip install ollama
|
||||
@@ -134,6 +145,18 @@ 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}"}
|
||||
data = {"model": llmModel, "prompt": input}
|
||||
response = requests.post(f"{openWebUI_base_url}/chat/completions", headers=headers, json=data)
|
||||
|
||||
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 = []
|
||||
|
||||
Reference in New Issue
Block a user