Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default mode option to settings #2078

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions private_gpt/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class AzureOpenAISettings(BaseModel):
class UISettings(BaseModel):
enabled: bool
path: str
default_mode: str = Field(
"RAG",
description="The default mode.",
)
jaluma marked this conversation as resolved.
Show resolved Hide resolved
default_chat_system_prompt: str = Field(
None,
description="The default system prompt to use for the chat mode.",
Expand Down
6 changes: 4 additions & 2 deletions private_gpt/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down