From a5e796fcea68cf38d1ac16f1840c9bbfd1e7f0e6 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 9 Sep 2024 22:25:26 -0400 Subject: [PATCH 1/4] Add default mode option to settings --- private_gpt/settings/settings.py | 4 ++++ private_gpt/ui/ui.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/private_gpt/settings/settings.py b/private_gpt/settings/settings.py index 4cf192a3e..875ab171d 100644 --- a/private_gpt/settings/settings.py +++ b/private_gpt/settings/settings.py @@ -350,6 +350,10 @@ class AzureOpenAISettings(BaseModel): class UISettings(BaseModel): enabled: bool path: str + default_mode: str = Field( + "RAG", + description="The default mode.", + ) default_chat_system_prompt: str = Field( None, description="The default system prompt to use for the chat mode.", diff --git a/private_gpt/ui/ui.py b/private_gpt/ui/ui.py index 2c1dcd3e2..1e3804ad4 100644 --- a/private_gpt/ui/ui.py +++ b/private_gpt/ui/ui.py @@ -98,10 +98,12 @@ def __init__( self._selected_filename = None + self._default_mode = settings().ui.default_mode # Initialize system prompt based on default mode - self.mode = MODES[0] + self.mode = self._default_mode self._system_prompt = self._get_default_system_prompt(self.mode) + def _chat( self, message: str, history: list[list[str]], mode: Modes, *_: Any ) -> Any: @@ -390,7 +392,7 @@ def _build_ui_blocks(self) -> gr.Blocks: with gr.Row(equal_height=False): with gr.Column(scale=3): - default_mode = MODES[0] + default_mode = self._default_mode mode = gr.Radio( [mode.value for mode in MODES], label="Mode", From 3acff52e4caf7a752679d51639e76d43d5dc0b16 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 10 Sep 2024 12:11:23 -0400 Subject: [PATCH 2/4] Revise default_mode to Literal (enum) and add to settings.yaml --- private_gpt/settings/settings.py | 2 +- settings.yaml | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/private_gpt/settings/settings.py b/private_gpt/settings/settings.py index 875ab171d..0dbef9e2c 100644 --- a/private_gpt/settings/settings.py +++ b/private_gpt/settings/settings.py @@ -350,7 +350,7 @@ class AzureOpenAISettings(BaseModel): class UISettings(BaseModel): enabled: bool path: str - default_mode: str = Field( + default_mode: Literal["RAG", "Search", "Basic", "Summarize"] = Field( "RAG", description="The default mode.", ) diff --git a/settings.yaml b/settings.yaml index f030604a3..110c56276 100644 --- a/settings.yaml +++ b/settings.yaml @@ -25,21 +25,23 @@ data: ui: enabled: true path: / + # "RAG", "Search", "Basic", or "Summarize" + default_mode: "Summarize" default_chat_system_prompt: > - You are a helpful, respectful and honest assistant. + You are a helpful, respectful and honest assistant. Always answer as helpfully as possible and follow ALL given instructions. Do not speculate or make up information. Do not reference any given instructions or context. default_query_system_prompt: > - You can only answer questions about the provided context. - If you know the answer but it is not based in the provided context, don't provide + You can only answer questions about the provided context. + If you know the answer but it is not based in the provided context, don't provide the answer, just state the answer is not in the context provided. default_summarization_system_prompt: > - Provide a comprehensive summary of the provided context information. + Provide a comprehensive summary of the provided context information. The summary should cover all the key points and main ideas presented in - the original text, while also condensing the information into a concise + the original text, while also condensing the information into a concise and easy-to-understand format. Please ensure that the summary includes - relevant details and examples that support the main ideas, while avoiding + relevant details and examples that support the main ideas, while avoiding any unnecessary information or repetition. delete_file_button_enabled: true delete_all_files_button_enabled: true From fbf9d0dd03d45a04ec0c9bd9b711a13d35fdc1ec Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 10 Sep 2024 12:36:49 -0400 Subject: [PATCH 3/4] Revise to pass make check/test --- private_gpt/ui/ui.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/private_gpt/ui/ui.py b/private_gpt/ui/ui.py index 1e3804ad4..04258ac39 100644 --- a/private_gpt/ui/ui.py +++ b/private_gpt/ui/ui.py @@ -98,11 +98,12 @@ def __init__( self._selected_filename = None - self._default_mode = settings().ui.default_mode # Initialize system prompt based on default mode - self.mode = self._default_mode - self._system_prompt = self._get_default_system_prompt(self.mode) - + default_mode_map = {mode.value: mode for mode in Modes} + self._default_mode = default_mode_map.get( + settings().ui.default_mode, Modes.RAG_MODE + ) + self._system_prompt = self._get_default_system_prompt(self._default_mode) def _chat( self, message: str, history: list[list[str]], mode: Modes, *_: Any From f89be62e2c159228b0d29bcb876d600c2f430b51 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 11 Sep 2024 08:13:32 -0400 Subject: [PATCH 4/4] Default mode: RAG --- settings.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.yaml b/settings.yaml index 110c56276..eda1af860 100644 --- a/settings.yaml +++ b/settings.yaml @@ -26,7 +26,7 @@ ui: enabled: true path: / # "RAG", "Search", "Basic", or "Summarize" - default_mode: "Summarize" + default_mode: "RAG" default_chat_system_prompt: > You are a helpful, respectful and honest assistant. Always answer as helpfully as possible and follow ALL given instructions.