@@ -280,6 +280,176 @@ def create(self, dataset_type: str = "DATA") -> Dict[str, Any]:
280280 result : Dict [str , Any ] = response .get ("data" , {}).get ("addDataset" , {})
281281 return result
282282
283+ def get_prompt_by_id (self , dataset_id : str ) -> Dict [str , Any ]:
284+ """
285+ Get a prompt dataset by ID with prompt-specific metadata.
286+
287+ Args:
288+ dataset_id: UUID of the prompt dataset
289+
290+ Returns:
291+ Dictionary containing prompt dataset information including prompt metadata
292+ """
293+ query = """
294+ query GetPromptDataset($id: UUID!) {
295+ dataset(id: $id) {
296+ id
297+ title
298+ description
299+ status
300+ accessType
301+ license
302+ datasetType
303+ createdAt
304+ updatedAt
305+ organization {
306+ id
307+ name
308+ description
309+ }
310+ tags {
311+ id
312+ value
313+ }
314+ sectors {
315+ id
316+ name
317+ }
318+ geographies {
319+ id
320+ name
321+ }
322+ resources {
323+ id
324+ title
325+ description
326+ fileDetails
327+ schema
328+ createdAt
329+ updatedAt
330+ promptFormat
331+ hasSystemPrompt
332+ hasExampleResponses
333+ avgPromptLength
334+ promptCount
335+ }
336+ promptMetadata {
337+ taskType
338+ targetLanguages
339+ domain
340+ targetModelTypes
341+
342+ }
343+ }
344+ }
345+ """
346+
347+ response = self .post (
348+ "/api/graphql" ,
349+ json_data = {
350+ "query" : query ,
351+ "variables" : {"id" : dataset_id },
352+ },
353+ )
354+
355+ if "errors" in response :
356+ from dataspace_sdk .exceptions import DataSpaceAPIError
357+
358+ raise DataSpaceAPIError (f"GraphQL error: { response ['errors' ]} " )
359+
360+ result : Dict [str , Any ] = response .get ("data" , {}).get ("dataset" , {})
361+ return result
362+
363+ def list_prompts (
364+ self ,
365+ status : Optional [str ] = None ,
366+ task_type : Optional [str ] = None ,
367+ domain : Optional [str ] = None ,
368+ organization_id : Optional [str ] = None ,
369+ limit : int = 10 ,
370+ offset : int = 0 ,
371+ ) -> Any :
372+ """
373+ List prompt datasets with pagination using GraphQL.
374+
375+ Args:
376+ status: Filter by status (DRAFT, PUBLISHED, etc.)
377+ task_type: Filter by prompt task type
378+ domain: Filter by domain
379+ organization_id: Filter by organization
380+ limit: Number of results to return
381+ offset: Number of results to skip
382+
383+ Returns:
384+ List of prompt datasets
385+ """
386+ query = """
387+ query ListPromptDatasets($filters: DatasetFilter, $pagination: OffsetPaginationInput) {
388+ datasets(filters: $filters, pagination: $pagination) {
389+ id
390+ title
391+ description
392+ status
393+ accessType
394+ datasetType
395+ createdAt
396+ updatedAt
397+ organization {
398+ id
399+ name
400+ }
401+ tags {
402+ id
403+ value
404+ }
405+ promptMetadata {
406+ taskType
407+ targetLanguages
408+ domain
409+ targetModelTypes
410+
411+ }
412+ resources {
413+ id
414+ title
415+ fileDetails
416+ promptFormat
417+ hasSystemPrompt
418+ hasExampleResponses
419+ promptCount
420+ }
421+ }
422+ }
423+ """
424+
425+ filters : Dict [str , Any ] = {"datasetType" : "PROMPT" }
426+ if status :
427+ filters ["status" ] = status
428+ if organization_id :
429+ filters ["organization" ] = {"id" : {"exact" : organization_id }}
430+
431+ variables : Dict [str , Any ] = {
432+ "pagination" : {"limit" : limit , "offset" : offset },
433+ "filters" : filters ,
434+ }
435+
436+ response = self .post (
437+ "/api/graphql" ,
438+ json_data = {
439+ "query" : query ,
440+ "variables" : variables ,
441+ },
442+ )
443+
444+ if "errors" in response :
445+ from dataspace_sdk .exceptions import DataSpaceAPIError
446+
447+ raise DataSpaceAPIError (f"GraphQL error: { response ['errors' ]} " )
448+
449+ data = response .get ("data" , {})
450+ datasets_result : Any = data .get ("datasets" , []) if isinstance (data , dict ) else []
451+ return datasets_result
452+
283453 def search_prompts (
284454 self ,
285455 query : Optional [str ] = None ,
0 commit comments