Skip to content

fix: make dimensions parameter optional in OpenAITextEmbedding (#1095)#1110

Open
egezturkk wants to merge 3 commits intoagentscope-ai:mainfrom
egezturkk:fix/1095-openai-embedding-dimensions
Open

fix: make dimensions parameter optional in OpenAITextEmbedding (#1095)#1110
egezturkk wants to merge 3 commits intoagentscope-ai:mainfrom
egezturkk:fix/1095-openai-embedding-dimensions

Conversation

@egezturkk
Copy link
Copy Markdown

@egezturkk egezturkk commented Apr 2, 2026

AgentScope-Java Version

1.0.12-SNAPSHOT

Description

Background & Purpose:
Currently, OpenAITextEmbedding enforces a mandatory dimensions parameter. This causes 400 Bad Request errors when using open-source embedding models (like BAAI/bge) through the OpenAI-compatible API, as these models do not support the Matryoshka representation parameter.

Changes:

  • Changed dimensions type from int to Integer in OpenAITextEmbedding and its Builder.
  • Removed the hardcoded default value of 1536 to make it optional.
  • Updated the request builder logic to only include the dimensions field in the API payload if it is explicitly provided.
  • Added null checks in embed(), getDimensions(), and validation logic to ensure stability.

How to test:
Initialize OpenAITextEmbedding without calling .dimensions(). Verify that the outgoing JSON request to the embedding endpoint does not contain the dimensions key.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Code is ready for review

@egezturkk egezturkk requested a review from a team April 2, 2026 14:35
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Apr 2, 2026

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ope/core/embedding/openai/OpenAITextEmbedding.java 66.66% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant