Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions cds-feature-recommendations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ Or use the starter that bundles this with `cds-feature-ai-core`:
- An [SAP AI Core](https://help.sap.com/docs/sap-ai-core) service binding (see [`cds-feature-ai-core`](../cds-feature-ai-core/README.md))
- Entity must be **draft-enabled** (`@odata.draft.enabled`)
- At least one field annotated with a **value list**
- The `@cap-js/ai` CDS plugin must be installed (provides the model enhancement that adds `SAP_Recommendations` as a navigation property)
- The `SAP_Recommendations` navigation property must be added to the entities that should receive recommendations by
- either installing the `@cap-js/ai` CDS plugin (automatically provides the model enhancement that adds `SAP_Recommendations` as a navigation property)
- or adding the `SAP_Recommendations`property manually.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Typo: Missing space before property in the bullet point

SAP_Recommendationspropertyis missing a space between the backtick and the wordproperty`. This makes the sentence read awkwardly and the missing space may confuse readers skimming the text.

Consider adding the missing space.

Suggested change
- or adding the `SAP_Recommendations`property manually.
- or adding the `SAP_Recommendations` property manually.

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Without the `SAP_Recommendations` navigation property, the predictions will be computed but not serialized in OData responses.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clarity / Logic: The "Without the SAP_Recommendations navigation property" sentence is separated from the bullet list it belongs to

The indentation on line 46 ( Without the…) is not aligned with the - or adding… sub-bullet (which is indented with two spaces), so it reads as a new paragraph in most renderers rather than a continuation of the list. Additionally, the sentence is important context that should be clearly visible — consider either aligning it as a proper continuation line or moving it outside the bullet list entirely as a standalone note.

Suggested change
Without the `SAP_Recommendations` navigation property, the predictions will be computed but not serialized in OData responses.
- or adding the `SAP_Recommendations` property manually.
> **Note**: Without the `SAP_Recommendations` navigation property, the predictions will be computed but not serialized in OData responses.

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful


### CDS Plugin
#### CDS Plugin

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistency: The "CDS Plugin" and "Adding the SAP_Recommendations…" sections are headed with #### (h4), but they appear directly under a ### Prerequisites section — they should be #### subsections of ### Prerequisites, not peers of it. However, looking at the broader document structure, the "CDS Plugin" section was previously a ### (h3) heading and was downgraded to #### in this PR. The new manual-property section also uses ####. This is correct only if both sub-sections belong under ### Prerequisites; however the content (installation instructions) goes well beyond listing prerequisites and really belongs under ## Setup as ### siblings. This structural mismatch may confuse readers navigating the README.

Consider restoring "CDS Plugin" and "Adding the SAP_Recommendations navigation property manually" as ###-level headings directly under ## Setup, alongside ### Maven and ### Prerequisites.

Suggested change
#### CDS Plugin
### CDS Plugin

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful


Add `@cap-js/ai` to your project's `package.json`:

Expand All @@ -55,7 +58,7 @@ Add `@cap-js/ai` to your project's `package.json`:
}
```

Then run `npm install`. The plugin hooks into the CDS compiler and automatically adds the `SAP_Recommendations` navigation property to draft-enabled entities that have value-list fields. Without this plugin, predictions will be computed but not serialized in OData responses.
Then run `npm install`. The plugin hooks into the CDS compiler and automatically adds the `SAP_Recommendations` navigation property to draft-enabled entities that have value-list fields.

Since the Java module `cds-feature-ai-core` already provides the `AICore` service CDS model, disable the duplicate model from `@cap-js/ai` in your `.cdsrc.json`:

Expand All @@ -68,6 +71,41 @@ Since the Java module `cds-feature-ai-core` already provides the `AICore` servic
}
}
```
#### Adding the SAP_Recommendations navigation property manually

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formatting: Missing blank line before the new #### heading

The new #### Adding the SAP_Recommendations navigation property manually heading (line 74) immediately follows the closing fence of the JSON code block (line 73) with no blank line in between. In standard Markdown, headings should be preceded by a blank line to be reliably parsed as headings by all renderers and to improve readability.

Suggested change
#### Adding the SAP_Recommendations navigation property manually
#### Adding the SAP_Recommendations navigation property manually

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistency: The heading level for the new manual section should match the restored ### level of "CDS Plugin" (see comment on line 48). If both are kept as ####, they are structural siblings of each other, which is fine, but the heading change at line 48 from ### to #### without a matching parent ### heading makes the document hierarchy incorrect.

Suggested change
#### Adding the SAP_Recommendations navigation property manually
### Adding the SAP_Recommendations navigation property manually

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful


If you cannot use the CDS plugin, add the `SAP_Recommendations` navigation property directly in your CDS model. You need to:

1. **Define a `RecommendationItem_*` type** for each CDS primitive type used by your value-list fields. Each type must contain the four fixed fields shown below — only `RecommendedFieldValue` varies by type.
2. **Extend each target entity** with a `SAP_Recommendations` composition that has one entry per value-list field, using the field name as the property name and the matching `RecommendationItem_*` type.

The property names inside `SAP_Recommendations` must exactly match the field names on the entity (e.g. `genre_ID`, `author_ID`).

```cds
// Define one type per CDS primitive used by your value-list fields
type RecommendationItem_Integer {
RecommendedFieldValue : Integer;
RecommendedFieldDescription : String;
RecommendedFieldScoreValue : Decimal;
RecommendedFieldIsSuggestion: Boolean;
}

type RecommendationItem_UUID {
RecommendedFieldValue : UUID;
RecommendedFieldDescription : String;
RecommendedFieldScoreValue : Decimal;
RecommendedFieldIsSuggestion: Boolean;
}

// Extend your entity — one entry per value-list field
extend my.Books with {
SAP_Recommendations: Composition of one {
genre_ID : many RecommendationItem_Integer;
author_ID: many RecommendationItem_UUID;
}
}
```

See also the [SAP Fiori Elements – Recommendations documentation](https://help.sap.com/docs/SAPUI5/b2f662dd9d7a4ec680056733050b4d34/1a6324d5ad7f4034a93f911b4e53e080.html).

## Enabling Recommendations

Expand Down
Loading