@@ -142,3 +142,59 @@ async def get_workspace_messages(workspace_name: str) -> List[Conversation]:
142
142
return await dashboard .parse_messages_in_conversations (prompts_outputs )
143
143
except Exception :
144
144
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 .SystemPrompt :
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
+ if ws .system_prompt is None :
162
+ return v1_models .SystemPrompt (prompt = "" )
163
+
164
+ return v1_models .SystemPrompt (prompt = ws .system_prompt )
165
+
166
+
167
+ @v1 .put (
168
+ "/workspaces/{workspace_name}/system-prompt" ,
169
+ tags = ["Workspaces" ],
170
+ generate_unique_id_function = uniq_name ,
171
+ status_code = 204 ,
172
+ )
173
+ async def set_workspace_system_prompt (workspace_name : str , request : v1_models .SystemPrompt ):
174
+ try :
175
+ # This already checks if the workspace exists
176
+ await wscrud .update_workspace_system_prompt (workspace_name , [request .prompt ])
177
+ except crud .WorkspaceDoesNotExistError :
178
+ raise HTTPException (status_code = 404 , detail = "Workspace does not exist" )
179
+ except Exception :
180
+ raise HTTPException (status_code = 500 , detail = "Internal server error" )
181
+
182
+ return Response (status_code = 204 )
183
+
184
+
185
+ @v1 .delete (
186
+ "/workspaces/{workspace_name}/system-prompt" ,
187
+ tags = ["Workspaces" ],
188
+ generate_unique_id_function = uniq_name ,
189
+ status_code = 204 ,
190
+ )
191
+ async def delete_workspace_system_prompt (workspace_name : str ):
192
+ try :
193
+ # This already checks if the workspace exists
194
+ await wscrud .update_workspace_system_prompt (workspace_name , [])
195
+ except crud .WorkspaceDoesNotExistError :
196
+ raise HTTPException (status_code = 404 , detail = "Workspace does not exist" )
197
+ except Exception :
198
+ raise HTTPException (status_code = 500 , detail = "Internal server error" )
199
+
200
+ return Response (status_code = 204 )
0 commit comments