Skip to content
Closed
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 @@ -30,6 +30,7 @@
*
* @author Christian Tzolov
* @author Mark Pollack
* @author Ilayaperumal Gopinathan
* @since 1.0.0
*/
public class VertexAiEmbeddingConnectionDetails {
Expand Down Expand Up @@ -125,26 +126,72 @@ public static class Builder {
*/
private PredictionServiceSettings predictionServiceSettings;

public Builder apiEndpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder location(String location) {
this.location = location;
return this;
}

public Builder publisher(String publisher) {
this.publisher = publisher;
return this;
}

public Builder predictionServiceSettings(PredictionServiceSettings predictionServiceSettings) {
this.predictionServiceSettings = predictionServiceSettings;
return this;
}

/**
* @deprecated use {@link #apiEndpoint(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withApiEndpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}

/**
* @deprecated use {@link #projectId(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withProjectId(String projectId) {
this.projectId = projectId;
return this;
}

/**
* @deprecated use {@link #location(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withLocation(String location) {
this.location = location;
return this;
}

/**
* @deprecated use {@link #publisher(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withPublisher(String publisher) {
this.publisher = publisher;
return this;
}

/**
* @deprecated use {@link #predictionServiceSettings(PredictionServiceSettings)}
* instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withPredictionServiceSettings(PredictionServiceSettings predictionServiceSettings) {
this.predictionServiceSettings = predictionServiceSettings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Utility class for constructing parameter objects for Vertex AI embedding requests.
*
* @author Christian Tzolov
* @author Ilayaperumal Gopinathan
* @since 1.0.0
*/
public abstract class VertexAiEmbeddingUtils {
Expand Down Expand Up @@ -82,12 +83,32 @@ public static TextParametersBuilder of() {
return new TextParametersBuilder();
}

public TextParametersBuilder outputDimensionality(Integer outputDimensionality) {
Assert.notNull(outputDimensionality, "Output dimensionality must not be null");
this.outputDimensionality = outputDimensionality;
return this;
}

public TextParametersBuilder autoTruncate(Boolean autoTruncate) {
Assert.notNull(autoTruncate, "Auto truncate must not be null");
this.autoTruncate = autoTruncate;
return this;
}

/**
* @deprecated use {@link #outputDimensionality(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TextParametersBuilder withOutputDimensionality(Integer outputDimensionality) {
Assert.notNull(outputDimensionality, "Output dimensionality must not be null");
this.outputDimensionality = outputDimensionality;
return this;
}

/**
* @deprecated use {@link #autoTruncate(Boolean)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TextParametersBuilder withAutoTruncate(Boolean autoTruncate) {
Assert.notNull(autoTruncate, "Auto truncate must not be null");
this.autoTruncate = autoTruncate;
Expand Down Expand Up @@ -123,12 +144,32 @@ public static TextInstanceBuilder of(String content) {
return builder;
}

public TextInstanceBuilder taskType(String taskType) {
Assert.hasText(taskType, "Task type must not be empty");
this.taskType = taskType;
return this;
}

public TextInstanceBuilder title(String title) {
Assert.hasText(title, "Title must not be empty");
this.title = title;
return this;
}

/**
* @deprecated use {@link #taskType(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TextInstanceBuilder withTaskType(String taskType) {
Assert.hasText(taskType, "Task type must not be empty");
this.taskType = taskType;
return this;
}

/**
* @deprecated use {@link #title(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TextInstanceBuilder withTitle(String title) {
Assert.hasText(title, "Title must not be empty");
this.title = title;
Expand Down Expand Up @@ -179,25 +220,66 @@ public static MultimodalInstanceBuilder of() {
return new MultimodalInstanceBuilder();
}

public MultimodalInstanceBuilder text(String text) {
Assert.hasText(text, "Text must not be empty");
this.text = text;
return this;
}

public MultimodalInstanceBuilder dimension(Integer dimension) {
Assert.isTrue(dimension == 128 || dimension == 256 || dimension == 512 || dimension == 1408,
"Invalid dimension value: " + dimension + ". Accepted values: 128, 256, 512, or 1408.");
this.dimension = dimension;
return this;
}

public MultimodalInstanceBuilder image(Struct image) {
Assert.notNull(image, "Image must not be null");
this.image = image;
return this;
}

public MultimodalInstanceBuilder video(Struct video) {
Assert.notNull(video, "Video must not be null");
this.video = video;
return this;
}

/**
* @deprecated use {@link #text(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MultimodalInstanceBuilder withText(String text) {
Assert.hasText(text, "Text must not be empty");
this.text = text;
return this;
}

/**
* @deprecated use {@link #dimension(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MultimodalInstanceBuilder withDimension(Integer dimension) {
Assert.isTrue(dimension == 128 || dimension == 256 || dimension == 512 || dimension == 1408,
"Invalid dimension value: " + dimension + ". Accepted values: 128, 256, 512, or 1408.");
this.dimension = dimension;
return this;
}

/**
* @deprecated use {@link #image(Struct)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MultimodalInstanceBuilder withImage(Struct image) {
Assert.notNull(image, "Image must not be null");
this.image = image;
return this;
}

/**
* @deprecated use {@link #video(Struct)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MultimodalInstanceBuilder withVideo(Struct video) {
Assert.notNull(video, "Video must not be null");
this.video = video;
Expand Down Expand Up @@ -255,6 +337,35 @@ public static ImageBuilder of(MimeType mimeType) {
return builder;
}

public ImageBuilder imageData(Object imageData) {
Assert.notNull(imageData, "Image data must not be null");
if (imageData instanceof byte[] bytes) {
return imageBytes(bytes);
}
else if (imageData instanceof String uri) {
return gcsUri(uri);
}
else {
throw new IllegalArgumentException("Unsupported image data type: " + imageData.getClass());
}
}

public ImageBuilder imageBytes(byte[] imageBytes) {
Assert.notNull(imageBytes, "Image bytes must not be null");
this.imageBytes = imageBytes;
return this;
}

public ImageBuilder gcsUri(String gcsUri) {
Assert.hasText(gcsUri, "GCS URI must not be empty");
this.gcsUri = gcsUri;
return this;
}

/**
* @deprecated use {@link #imageData(Object)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageBuilder withImageData(Object imageData) {
Assert.notNull(imageData, "Image data must not be null");
if (imageData instanceof byte[] bytes) {
Expand All @@ -268,12 +379,20 @@ else if (imageData instanceof String uri) {
}
}

/**
* @deprecated use {@link #imageBytes(byte[])} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageBuilder withImageBytes(byte[] imageBytes) {
Assert.notNull(imageBytes, "Image bytes must not be null");
this.imageBytes = imageBytes;
return this;
}

/**
* @deprecated use {@link #gcsUri(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageBuilder withGcsUri(String gcsUri) {
Assert.hasText(gcsUri, "GCS URI must not be empty");
this.gcsUri = gcsUri;
Expand Down Expand Up @@ -351,38 +470,105 @@ public static VideoBuilder of(MimeType mimeType) {
return builder;
}

public VideoBuilder videoData(Object imageData) {
Assert.notNull(imageData, "Video data must not be null");
if (imageData instanceof byte[] imageBytes) {
return videoBytes(imageBytes);
}
else if (imageData instanceof String uri) {
return gcsUri(uri);
}
else {
throw new IllegalArgumentException("Unsupported image data type: " + imageData.getClass());
}
}

public VideoBuilder videoBytes(byte[] imageBytes) {
Assert.notNull(imageBytes, "Video bytes must not be null");
this.videoBytes = imageBytes;
return this;
}

public VideoBuilder gcsUri(String gcsUri) {
Assert.hasText(gcsUri, "GCS URI must not be empty");
this.gcsUri = gcsUri;
return this;
}

public VideoBuilder startOffsetSec(Integer startOffsetSec) {
if (startOffsetSec != null) {
this.startOffsetSec = startOffsetSec;
}
return this;
}

public VideoBuilder endOffsetSec(Integer endOffsetSec) {
if (endOffsetSec != null) {
this.endOffsetSec = endOffsetSec;
}
return this;

}

public VideoBuilder intervalSec(Integer intervalSec) {
if (intervalSec != null) {
this.intervalSec = intervalSec;
}
return this;
}

/**
* @deprecated use {@link #videoData(Object)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withVideoData(Object imageData) {
Assert.notNull(imageData, "Video data must not be null");
if (imageData instanceof byte[] imageBytes) {
return withVideoBytes(imageBytes);
return videoBytes(imageBytes);
}
else if (imageData instanceof String uri) {
return withGcsUri(uri);
return gcsUri(uri);
}
else {
throw new IllegalArgumentException("Unsupported image data type: " + imageData.getClass());
}
}

/**
* @deprecated use {@link #videoBytes(byte[])} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withVideoBytes(byte[] imageBytes) {
Assert.notNull(imageBytes, "Video bytes must not be null");
this.videoBytes = imageBytes;
return this;
}

/**
* @deprecated use {@link #gcsUri(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withGcsUri(String gcsUri) {
Assert.hasText(gcsUri, "GCS URI must not be empty");
this.gcsUri = gcsUri;
return this;
}

/**
* @deprecated use {@link #startOffsetSec(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withStartOffsetSec(Integer startOffsetSec) {
if (startOffsetSec != null) {
this.startOffsetSec = startOffsetSec;
}
return this;
}

/**
* @deprecated use {@link #endOffsetSec(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withEndOffsetSec(Integer endOffsetSec) {
if (endOffsetSec != null) {
this.endOffsetSec = endOffsetSec;
Expand All @@ -391,6 +577,10 @@ public VideoBuilder withEndOffsetSec(Integer endOffsetSec) {

}

/**
* @deprecated use {@link #intervalSec(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public VideoBuilder withIntervalSec(Integer intervalSec) {
if (intervalSec != null) {
this.intervalSec = intervalSec;
Expand Down
Loading
Loading