gen_ai_hub.proxy.native.sap.models module¶
- class gen_ai_hub.proxy.native.sap.models.TargetColumn(*, name: str, prediction_placeholder: str = '[PREDICT]', task_type: Literal['classification', 'regression'] | None = None)¶
Bases:
BaseModelRepresents a target column in data.
- Parameters:
name (str) – Name of the target column.
prediction_placeholder (str) – Placeholder string denoting where predictions will be inserted. Defaults to
"[PREDICT]".task_type (Optional[Literal["classification", "regression"]]) – Task type of the target column. One of
"classification"or"regression". Defaults toNone.
- name: str¶
- prediction_placeholder: str¶
- task_type: Literal['classification', 'regression'] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.PredictionConfig(*, target_columns: list[TargetColumn])¶
Bases:
BaseModelThe configuration object specifying which columns to predict
- Parameters:
target_columns (list[TargetColumn]) – List of target columns to predict.
- target_columns: list[TargetColumn]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.DataType(*, dtype: Literal['string', 'numeric', 'date'])¶
Bases:
BaseModelSchema definition for a column.
- Parameters:
dtype (Literal["string", "numeric", "date"]) – The data type of the column.
- dtype: Literal['string', 'numeric', 'date']¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.RPTRequest(*, prediction_config: PredictionConfig, index_column: str | None = None, rows: list[dict] | None = None, columns: dict[str, list] | None = None, data_schema: dict[str, DataType] | None = None, parse_data_types: bool = True)¶
Bases:
BaseModelRequest model for predictions.
Provide exactly one of
rowsorcolumns.- Parameters:
prediction_config (PredictionConfig) – Configuration describing what to predict.
index_column (Optional[str]) – Name of a column used to identify the row. This column is not used as an input feature and may be returned in the response objects.
rows (Optional[list[dict]]) – Array of objects representing table rows (both context and query rows).
columns (Optional[dict[str, list]]) – Mapping from column name to array of column values.
data_schema (Optional[dict[str, DataType]]) – Schema definition for all columns, e.g.
{"columnA": {"dtype": "string"}, "columnB": {"dtype": "numeric"}}.parse_data_types (bool) – Relevant when
data_schemais not provided. Whether to parse data types (e.g., interpret strings as numbers or dates). Defaults toTrue.
- prediction_config: PredictionConfig¶
- index_column: str | None¶
- rows: list[dict] | None¶
- columns: dict[str, list] | None¶
- parse_data_types: bool¶
- validate_rows_xor_columns()¶
Validate that exactly one of
rowsorcolumnsis provided.- Raises:
ValueError – If neither or both of
rowsandcolumnsare provided.- Returns:
The validated request instance.
- Return type:
- model_dump(**kwargs)¶
Serialize the model to a dictionary.
Ensures the non-provided alternative (
rowsorcolumns) is omitted from the dump and thatNonevalues are excluded.- Parameters:
kwargs (Any) – Keyword arguments forwarded to
pydantic.BaseModel.model_dump.- Returns:
Serialized dictionary representation of the model.
- Return type:
dict
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.ResponseMetadata(*, num_rows: int, num_columns: int, num_predictions: int, num_query_rows: int)¶
Bases:
BaseModelResponse metadata.
- Parameters:
num_rows (int) – Total number of input rows.
num_columns (int) – Total number of input columns.
num_predictions (int) – Number of table cells containing the specified placeholder values, summed over all target columns.
num_query_rows (int) – Number of query rows for which a prediction was made.
- num_rows: int¶
- num_columns: int¶
- num_predictions: int¶
- num_query_rows: int¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.ResponseStatus(*, code: int, message: str)¶
Bases:
BaseModelStatus information for a prediction request.
- Parameters:
code (int) – Numeric status code.
message (str) – Status message.
- code: int¶
- message: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.PredictionItem(*, prediction: str | float, confidence: float | None = None)¶
Bases:
BaseModelSingle prediction result.
- Parameters:
prediction (Union[str, float]) – The predicted value.
confidence (Optional[float]) – Confidence score for classification tasks. Defaults to
None.
- prediction: str | float¶
- confidence: float | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.Prediction(root: RootModelRootType = PydanticUndefined)¶
Bases:
RootModel[dict[str, Union[list[PredictionItem], Any]]]Container for prediction results keyed by target column name.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: RootModelRootType¶
- class gen_ai_hub.proxy.native.sap.models.RPTResponse(*, id: str, status: ResponseStatus, predictions: list[Prediction], metadata: ResponseMetadata)¶
Bases:
BaseModelResponse model for an RPT request.
- Parameters:
id (str) – Unique identifier for the response.
status (ResponseStatus) – Status describing the outcome of the request.
predictions (list[Prediction]) – Prediction data returned by the service.
metadata (ResponseMetadata) – Metadata about the request/response.
- id: str¶
- status: ResponseStatus¶
- predictions: list[Prediction]¶
- metadata: ResponseMetadata¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.proxy.native.sap.models.ErrorResponseDetails(*, loc: list, msg: str, type: str)¶
Bases:
BaseModelDetails of an error response.
- Parameters:
loc (list) – Location in the request where the error occurred.
msg (str) – Human-readable error message.
type (str) – Error category/type.
- loc: list¶
- msg: str¶
- type: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- exception gen_ai_hub.proxy.native.sap.models.RPTException(status: ResponseStatus, detail: list[ErrorResponseDetails] | None = None)¶
Bases:
ExceptionException representing an error response from the RPT service.
- Parameters:
status (ResponseStatus) – Status indicating the error category/type.
detail (Optional[list[ErrorResponseDetails]]) – Optional list of additional error details.
- __init__(status: ResponseStatus, detail: list[ErrorResponseDetails] | None = None)¶