Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.basistech.rosette.api.HttpRosetteAPI;
import com.basistech.rosette.apimodel.DocumentRequest;
import com.basistech.rosette.apimodel.TextEmbeddingOptions;
import com.basistech.rosette.apimodel.TextEmbeddingResponse;

import java.io.IOException;
Expand Down Expand Up @@ -44,7 +45,9 @@ private void run() throws IOException {
//The api object creates an http client, but to provide your own:
//api.httpClient(CloseableHttpClient)
// When no options, use <?>.
DocumentRequest<?> request = DocumentRequest.builder().content(embeddingsData).build();
DocumentRequest<TextEmbeddingOptions> request = DocumentRequest.<TextEmbeddingOptions>builder()
.content(embeddingsData)
.build();
TextEmbeddingResponse response = rosetteApi.perform(HttpRosetteAPI.TEXT_EMBEDDING_SERVICE_PATH, request, TextEmbeddingResponse.class);
System.out.println(responseToJson(response));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2018 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.basistech.rosette.apimodel;

import com.basistech.rosette.annotations.JacksonMixin;
import lombok.Builder;
import lombok.Value;

/**
* Text embedding options
*/
@Value
@Builder
@JacksonMixin
public class TextEmbeddingOptions extends Options {

/**
* @return whether embeddings should be returned for each token in addition to the whole document
*/
private Boolean perToken;

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@
public class TextEmbeddingResponse extends Response {

/**
* @return the embedding vector as a list
* @return the document embedding vector as a list
*/
private final List<Double> embedding;
private final List<Double> documentEmbedding;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't we deprecating the old one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm double-checking with Hannah to be sure, but I think the plan is to just make the change (since TVEC is still in "Labs")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright, Hannah just confirmed that we can go ahead and just rename the field. She will make sure that the appropriate customers are notified about the change.


/**
* @return list of tokens, or {@code null}
*/
private final List<String> tokens;

/**
* @return list of per-token embeddings, 1:1 with tokens, or {@code null}
*/
private final List<List<Double>> tokenEmbeddings;
}