Skip to content

[Feature] Add OpenAI embedding model (Java) #1103

Description

@purushah

Search before asking

  • I searched in the issues and found nothing similar.

Description

Motivation

Python has OpenAIEmbeddingModelConnection and OpenAIEmbeddingModelSetup; Java has only Ollama and Bedrock. A Java agent that needs an OpenAI embedding today must go through the Python wrapper, which requires a Python environment on the task managers for a plain HTTPS call. This is a Java/Python parity gap. The Java OpenAI chat model already depends on com.openai:openai-java, so no new third-party dependency is needed.

Proposed changes

  • New module integrations/embedding-models/openai with OpenAIEmbeddingModelConnection and OpenAIEmbeddingModelSetup, built the same way OpenAICompletionsConnection builds its client.
  • Arguments mirror the Python classes one for one: connection api_key, base_url, request_timeout, max_retries, organization, project; setup connection, model, encoding_format, dimensions, user, additional_kwargs.
  • embedWithUsage reports prompt and total tokens so the embedding token metrics from [api][python][java] Track embedding token usage metrics #870 cover this provider.
  • ResourceName constants, YAML aliases, dist registration, and a Java tab in the OpenAI section of embedding_models.md.
  • Unit tests with a mocked client, following BedrockEmbeddingModelTest.

One naming question: the Java OpenAI chat connection uses api_base_url and timeout, while the Python embedding connection uses base_url and request_timeout. I propose the Python embedding names so the two embedding implementations align across languages. Happy to follow the chat-model names instead if preferred.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

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

Metadata

Metadata

Assignees

Labels

feature[Issue Type] New features or improvements to existing features.fixVersion/0.4.0priority/majorDefault priority of the PR or issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions