From c8c56d272320807b671e7e4ac97a16a47dc63917 Mon Sep 17 00:00:00 2001 From: lochan paudel Date: Sun, 6 Jul 2025 13:59:47 +0530 Subject: [PATCH] Fix: Model uses the system prompt and query rewriting prompt from the database if it exists. Signed-off-by: lochan paudel --- src/mvt/pages/chatbot.py | 4 ++-- src/mvt/pages/prompt_management.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mvt/pages/chatbot.py b/src/mvt/pages/chatbot.py index 96b6d36..b6d33ea 100644 --- a/src/mvt/pages/chatbot.py +++ b/src/mvt/pages/chatbot.py @@ -1,4 +1,4 @@ -from utils import load_yaml_file +from utils import load_yaml_file_with_db_prompts from main import get_ragchain import streamlit as st from menu import menu_with_redirect @@ -23,7 +23,7 @@ config_path = "./config.yaml" logo_path = "https://github.com/hyperledger-labs/aifaq/blob/mvt-streamlit/images/logo.png?raw=true" -config_data = load_yaml_file(config_path) +config_data = load_yaml_file_with_db_prompts(config_path) # filter public document in case of guest user filter = None diff --git a/src/mvt/pages/prompt_management.py b/src/mvt/pages/prompt_management.py index 6496add..fdcad4d 100644 --- a/src/mvt/pages/prompt_management.py +++ b/src/mvt/pages/prompt_management.py @@ -1,6 +1,6 @@ import streamlit as st import yaml -from utils import load_yaml_file +from utils import load_yaml_file, load_yaml_file_with_db_prompts from database import create_connection, create_prompts_table, save_prompt, get_prompt from menu import menu_with_redirect @@ -87,7 +87,12 @@ def load_prompts_from_db(): # Initialize session state for prompts if not already set if "current_prompts" not in st.session_state: - st.session_state.current_prompts = load_prompts_from_db() + # Use the utility function that loads from database with config fallback + config_data = load_yaml_file_with_db_prompts("config.yaml") + st.session_state.current_prompts = { + "system_prompt": config_data.get("system_prompt", ""), + "query_rewriting_prompt": config_data.get("query_rewriting_prompt", "") + } # Create columns for better layout col1, col2 = st.columns([3, 1])