Skip to content

Commit

Permalink
block pre prompt edition in read only
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrochar committed Mar 19, 2024
1 parent 2d39526 commit 7931d18
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions blitz/ui/pages/gpt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from nicegui.events import KeyEventArguments
from openai import APIConnectionError, AsyncOpenAI, AsyncStream, AuthenticationError

from blitz.settings import get_settings
from blitz.settings import Settings, get_settings
from blitz.ui.blitz_ui import BlitzUI, get_blitz_ui
from blitz.ui.components import notify
from blitz.ui.components.buttons.flat import FlatButton
Expand Down Expand Up @@ -334,14 +334,13 @@ async def ask_gpt(self) -> AsyncGenerator[str, None]:

class ChatSettings:
def __init__(
self,
gpt_client: GPTClient,
blitz_ui: BlitzUI = get_blitz_ui(),
self, gpt_client: GPTClient, blitz_ui: BlitzUI = get_blitz_ui(), settings: Settings = get_settings()
) -> None:
self.gpt_client = gpt_client
self.dialog = ui.dialog().props("maximized transition-show=slide-up transition-hide=slide-down")
self.blitz_ui = blitz_ui
self.quit_dialog = ui.dialog(value=False)
self.read_only = settings.BLITZ_READ_ONLY

@ui.refreshable
def render(self) -> None:
Expand Down Expand Up @@ -401,6 +400,8 @@ def pre_prompt_editor(self) -> None:
with WFullItemsCenterRow():
OutlineButton("Reset Pre-Prompt", on_click=self.reset_preprompt)
switch = ui.switch("Edit Pre-Prompt", value=False)
if self.read_only:
switch.disable()
self.preprompt = (
ui.textarea(label="Pre-Prompt", value=self.blitz_ui.preprompt)
.classes("w-full rounded-lg px-2 border-solid border")
Expand Down

0 comments on commit 7931d18

Please sign in to comment.