diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1fc964d9..001cae28 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -16,7 +16,7 @@ import { MessageWithFiles } from "./utils/formTypes.ts"; import { useNavigate } from "react-router-dom"; import { useThreadAndAssistant } from "./hooks/useThreadAndAssistant.ts"; -function App() { +function App(props: { edit?: boolean }) { const navigate = useNavigate(); const [sidebarOpen, setSidebarOpen] = useState(false); const { chats, createChat } = useChatList(); @@ -124,7 +124,7 @@ function App() { {currentChat && assistantConfig && ( )} - {!currentChat && assistantConfig && ( + {!currentChat && assistantConfig && !props.edit && ( )} + {!currentChat && assistantConfig && props.edit && ( + + )} {!currentChat && !assistantConfig && !isLoading && ( void; + edit?: boolean; }) { const [values, setValues] = useState( props.config?.config ?? props.configDefaults, @@ -537,9 +538,9 @@ export function Config(props: { } }, [dropzone.acceptedFiles, setFiles]); const [inflight, setInflight] = useState(false); - const readonly = !!props.config && !inflight; + const readonly = !!props.config && !props.edit && !inflight; - const settings = !props.config ? ( + const settings = !readonly ? (
@@ -550,6 +551,7 @@ export function Config(props: { autoComplete="off" className="block w-full rounded-none rounded-l-md border-0 py-1.5 pl-4 text-gray-900 ring-1 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 ring-inset ring-gray-300" placeholder="Name your bot" + defaultValue={props.config?.name} />
+ event.stopPropagation()} + > + +
); diff --git a/frontend/src/hooks/useConfigList.ts b/frontend/src/hooks/useConfigList.ts index d8e3c329..eaa1425f 100644 --- a/frontend/src/hooks/useConfigList.ts +++ b/frontend/src/hooks/useConfigList.ts @@ -22,6 +22,7 @@ export interface ConfigListProps { config: Config["config"], files: File[], isPublic: boolean, + assistantId?: string, ) => Promise; } @@ -64,15 +65,19 @@ export function useConfigList(): ConfigListProps { config: Config["config"], files: File[], isPublic: boolean, + assistantId?: string, ): Promise => { - const confResponse = await fetch(`/assistants`, { - method: "POST", - body: JSON.stringify({ name, config, public: isPublic }), - headers: { - "Content-Type": "application/json", - Accept: "application/json", + const confResponse = await fetch( + assistantId ? `/assistants/${assistantId}` : "/assistants", + { + method: assistantId ? "PUT" : "POST", + body: JSON.stringify({ name, config, public: isPublic }), + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, }, - }); + ); const savedConfig = (await confResponse.json()) as Config; if (files.length) { const assistant_id = savedConfig.assistant_id; diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index af504278..4a41abeb 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -19,6 +19,10 @@ ReactDOM.createRoot(document.getElementById("root")!).render( } /> + } + /> } /> } /> } />