Skip to content

fix(embedding): validate batch results before accepting vectors #401

Closed

Description

@WH-2099

Delivery status — 2026-11-02

Implementation is completed through merged #403; this issue remains closed as completed.
SDK 0.11.0 publication for Dify 1.19.0 is tracked separately in #413.

OAICompatEmbeddingModel._invoke accepts malformed batches and appends vectors in response order.
For three inputs in batches of two, an empty first response still triggers the second request and returns just one vector.

Validate each batch before accepting vectors or sending another request:

  • Require one nonempty vector per input, consistent dimensions and finite numeric values.
  • Require complete, unique, valid integer indices when present, and restore input order.
  • Keep valid responses without indices in response order; reject mixed or invalid index metadata.
  • Stop at the first invalid batch through the SDK invocation-error path.
  • Preserve usage aggregation for valid batches and close owned responses on success and failure.

Update #396's HTTP tests to cover valid indexed/unindexed responses, reordered vectors, malformed batches and no further requests after failure.
Check Gitee AI and SiliconFlow; document rejection of malformed responses and reordering of indexed results.
From #394 and the review in #396.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions