Add architecture files for cds-feature-ai-core, cds-feature-recommendations#111
Add architecture files for cds-feature-ai-core, cds-feature-recommendations#111lisajulia wants to merge 5 commits into
Conversation
SummaryThe following content is AI-generated and provides a summary of the pull request: Add Architecture Documents and Improve READMEsDocumentation📚 Added detailed architecture documentation for Changes
PR Bot InformationVersion:
|
There was a problem hiding this comment.
Two issues found: a broken relative link in cds-feature-recommendations/docs/architecture.md that points to a non-existent path, and a double-article typo ("an the") in cds-starter-ai/README.md. Both are straightforward to fix with the suggested corrections.
PR Bot Information
Version: 1.26.14
- LLM:
anthropic--claude-4.6-sonnet - File Content Strategy: Full file content
- Event Trigger:
pull_request.opened - Correlation ID:
7f159260-792f-11f1-90a0-17a3f9ca90e6
138c964 to
a355097
Compare
a355097 to
415193e
Compare
|
In any case: I suggest to wait for @agoerler's review of this before merging 👨💻 |
Co-authored-by: Marvin L <marvin.lindner@sap.com> Signed-off-by: Lisa Julia Nebel <lisajuliafog@yahoo.de>
|
@Schmarvinius: Thanks! |
agoerler
left a comment
There was a problem hiding this comment.
Hi @lisajulia, this is very helpful :-). I wish I had this overview right from the start.
Please consider to add a link from the readme files to the architecture files.
Intermediate feedback. I only have started to look at the CoreAI-part ...
|
|
||
| ## Purpose | ||
|
|
||
| Automatically injects AI-powered field recommendations from the SAP RPT-1 tabular prediction foundation model into Fiori Elements OData responses for draft-enabled entities. Zero application code required. |
| | [`cds-feature-ai-core`](../../cds-feature-ai-core/README.md) | Provides the `AICore` CDS service and `AICoreService` API used to resolve the resource group, deployment ID, and inference `ApiClient` for the RPT-1 model. Recommendations cannot function without an active AI Core connection. | | ||
| | `@cap-js/ai` (Node.js CDS plugin) | At CDS build time, the plugin adds the `SAP_Recommendations` navigation property to draft-enabled entities that have value-list fields. Without this (or a manual CDS extension), predictions are computed but not serialized in OData responses. | | ||
| | `com.sap.ai.sdk.foundationmodels:sap-rpt` (SAP AI SDK) | Provides the RPT-1 model client used to call the `/predict` endpoint. | | ||
| | `com.github.ben-manes.caffeine:caffeine` | Thread-safe in-process caching for the per-tenant entity skip cache (10k max, no TTL). | |
There was a problem hiding this comment.
I think here for this document it's perfect to describe the current state.
As you have a dependency to cds-services-utils you could consider to rather use com.sap.cds.services.utils.TenantAwareCache, which would free the plugin from all concerns wrt. tenant-specific cache invalidation.
Please add a section with left-overs/todos/blis/...
|
|
||
| No dedicated CDS model file — the plugin relies on the `AICore` service model provided by `cds-feature-ai-core`, and on the `SAP_Recommendations` navigation property injected by the `@cap-js/ai` Node.js plugin (or added manually by the application). | ||
|
|
||
| The Node plugin will automatically detect fields annotated with a value list, see [`README`](../README.md#enabling-recommendations). |
There was a problem hiding this comment.
annotated with a value list
please quote the annotation name although you link to the read.me
| ### Public API / Handlers | ||
|
|
||
| No Java API — the plugin is entirely annotation-driven. Extend or annotate your CDS model to control which fields receive recommendations, see [`README`](../README.md#enabling-recommendations). | ||
| Currently, it is not possible to hook into the recommendation result from application code to observe the injected output, nor to override the inference call itself ([#110](https://github.com/cap-java/cds-ai/issues/110)). |
There was a problem hiding this comment.
Please move or add this to a BLIs/TODOs/... section
I think a CAPish/Calesi-ish approach would to introduce a RecomendationService. A default implementation would use RPT-1. A mock implementation could generate something random.
You could handle the RecomendationService on-event to provide your own implementation. Or in an after-handler fine-tune the result.
| | `RptModelSpec` | Static factory for the `ModelDeploymentSpec` targeting `sap-rpt-1-small`; used as the cache key for deployment resolution | | ||
| | `RptInferenceClient` | Calls RPT-1 `/predict` endpoint; handles the synthetic `SAP_RECOMMENDATIONS_ID` index column for composite/non-string keys | | ||
| | `RecommendationResultParser` | Type-coerces RPT-1 string output back to CDS primitive types; resolves `@Common.Text` descriptions from the database | | ||
| | `RecommendationModelChangedHandler` | `@On(EVENT_MODEL_CHANGED)` — invalidates per-tenant entity cache on MTX model upgrade | |
There was a problem hiding this comment.
I think, later we can use the TenantAwareCache instead.
| #### Recommendation Pipeline (OData GET on draft entity) | ||
|
|
||
| ```mermaid | ||
| flowchart TD |
There was a problem hiding this comment.
would be nice to have swim lanes for
- app server
- AICore/RPT-1
- the database
(but I am afraid the flowchart diagram does not support swim lanes)
|
|
||
| ## Purpose | ||
|
|
||
| Bridges CAP Java to SAP AI Core's management and inference REST APIs, providing resource group management, deployment lifecycle, and inference client resolution as a standard CAP `RemoteService`. At the time of writing, `com.sap.ai.sdk:ai-core` offered no CAP integration — only raw REST API clients — so this plugin fills that gap. |
There was a problem hiding this comment.
as a standard CAP
RemoteService
"as a CAP service"
A remote service bridges to a RESTish remote service that somehow understands CRUD operations
|
|
||
| | Dependency | Why | | ||
| |---|---| | ||
| | `com.sap.ai.sdk:ai-core` (SAP AI SDK) | Provides the generated `DeploymentApi`, `ConfigurationApi`, `ResourceGroupApi`, and `ApiClient` types used to call the AI Core REST API. The plugin wraps these behind CDS events so callers never deal with the SDK directly. | |
There was a problem hiding this comment.
| | `com.sap.ai.sdk:ai-core` (SAP AI SDK) | Provides the generated `DeploymentApi`, `ConfigurationApi`, `ResourceGroupApi`, and `ApiClient` types used to call the AI Core REST API. The plugin wraps these behind CDS events so callers never deal with the SDK directly. | | |
| | `com.sap.ai.sdk:ai-core` (SAP AI SDK) | Provides the generated `DeploymentApi`, `ConfigurationApi`, `ResourceGroupApi`, and `ApiClient` types used to call the AI Core REST API. The plugin wraps these behind CDS events so callers never deal with the AI SDK directly. | |
| // Events: | ||
| event resourceGroup // in: (optional: tenantId — falls back to UserInfo.getTenant() from request context) → out: resourceGroupId | ||
| event deploymentId // in: resourceGroupId + ModelDeploymentSpec → out: deploymentId | ||
| event inferenceClient // in: resourceGroupId + deploymentId → out: ApiClient |
There was a problem hiding this comment.
I don't find these "events" in cds-feature-ai-core/src/main/resources/cds/com.sap.cds/ai/index.cds.
| ``` | ||
|
|
||
| #### Inference Client Resolution | ||
|
|
There was a problem hiding this comment.
Please add a textual description of which problem you are solving here, why and how.
Uh oh!
There was an error while loading. Please reload this page.