From c8eddc3787e75e225b31563f6b60e9783dfd0edd Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 24 Oct 2024 19:44:51 -0700 Subject: [PATCH] Update llm.py --- modules/llm.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/llm.py b/modules/llm.py index 4ffb113..0179954 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -20,7 +20,8 @@ ragDEV = False if openWebUI: import requests openWebUI_api_key = "your_api_key" - openWebUI_base_url = "http://localhost:3000/api/v1" + openWebUI_collection_id = "your_collection_id" + openWebUI_base_url = 'http://localhost:3000/api' if ragDEV: import os @@ -147,9 +148,9 @@ def query_collection(prompt): 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) + 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"]