gen_ai_hub.orchestration_v2.models.document_grounding module

Module for defining document grounding configurations.

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

Bases: str, Enum

Enumerates supported grounding types.

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

Bases: str, Enum

Enumerates data repository types.

VECTOR = 'vector'
URL = 'help.sap.com'
class gen_ai_hub.orchestration_v2.models.document_grounding.DocumentGroundingFilter(*, id: str | None = None, data_repository_type: DataRepositoryType | Literal['vector', 'help.sap.com'], search_config: GroundingSearchConfig | None = None, data_repositories: List[str] | None = None, data_repository_metadata: List[KeyValueListPair] | None = None, document_metadata: List[DocumentMetadataKeyValueListPairs] | None = None, chunk_metadata: List[KeyValueListPair] | None = None)

Bases: ABCBaseModel

Module for configuring document grounding filters.

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

  • search_config – GroundingSearchConfig object.

  • data_repository_type – Only include DataRepositories with the given type: vector, help.sap.com.

  • data_repositories – list of data repositories to search. Specify [‘*’] to search across all DataRepositories or give a specific list of DataRepository ids.

  • data_repository_metadata – The metadata for the data repository. Restrict DataRepositories considered during search to those annotated with the given metadata. Useful when combined with dataRepositories=[‘*’]

  • document_metadata – DocumentMetadata object.

  • chunk_metadata – Restrict chunks considered during search to those with the given metadata.

id: str | None
data_repository_type: DataRepositoryType | Literal['vector', 'help.sap.com']
search_config: GroundingSearchConfig | None
data_repositories: List[str] | None
data_repository_metadata: List[KeyValueListPair] | None
document_metadata: List[DocumentMetadataKeyValueListPairs] | None
chunk_metadata: List[KeyValueListPair] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.document_grounding.DocumentGroundingPlaceholders(*, input: Annotated[List[str], MinLen(min_length=1)], output: str)

Bases: ABCBaseModel

input: The list of input parameters used for grounding input questions (minItems: 1). output: Parameter name used for grounding output.

input: List[str]
output: str
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.document_grounding.DocumentGroundingConfig(*, filters: List[DocumentGroundingFilter] | None = None, placeholders: DocumentGroundingPlaceholders, metadata_params: list[str] | None = None)

Bases: ABCBaseModel

defines the detailed configuration for the Grounding module.

Parameters:
  • filters – List of DocumentGroundingFilter objects.

  • placeholders – Placeholders to be used for grounding input questions and output.

  • metadata_params – Parameter name used for specifying metadata parameters.

filters: List[DocumentGroundingFilter] | None
placeholders: DocumentGroundingPlaceholders
metadata_params: list[str] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.document_grounding.GroundingModuleConfig(*, type: GroundingType = GroundingType.DOCUMENT_GROUNDING_SERVICE, config: DocumentGroundingConfig)

Bases: ABCBaseModel

Module for managing and applying grounding aka RAG configurations.

Parameters:
  • type – The type of the grounding module.

  • config – Configuration dictionary for the grounding module.

type: GroundingType
config: DocumentGroundingConfig
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.document_grounding.KeyValueListPair(*, key: str, value: List[str])

Bases: ABCBaseModel

key: str
value: List[str]
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.document_grounding.DocumentMetadataKeyValueListPairs(*, key: str, value: List[str], select_mode: List[Literal['ignoreIfKeyAbsent']] | None = None)

Bases: KeyValueListPair

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

Parameters:
  • key – The key for the metadata.

  • value – The list of values for the metadata.

  • select_mode – Select mode for search filters.

select_mode: List[Literal['ignoreIfKeyAbsent']] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

key: str
value: List[str]