diff --git a/adr/0007-gen-package-split.md b/adr/0007-gen-package-split.md new file mode 100644 index 00000000..21da588e --- /dev/null +++ b/adr/0007-gen-package-split.md @@ -0,0 +1,99 @@ +# Coding Tools + +## Status + +agreed + +## Context + +The Python SDK currently consists of the `base`, `core` and `gen` packages. The `gen` package has a large dependency footprint, which includes by default, for example, `openai`, `pandas` and `langchain`. Users asked for packages with a smaller dependency footprint for their use cases. + +## Decision + +Option C. Split the `gen` package into separate PyPI packages for the individual services (for example `sap-ai-sdk-rpt`, `sap-ai-sdk-orchestration` and so on). The `sap-ai-sdk-gen` package itself will stay for backwards compatibility as a meta package that distributes the individual packages in the `gen_ai_hub` namespace. + +## Consequences + +- The dependency footprint of the new packages will be minimal. +- There is an effort in creating the new packages and updating CI and release pipelines. +- There will be no immediate breaking changes for current users because they can continue to use the `gen` package. +- Users will need to update import statements when they migrate to the new packages. + +## Appendix + +### Option A: Optional Dependencies + +Move heavy dependencies into named extras (continuing the current approach). + +Pros: + +- Very small and easy change +- Keeps the current strategy + +Cons: + +- Making dependencies optional is a breaking change +- There is no clear mapping between the service used by the customer and installation command (some services need optional dependencies, others do not) +- Approach differs from other SDKs +- Are unused optional dependencies correctly ignored by security scanners? Currently this is the case, but it may be a risk in the future + +Simple user example: + +- Installation: `pip install sap-ai-sdk-gen[openai]` +- Code snippet: + + ```python + from gen_ai_hub.proxy.native.openai import chat + chat.completions.create(model_name="gpt-5.4-nano", messages=[...]) + ``` + +### Option B: Namespace Packages + +Distribute individual packages (`sap-ai-sdk-rpt`, `sap-ai-sdk-orchestration`, ...) but in the existing `gen_ai_hub` namespace. This keeps the current import paths and the `gen` meta package is for only assembling all package dependencies. See [this PoC](https://github.com/SAP/ai-sdk-python/tree/namespace-packages-poc) for more details. + +Pros: + +- Import paths in new packages stay as before (export for some re-exports, see below) +- Meta-package contains no code, just gathers all individual packages +- Independent releases and version numbers per package + +Cons: + +- Individual release pipeline per package (higher CI and release effort) +- To enable re-exports on the `gen` and `proxy` level, a [hack](https://github.com/SAP/ai-sdk-python/blob/namespace-packages-poc/packages/gen/gen_ai_hub/__init__.py) is needed. In a clean namespace package, these re-exports are not possible because `gen` and `proxy` are namespaces without an `init.py`. NOTE: There is no guarantee that this hack is working properly. + +Simple user example: + +- Installation: `pip install sap-ai-sdk-openai` +- Code snippet: + + ```python + from gen_ai_hub.proxy.native.openai import chat + chat.completions.create(model_name="gpt-5.4-nano", messages=[...]) + ``` + +### Option C: Separate Packages + +Distribute separate packages for the different services, each in it's own namespace. The `gen` meta package aliases the packages under the `gen_ai_hub` namespace for full backwards compatibility. See [this PoC](https://github.com/SAP/ai-sdk-python/tree/separate-packages-poc) for more details. + +Pros: + +- Mirrors existing `core` and `base` split and the approach in the other SDKs +- Independent releases and version numbers per package +- Less complex configuration compared to namespace packages (just a bunch of standard Python packages). Also more flexibility cause the old `gen` package and the new packages don't all write in the `gen_ai_hub` namespace. +- Install and import name are aligned. + +Cons: + +- Individual release pipeline per package (higher CI and release effort) +- More migration effort for users compared to option B (switch to new packages needs change of import statements) + +Simple user example: + +- Installation: `pip install sap-ai-sdk-openai` +- Code snippet: + + ```python + from sap_ai_sdk_openai import chat + chat.completions.create(model_name="gpt-5.4-nano", messages=[...]) + ```