From c689356b31bd032983c680223804d90d8cbd6602 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 20 Jun 2024 03:57:36 -0700 Subject: [PATCH] refac --- backend/apps/ollama/main.py | 17 ++++------------- src/lib/components/chat/Chat.svelte | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/backend/apps/ollama/main.py b/backend/apps/ollama/main.py index 22a30474e..455dc89a5 100644 --- a/backend/apps/ollama/main.py +++ b/backend/apps/ollama/main.py @@ -53,7 +53,7 @@ from config import ( UPLOAD_DIR, AppConfig, ) -from utils.misc import calculate_sha256 +from utils.misc import calculate_sha256, add_or_update_system_message log = logging.getLogger(__name__) log.setLevel(SRC_LOG_LEVELS["OLLAMA"]) @@ -834,18 +834,9 @@ async def generate_chat_completion( ) if payload.get("messages"): - for message in payload["messages"]: - if message.get("role") == "system": - message["content"] = system + message["content"] - break - else: - payload["messages"].insert( - 0, - { - "role": "system", - "content": system, - }, - ) + payload["messages"] = add_or_update_system_message( + system, payload["messages"] + ) if url_idx == None: if ":" not in payload["model"]: diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 9cf2201fc..d83eb3cb2 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -941,7 +941,7 @@ chat_id: $chatId }, - `${OPENAI_API_BASE_URL}` + `${WEBUI_BASE_URL}/api` ); // Wait until history/message have been updated