Skip to content

feat: create more sample code - #150

Merged
OscarDDD merged 19 commits into
mainfrom
feat/sample-code
Sep 23, 2026
Merged

OscarDDD merged 19 commits into
mainfrom
feat/sample-code

Conversation

@OscarDDD

@OscarDDD OscarDDD commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Context

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

What this PR does and why it is needed

Adds sample code for document_grounding, sap_rpt, prompt_registry, and LangChain modules, and registers all new functions as FastAPI endpoints in server.py. All endpoints can be tested directly via the FastAPI server.

@OscarDDD OscarDDD changed the title Feat: create more sample code feat: create more sample code Sep 17, 2026
@OscarDDD
OscarDDD marked this pull request as ready for review September 17, 2026 16:00

@yamaceay yamaceay 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.

@OscarDDD Thanks for the sample codes! Just for my own understanding:

[q] I would like to know whether there is a correct, efficient way to verify whether the sample code works (without trying out visually). Would unit tests be a feasible option to test the behavior of all these code snippets?

Another question is:

[q] Do you think from a security vs. usability perspective it is feasible to have setup - cleanup functions (directly as decorators etc.) which deploy (& later teardown) the required models? The logic could look something like:

If the deployment already exists: Reuse the available deployment and don't teardown later.
If the deployment doesn't exist: Create a temporary deployment for the sample, then teardown after running the sample.

@mwien mwien 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.

Looks good! Just a few small comments

Comment thread sample-code/sample_code/server.py Outdated
Comment thread sample-code/sample_code/server.py Outdated
Comment thread sample-code/sample_code/sap_rpt.py Outdated
Comment thread sample-code/sample_code/prompt_registry.py Outdated
Comment thread sample-code/sample_code/langchain_openai.py Outdated
Comment thread sample-code/sample_code/grounding.py Outdated
@mwien

mwien commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@OscarDDD Thanks for the sample codes! Just for my own understanding:

[q] I would like to know whether there is a correct, efficient way to verify whether the sample code works (without trying out visually). Would unit tests be a feasible option to test the behavior of all these code snippets?

Another question is:

[q] Do you think from a security vs. usability perspective it is feasible to have setup - cleanup functions (directly as decorators etc.) which deploy (& later teardown) the required models? The logic could look something like:

If the deployment already exists: Reuse the available deployment and don't teardown later. If the deployment doesn't exist: Create a temporary deployment for the sample, then teardown after running the sample.

Re testing:

  • the sample code will likely be used for smoke tests later
  • good point re unit tests, we could think about adding those (outside of this PR), as far as I can tell the Java SDK has unit tests in the sample code and the JS one doesn't

Re decorators:
Imo the less magic we add, the more transparent the code examples... the code should prepare people to be able to write their own stuff with the SDK and I'd rather avoid everyone copying decorators because they assume that's strictly necessary.

@OscarDDD

OscarDDD commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@OscarDDD Thanks for the sample codes! Just for my own understanding:

[q] I would like to know whether there is a correct, efficient way to verify whether the sample code works (without trying out visually). Would unit tests be a feasible option to test the behavior of all these code snippets?

Another question is:

[q] Do you think from a security vs. usability perspective it is feasible to have setup - cleanup functions (directly as decorators etc.) which deploy (& later teardown) the required models? The logic could look something like:

If the deployment already exists: Reuse the available deployment and don't teardown later. If the deployment doesn't exist: Create a temporary deployment for the sample, then teardown after running the sample.

Regarding the unit tests:
I think it's good to have the unit tests. I'm currently following the JavaScript SDK repo as a reference, so tests haven't been added yet.

Regarding the decorators:
I'm considering whether it would make sense to introduce a setup.py or something similar down the line, to allow users to set up everything they need in one step.

@OscarDDD
OscarDDD requested a review from mwien September 22, 2026 09:12

@mwien mwien 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.

lgtm

@yamaceay yamaceay 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.

all questions answered

@OscarDDD
OscarDDD merged commit 5964349 into main Sep 23, 2026
15 checks passed
@OscarDDD
OscarDDD deleted the feat/sample-code branch September 23, 2026 10:56
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.

3 participants