From e0c56812b053f078eeddf3d29dad90d93206bdd7 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Mon, 16 Dec 2024 18:16:40 -0800 Subject: [PATCH 1/3] wip change workspace llm settings --- .../WorkspaceLLMItem/index.jsx | 70 +++++++++++++------ 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx b/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx index a8017b2ec5e..bc428fbbd1b 100644 --- a/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx +++ b/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx @@ -4,9 +4,10 @@ import { createPortal } from "react-dom"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; -import { X } from "@phosphor-icons/react"; +import { X, Gear } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; +import { useEffect, useState } from "react"; export default function WorkspaceLLM({ llm, @@ -17,18 +18,31 @@ export default function WorkspaceLLM({ }) { const { isOpen, openModal, closeModal } = useModal(); const { name, value, logo, description } = llm; + const [currentSettings, setCurrentSettings] = useState(settings); + + useEffect(() => { + async function getSettings() { + if (isOpen) { + const _settings = await System.keys(); + setCurrentSettings(_settings ?? {}); + } + } + getSettings(); + }, [isOpen]); function handleProviderSelection() { // Determine if provider needs additional setup because its minimum required keys are // not yet set in settings. - const requiresAdditionalSetup = (llm.requiredConfig || []).some( - (key) => !settings[key] - ); - if (requiresAdditionalSetup) { - openModal(); - return; + if (!checked) { + const requiresAdditionalSetup = (llm.requiredConfig || []).some( + (key) => !currentSettings[key] + ); + if (requiresAdditionalSetup) { + openModal(); + return; + } + onClick(value); } - onClick(value); } return ( @@ -47,16 +61,30 @@ export default function WorkspaceLLM({ readOnly={true} formNoValidate={true} /> -
- {`${name} -
-
{name}
-
{description}
+
+
+ {`${name} +
+
{name}
+
{description}
+
+ {checked && ( + + )}
); @@ -76,6 +105,7 @@ function SetupProvider({ provider, closeModal, postSubmit, + settings, }) { if (!isOpen) return null; const LLMOption = availableLLMs.find((llm) => llm.value === provider); @@ -107,7 +137,7 @@ function SetupProvider({

- Setup {LLMOption.name} + {LLMOption.name} Settings

From 786d76f302459936da34cb69fb8a42573cdb75ba Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Tue, 17 Dec 2024 11:02:35 -0800 Subject: [PATCH 2/3] allow editing of workspace llm and agent config inside workspace settings --- .../AgentLLMSelection/AgentLLMItem/index.jsx | 80 +++++++++++++------ .../ChatModelSelection/index.jsx | 4 +- .../WorkspaceLLMItem/index.jsx | 4 +- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx b/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx index 10bb03473c3..bb919f4d0c9 100644 --- a/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx +++ b/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx @@ -4,11 +4,12 @@ import { createPortal } from "react-dom"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; -import { X } from "@phosphor-icons/react"; +import { X, Gear } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; +import { useEffect, useState } from "react"; -export default function WorkspaceLLM({ +export default function AgentLLMItem({ llm, availableLLMs, settings, @@ -17,18 +18,29 @@ export default function WorkspaceLLM({ }) { const { isOpen, openModal, closeModal } = useModal(); const { name, value, logo, description } = llm; + const [currentSettings, setCurrentSettings] = useState(settings); + + useEffect(() => { + async function getSettings() { + if (isOpen) { + const _settings = await System.keys(); + setCurrentSettings(_settings ?? {}); + } + } + getSettings(); + }, [isOpen]); function handleProviderSelection() { - // Determine if provider needs additional setup because its minimum required keys are - // not yet set in settings. - const requiresAdditionalSetup = (llm.requiredConfig || []).some( - (key) => !settings[key] - ); - if (requiresAdditionalSetup) { - openModal(); - return; + if (!checked) { + const requiresAdditionalSetup = (llm.requiredConfig || []).some( + (key) => !currentSettings[key] + ); + if (requiresAdditionalSetup) { + openModal(); + return; + } + onClick(value); } - onClick(value); } return ( @@ -47,16 +59,30 @@ export default function WorkspaceLLM({ readOnly={true} formNoValidate={true} /> -
- {`${name} -
-
{name}
-
{description}
+
+
+ {`${name} +
+
{name}
+
{description}
+
+ {checked && value !== "none" && ( + + )}
); @@ -76,6 +103,7 @@ function SetupProvider({ provider, closeModal, postSubmit, + settings, }) { if (!isOpen) return null; const LLMOption = availableLLMs.find((llm) => llm.value === provider); @@ -107,7 +135,7 @@ function SetupProvider({

- Setup {LLMOption.name} + {LLMOption.name} Settings