gen_ai_hub.orchestration.models.document_grounding module

class gen_ai_hub.orchestration.models.document_grounding.GroundingType(*values)

Bases: str, Enum

Enumerates supported grounding types.

DOCUMENT_GROUNDING_SERVICE = 'document_grounding_service'
class gen_ai_hub.orchestration.models.document_grounding.DataRepositoryType(*values)

Bases: str, Enum

Enumerates data repository types.

VECTOR = 'vector'
URL = 'help.sap.com'
class gen_ai_hub.orchestration.models.document_grounding.DocumentMetadata(key: str, value: List[str], select_mode: List[str] = None)

Bases: JSONSerializable

Restrict documents considered during search to those annotated with the given metadata.

__init__(key: str, value: List[str], select_mode: List[str] = None)

Initializes the DocumentMetadata instance.

Parameters:
  • key (str) – The key for the metadata.

  • value (List[str]) – The list of values for the metadata.

  • select_mode (List[str], optional) – Select mode for search filters.

to_dict()

Converts the DocumentMetadata instance to a dictionary representation.

Returns:

Dictionary representation of the DocumentMetadata.

Return type:

dict

class gen_ai_hub.orchestration.models.document_grounding.GroundingFilterSearch(max_chunk_count: int = None, max_document_count: int = None)

Bases: JSONSerializable

Search configuration for the data repository.

__init__(max_chunk_count: int = None, max_document_count: int = None)

Initializes the GroundingFilterSearch instance.

Parameters:
  • max_chunk_count (int, optional) – maximum number of chunks > 0 to return, defaults to None

  • max_document_count (int, optional) – Maximum number of documents > 0 to return. Only supports ‘vector’ dataRepositoryType. Cannot be used with ‘maxChunkCount’. If maxDocumentCount is given, then only one chunk per document is returned, defaults to None

Raises:

ValueError – If both max_chunk_count and max_document_count are set.

to_dict()

Converts the GroundingFilterSearch instance to a dictionary representation.

Returns:

Dictionary representation of the GroundingFilterSearch.

Return type:

dict

class gen_ai_hub.orchestration.models.document_grounding.DocumentGroundingFilter(id: str, data_repository_type: str, search_config: GroundingFilterSearch = None, data_repositories: List[str] = None, data_repository_metadata: List[Dict[str, Any]] = None, document_metadata: List[DocumentMetadata] = None, chunk_metadata: List[Dict[str, Any]] = None)

Bases: JSONSerializable

Module for configuring document grounding filters.

__init__(id: str, data_repository_type: str, search_config: GroundingFilterSearch = None, data_repositories: List[str] = None, data_repository_metadata: List[Dict[str, Any]] = None, document_metadata: List[DocumentMetadata] = None, chunk_metadata: List[Dict[str, Any]] = None)

Initializes the DocumentGroundingFilter instance.

Parameters:
  • id (str) – The unique identifier for the grounding filter.

  • data_repository_type (str) – Only include DataRepositories with the given type: ‘vector’ or ‘url’ of website supporting elastic search.

  • search_config (GroundingFilterSearch, optional) – GroundingFilterSearchConfiguration object, defaults to None

  • data_repositories (List[str], optional) – list of data repositories to search. Specify [‘*’] to search across all DataRepositories or give a specific list of DataRepository ids, defaults to None

  • data_repository_metadata (List[Dict[str, Any]], optional) – The metadata for the data repository, Restrict DataRepositories considered during search to those annotated with the given metadata. Useful when combined with dataRepositories=[‘*’], defaults to None

  • document_metadata (List[DocumentMetadata], optional) – DocumentMetadata object, defaults to None

  • chunk_metadata (List[Dict[str, Any]], optional) – Restrict chunks considered during search to those with the given metadata, defaults to None

to_dict()

Converts the DocumentGroundingFilter instance to a dictionary representation.

Returns:

Dictionary representation of the DocumentGroundingFilter.

Return type:

dict

class gen_ai_hub.orchestration.models.document_grounding.DocumentGrounding(input_params: List[str], output_param: str, filters: List[DocumentGroundingFilter] = None, metadata_params: List[str] = None)

Bases: JSONSerializable

defines the detailed configuration for the Grounding module.

__init__(input_params: List[str], output_param: str, filters: List[DocumentGroundingFilter] = None, metadata_params: List[str] = None)

Initializes the DocumentGrounding instance.

Parameters:
  • input_params (List[str]) – The list of input parameters used for grounding input questions.

  • output_param (str) – Parameter name used for grounding output.

  • filters (List[DocumentGroundingFilter], optional) – List of DocumentGroundingFilter objects, defaults to None

  • metadata_params (List[str], optional) – Parameter name used for specifying metadata parameters, defaults to None

to_dict()

Converts the DocumentGrounding instance to a dictionary representation.

Returns:

Dictionary representation of the DocumentGrounding.

Return type:

dict

class gen_ai_hub.orchestration.models.document_grounding.GroundingModule(type: str, config: DocumentGrounding)

Bases: JSONSerializable

Module for managing and applying grounding aka RAG configurations.

__init__(type: str, config: DocumentGrounding)

Initializes the GroundingModule instance.

Parameters:
  • type (str) – The type of the grounding module.

  • config (DocumentGrounding) – Configuration for the grounding module.

to_dict()

Converts the GroundingModule instance to a dictionary representation.

Returns:

Dictionary representation of the GroundingModule.

Return type:

dict