Skip to content

Commit 52289c7

Browse files
authored
Fix: Model uses the system prompt and query rewriting prompt from the database if it exists. (#124)
Signed-off-by: lochan paudel <lochanpaudel10@gmail.com>
1 parent 2f2494b commit 52289c7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/mvt/pages/chatbot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from utils import load_yaml_file
1+
from utils import load_yaml_file_with_db_prompts
22
from main import get_ragchain
33
import streamlit as st
44
from menu import menu_with_redirect
@@ -23,7 +23,7 @@
2323

2424
config_path = "./config.yaml"
2525
logo_path = "https://github.com/hyperledger-labs/aifaq/blob/mvt-streamlit/images/logo.png?raw=true"
26-
config_data = load_yaml_file(config_path)
26+
config_data = load_yaml_file_with_db_prompts(config_path)
2727

2828
# filter public document in case of guest user
2929
filter = None

src/mvt/pages/prompt_management.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import streamlit as st
22
import yaml
3-
from utils import load_yaml_file
3+
from utils import load_yaml_file, load_yaml_file_with_db_prompts
44
from database import create_connection, create_prompts_table, save_prompt, get_prompt
55
from menu import menu_with_redirect
66

@@ -87,7 +87,12 @@ def load_prompts_from_db():
8787

8888
# Initialize session state for prompts if not already set
8989
if "current_prompts" not in st.session_state:
90-
st.session_state.current_prompts = load_prompts_from_db()
90+
# Use the utility function that loads from database with config fallback
91+
config_data = load_yaml_file_with_db_prompts("config.yaml")
92+
st.session_state.current_prompts = {
93+
"system_prompt": config_data.get("system_prompt", ""),
94+
"query_rewriting_prompt": config_data.get("query_rewriting_prompt", "")
95+
}
9196

9297
# Create columns for better layout
9398
col1, col2 = st.columns([3, 1])

0 commit comments

Comments
 (0)