diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 638ff016..97e589ed 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -249,7 +249,6 @@ def create_prompt(): if name == "": return {"status": "error"} user = "local" - # write to mongodb resp = prompts_collection.insert_one( { "name": name, @@ -258,7 +257,7 @@ def create_prompt(): } ) new_id = str(resp.inserted_id) - return {"id": new_id, "name": name, "content": content} + return {"id": new_id} @user.route("/api/get_prompts", methods=["GET"]) def get_prompts(): diff --git a/frontend/src/Setting.tsx b/frontend/src/Setting.tsx index 0927fc18..65756bea 100644 --- a/frontend/src/Setting.tsx +++ b/frontend/src/Setting.tsx @@ -255,10 +255,13 @@ const Prompts: React.FC = ({ } const newPrompt = await response.json(); if (setPrompts) { - setPrompts([...prompts, newPrompt]); + setPrompts([ + ...prompts, + { name: newPromptName, id: newPrompt.id, type: 'private' }, + ]); } - onSelectPrompt(newPrompt.name, newPrompt.id, newPrompt.type); - setNewPromptName(newPrompt.name); + onSelectPrompt(newPromptName, newPrompt.id, newPromptContent); + setNewPromptName(newPromptName); } catch (error) { console.error(error); }