Skip to content

feat(llm-batch): add LlmBatchModel type for batch-supported models - #2177

Open
InjunPark-sap wants to merge 5 commits into
mainfrom
feat/add-llm-batch-model-type
Open

feat(llm-batch): add LlmBatchModel type for batch-supported models#2177
InjunPark-sap wants to merge 5 commits into
mainfrom
feat/add-llm-batch-model-type

Conversation

@InjunPark-sap

Copy link
Copy Markdown
Member

Context

Closes SAP/ai-sdk-js-backlog#609.

What this PR does and why it is needed

Adds a LlmBatchModel type so BatchCreateRequest.spec.model is typed instead of plain string, giving IDE autocomplete for batch-supported models while staying backward compatible (any string is still accepted via LiteralUnion).

  • Add LlmBatchModel in @sap-ai-sdk/core, re-exported from @sap-ai-sdk/llm-batch.
  • Patch the generated BatchCreateRequest.spec.model to LlmBatchModel via the postgenerate step (generated file is never hand-edited; anchor miss hard-fails).
  • Add scripts/sap-batch-models.json as the ground-truth batch model list (6 models from the LLM batch service config; the SAP Notes list is intentionally incomplete).
  • Extend the update-models skill + scraper to sync the SAP Notes batch section non-destructively (never shrinks the ground-truth file; auto-bumps the llm-batch changeset).

Definition of Done

  • Code is tested (Unit, type-level via tsd)
  • Error handling created / updated & covered by the tests above (N/A — type-only change)
  • Documentation updated
  • (Optional) Aligned changes with the Java SDK
  • (Optional) Release notes updated (changeset: core + llm-batch minor)

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

👋 Hi — I'm PR Bot, your SAP code review assistant.

I'll automatically review your pull requests for code quality, security, and SAP compliance. Get an overview of what I do →

What I do

  • Summarize your pull request changes
  • Review code for quality, correctness, and reliability
  • Suggest fixes when a pipeline job fails

Key commands

Command Description
/review Trigger a code review
/summarize Generate a PR summary
/ask <question> Ask about the current changes
/help See all available commands
Configure me for your team

Create .hyperspace/pull_request_bot_config.json in your repository:

{
  "$schema": "https://devops-insights-pr-bot.cfapps.eu10-004.hana.ondemand.com/schema/pull_request_bot.json",
  "features": {
    "control_panel": false,
    "summarize": {
      "auto_generate_summary": true,
      "auto_insert_summary": true,
      "auto_run_on_draft_pr": true,
      "use_custom_summarize_prompt": false,
      "use_custom_summarize_output_template": false,
      "excluded_paths": [],
      "auto_exclude_authors": []
    },
    "review": {
      "auto_generate_review": true,
      "auto_run_on_draft_pr": false,
      "use_custom_review_focus": false,
      "excluded_paths": [],
      "auto_exclude_authors": []
    },
    "sonar_fix": {
      "enable": true,
      "excluded_rules": []
    },
    "pipeline_fix": {
      "enable": true
    }
  },
  "excluded_paths": []
}

Full configuration reference →

@InjunPark-sap InjunPark-sap self-assigned this Aug 19, 2026
@InjunPark-sap
InjunPark-sap marked this pull request as ready for review August 20, 2026 08:43
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


New Feature: Add LlmBatchModel Type for Batch-Supported Models

Context

Closes SAP/ai-sdk-js-backlog#609.

What this PR does and why it is needed

Introduces a LlmBatchModel typed union for BatchCreateRequest.spec.model, replacing the previous plain string type. This enables IDE autocomplete for batch-supported models while remaining fully backward compatible — arbitrary strings are still accepted via LiteralUnion.

Key changes

  • @sap-ai-sdk/core: Added the LlmBatchModel type to model-types.ts with 6 known GPT batch models (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-5, gpt-5.4, gpt-5.4-mini), and exported it from the package index.
  • @sap-ai-sdk/llm-batch: Re-exports LlmBatchModel from @sap-ai-sdk/core; the generated BatchCreateRequest.spec.model field is now typed as LlmBatchModel via a new patch-batch-model-type postgenerate step.
  • scripts/sap-batch-models.json: New ground-truth file for batch model names. The scraper never shrinks this file — models absent from SAP Notes but present here are preserved.
  • scripts/postgenerate-llm-batch.ts: Extended to handle batch-create-request.ts in addition to batches-api.ts. Uses hard-failing anchor assertions so generator format changes are detected immediately.
  • scripts/sync-model-types.ts: Loads sap-batch-models.json and injects LlmBatchModel into the type sync pipeline; auto-bumps the llm-batch changeset when the batch model list changes.
  • scripts/extract-model-table.js: Extended to scrape the "Batch Consumption Supported Models" table from SAP Notes, returning it as a batch string array.
  • tests/type-tests: New llm-batch.test-d.ts type-level test (via tsd) verifying known models, arbitrary strings, and the BatchCreateRequest.spec.model type.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.33

Comment thread packages/llm-batch/package.json Outdated
Comment on lines +46 to +47
"make-llm-batch-experimental": "node ../../scripts/postgenerate-llm-batch.ts ./src/client/batch-service/batches-api.ts",
"patch-batch-model-type": "node ../../scripts/postgenerate-llm-batch.ts ./src/client/batch-service/schema/batch-create-request.ts",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[pp] Please handle these as a single invocation of postgenerate-llm-batch.ts

Comment thread scripts/extract-model-table.js Outdated
Comment on lines +84 to +87
// Header/title rows vary, so filter by model-name shape instead of a fixed
// slice offset: keep only cells that look like a model id (lowercase,
// digits, dots, dashes). This rejects header labels like "Model"/"Region".
const isModelName = s => /^[a-z0-9][a-z0-9.-]*$/.test(s);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[q] Other row extractions do not have this, is this necessary?

Suggested change
// Header/title rows vary, so filter by model-name shape instead of a fixed
// slice offset: keep only cells that look like a model id (lowercase,
// digits, dots, dashes). This rejects header labels like "Model"/"Region".
const isModelName = s => /^[a-z0-9][a-z0-9.-]*$/.test(s);

// Identified by a "region" column with no "orchestration" and no
// "suggested replacement" column (distinguishes it from active/retired tables).

function findBatchTable() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[pp] I assume this works but it might be easier to look for the first table past a <strong>/<b>/<hN> Batch Consumption string.

Comment thread scripts/sync-model-types.ts Outdated
Comment on lines +348 to +349
batchCurrent.size !== batchNew.size ||
[...batchNew].some(m => !batchCurrent.has(m));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[pp]

Suggested change
batchCurrent.size !== batchNew.size ||
[...batchNew].some(m => !batchCurrent.has(m));
batchCurrent.symmetricDifference(batchNew).size > 0;

Comment thread scripts/sync-model-types.ts Outdated

const SAP_MODELS_PATH = resolve(import.meta.dirname, 'sap-models.json');

const SAP_BATCH_MODELS_PATH = resolve(import.meta.dirname, 'sap-batch-models.json');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[pp] I would prefer adding the new information to SAP_MODELS_PATH as part of an extra key in the main file.

Comment thread scripts/sync-model-types.ts Outdated
Comment on lines +465 to +467
if (batchChanged) {
bumps.push("'@sap-ai-sdk/llm-batch': minor");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As we don't bump extra packages when bumping other model types, I would also avoid doing that here.

Comment thread scripts/sync-model-types.ts Outdated
batchCurrent.size !== batchNew.size ||
[...batchNew].some(m => !batchCurrent.has(m));

const allAdded = Object.entries(typeToActiveModels).flatMap(([typeName, activeModels]) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[req] Please add changeset lines for changes (additions/removals) to the batch model list.

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