Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add embed endpoint #153

Merged
merged 5 commits into from
Sep 25, 2024
Merged

Add embed endpoint #153

merged 5 commits into from
Sep 25, 2024

Conversation

rohanshah18
Copy link
Contributor

@rohanshah18 rohanshah18 commented Sep 20, 2024

Problem

Add embed endpoint for Java SDK to allow users to create embeddings for text data such as passage or query using a specified model. More details on inference api can be found here.

Solution

Users can now call embed endpoint with the following parameters:

  1. String model: Accepts a string from the specified models .
  2. Map<String, Object> parameters: Accepts input_type and truncate as keys with their corresponding values in a Map. The values are expected to be scalar. Please note that the default value of truncate is set to END if not specified.
  3. List<String> inputs: The list must be of size atleast 1.

As a part of this change, I have added a getInferenceClient() in Pinecone class to follow a similar pattern with other SDKs. The underlying client uses OkHTTPClient for REST calls. The method getInferenceClient() returns an instance of Inference class which I added as a wrapper to the Inference API. So far, this wrapper contains embed() endpoint only, with the plan of adding rerank() soon. Lastly, I have added docstrings and updated README with an example of the embed endpoint.

Type of Change

  • New feature (non-breaking change which adds functionality)

Test Plan

Added integration tests.

@rohanshah18 rohanshah18 marked this pull request as ready for review September 23, 2024 21:45
src/main/java/io/pinecone/clients/Inference.java Outdated Show resolved Hide resolved
src/main/java/io/pinecone/clients/Inference.java Outdated Show resolved Hide resolved
src/main/java/io/pinecone/clients/Pinecone.java Outdated Show resolved Hide resolved
src/main/java/io/pinecone/clients/Inference.java Outdated Show resolved Hide resolved
src/main/java/io/pinecone/clients/Inference.java Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@aulorbe aulorbe left a comment

Choose a reason for hiding this comment

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

Just some language nits :)

Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, I agree with the feedback @ssmith-pc left as well.

Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for iterating.

README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ssmith-pc ssmith-pc left a comment

Choose a reason for hiding this comment

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

I left a couple more comments related to code samples, but overall looks good to me. Thanks for addressing all the feedback.

@rohanshah18 rohanshah18 merged commit 6f43b93 into main Sep 25, 2024
6 of 7 checks passed
@rohanshah18 rohanshah18 deleted the rshah/embed branch September 25, 2024 16:57
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.

4 participants