Skip to content

feat: rpt client updated to 1.6 - #174

Open
yamaceay wants to merge 6 commits into
mainfrom
upgrade-rpt-clients
Open

yamaceay wants to merge 6 commits into
mainfrom
upgrade-rpt-clients

Conversation

@yamaceay

@yamaceay yamaceay commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Context

Closes SAP/ai-sdk-python-backlog#17.

What this PR does and why it is needed

This PR aims to upgrade the RPT Client logic on the SDK side for the newest version 1.6, grouped in 6 significant sections:

  1. components.schemas.SchemaFieldConfig from spec: We add the missing data types to the dtype field in the current DataType
  2. components.schemas.PredictionResult from spec: confidence_interval is added into Predictionitem (current implementation). And also, we add minimum / maximum bounds to confidence as in 1.6.
  3. components.schemas.PredictionConfig from spec: explanations are added to PredictionConfig response, so that it is not silently discarded.
  4. context_mode is added to PredictionConfig and ResponseMetadata (1.6 specific issue).
  5. components.schemas.TargetColumnConfig from spec: top_k is added to TargetColumn. Second of all, prediction_placeholder is casted to be nullable: as of now >=1.5 allows null or numeric as placeholders, while current model enforces str. Corresponding link
  6. components.schemas.{ExplanationConfig / ExplanationResult} models didn't exist before, so they are implemented from scratch.

Definition of Done

  • Code is tested (Unit, Integration, E2E)
  • Error handling created / updated & covered by the tests above
  • Documentation updated
    • Only Public APIs are allowed to be used in documentation/tutorials/sample code
  • (Optional) Aligned changes with the JS/TS and Java SDK
  • (Optional) Release notes updated -->

@yamaceay yamaceay changed the title rpt client updated to 1.6 feat: rpt client updated to 1.6 Oct 2, 2026

@alpkom alpkom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you adjust the RPT mock responses in the tests/mock.py to reflect the API changes?
And maybe adjust the integration_tests as well, in order to make use of the new attributes in the API?

@yamaceay

yamaceay commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Could you adjust the RPT mock responses in the tests/mock.py to reflect the API changes? And maybe adjust the integration_tests as well, in order to make use of the new attributes in the API?

Current tests are failing partly because of the optional vs. required behavior of prediction_payload, fixing it now

@alpkom

alpkom commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Could you adjust the RPT mock responses in the tests/mock.py to reflect the API changes? And maybe adjust the integration_tests as well, in order to make use of the new attributes in the API?

Current tests are failing partly because of the optional vs. required behavior of prediction_payload, fixing it now

It's not only about fixing tests. We need to adjust the mock to reflect the backend behavior properly.
And we need to adjust/extend the integration tests to test the new features/attributes in the API, as well.

@yamaceay
yamaceay requested a review from alpkom October 2, 2026 09:44
@yamaceay

yamaceay commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

In the current test environment, there is no such RPT-1.6 deployment, and we need to deploy it for the tests to work


name: str
prediction_placeholder: str = "[PREDICT]"
prediction_placeholder: Optional[Union[str, int, float]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mandatory field, not optional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"TargetColumnConfig": {
    ...,
    "properties": {
        ..., "prediction_placeholder": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "number"
                },
                {
                    "type": "null"
                }
            ],
            "description": "The prediction placeholder in any column for which to predict a value. The model will predict a value for all table cells containing this value.",
            "title": "Prediction Placeholder"
        }, ..., "required": [
           "name",
           "prediction_placeholder"
        ], ...

According to this spec, yes, it is required. But still, it needs to be a nullable number | string union. Is it wrong to set optional here?

Comment thread packages/gen/integration_tests/constants.py Outdated
import unittest

from integration_tests.constants import SAP_RPT_1_SMALL_TEST_MODEL
from integration_tests.constants import SAP_RPT_1_6_SMALL_TEST_MODEL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not only test against 1.6.
The full set of tests should run against 1.6, but we should have 1 happy path test for both 1.0 and 1.5.

yield

@contextmanager
def sap_rpt_moke_response_code_0_with_explanations(url: str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type at "moke". It was probably a typo in the name of the already existing function.

Comment thread sample-code/sample_code/sap_rpt.py Outdated
self.assertIsNone(response.explanations)

def test_response_with_explanations(self):
from tests.mock import RPT_RESPONSE_CODE_0_WITH_EXPLANATIONS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the inline import?

self.assertEqual(response.metadata.context_mode, "default")

def test_response_explanations_none_by_default(self):
from tests.mock import RPT_RESPONSE_CODE_0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the inline import?

self.assertIsNone(result.top_relevant_context_rows)

def test_response_metadata_includes_context_mode(self):
from tests.mock import RPT_RESPONSE_CODE_0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the inline import?

with sap_rpt_moke_response_code_2(url_mock.return_value):
with self.assertRaises(RPTException) as err:
self.client.predict(body=request_by_row_dict, model_name="sap-rpt-1-small")
self.client.predict(body=request_by_row_dict, model_name="sap-rpt-1.6-small")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the model name here doesn't matter. What matters is the mock function used with the "with" clause.

with patch.object(RPTClient, "_get_url", return_value=mock_url) as url_mock:
with sap_rpt_moke_response_code_0(url_mock.return_value):
response = await self.client.apredict(body=request_by_row_dict, model_name="sap-rpt-1-small")
response = await self.client.apredict(body=request_by_row_dict, model_name="sap-rpt-1.6-small")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the model name here doesn't matter. What matters is the mock function used with the "with" clause.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants