@@ -142,3 +142,56 @@ async def get_workspace_messages(workspace_name: str) -> List[Conversation]:
142142 return await dashboard .parse_messages_in_conversations (prompts_outputs )
143143 except Exception :
144144 raise HTTPException (status_code = 500 , detail = "Internal server error" )
145+
146+
147+ @v1 .get (
148+ "/workspaces/{workspace_name}/system-prompt" ,
149+ tags = ["Workspaces" ],
150+ generate_unique_id_function = uniq_name ,
151+ )
152+ async def get_workspace_system_prompt (workspace_name : str ) -> v1_models .Workspace :
153+ """Get the system prompt for a workspace."""
154+ try :
155+ ws = await wscrud .get_workspace_by_name (workspace_name )
156+ except crud .WorkspaceDoesNotExistError :
157+ raise HTTPException (status_code = 404 , detail = "Workspace does not exist" )
158+ except Exception :
159+ raise HTTPException (status_code = 500 , detail = "Internal server error" )
160+
161+ return v1_models .SystemPrompt .from_db_workspace (ws )
162+
163+
164+ @v1 .put (
165+ "/workspaces/{workspace_name}/system-prompt" ,
166+ tags = ["Workspaces" ],
167+ generate_unique_id_function = uniq_name ,
168+ status_code = 204 ,
169+ )
170+ async def set_workspace_system_prompt (workspace_name : str , request : v1_models .SystemPrompt ):
171+ try :
172+ # This already checks if the workspace exists
173+ await wscrud .update_workspace_system_prompt (workspace_name , list (request .prompt ))
174+ except crud .WorkspaceDoesNotExistError :
175+ raise HTTPException (status_code = 404 , detail = "Workspace does not exist" )
176+ except Exception :
177+ raise HTTPException (status_code = 500 , detail = "Internal server error" )
178+
179+ return Response (status_code = 204 )
180+
181+
182+ @v1 .delete (
183+ "/workspaces/{workspace_name}/system-prompt" ,
184+ tags = ["Workspaces" ],
185+ generate_unique_id_function = uniq_name ,
186+ status_code = 204 ,
187+ )
188+ async def delete_workspace_system_prompt (workspace_name : str ):
189+ try :
190+ # This already checks if the workspace exists
191+ await wscrud .update_workspace_system_prompt (workspace_name , [])
192+ except crud .WorkspaceDoesNotExistError :
193+ raise HTTPException (status_code = 404 , detail = "Workspace does not exist" )
194+ except Exception :
195+ raise HTTPException (status_code = 500 , detail = "Internal server error" )
196+
197+ return Response (status_code = 204 )
0 commit comments