Package com.openai.models.embeddings
Class EmbeddingValue
-
- All Implemented Interfaces:
public final class EmbeddingValue
Represents embedding data that can be either a list of floats or base64-encoded string. This union type allows for efficient handling of both formats.
This class is immutable - all instances are thread-safe and cannot be modified after creation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
EmbeddingValue.Visitor
An interface that defines how to map each variant of EmbeddingValue to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<List<Float>>
floats()
final Optional<String>
base64()
final Boolean
isFloats()
Returns true if this value contains a list of floats. final Boolean
isBase64()
Returns true if this value contains base64 string data. final List<Float>
asFloats()
Returns the embedding data as a list of floats. final String
asBase64()
Returns the embedding data as a base64 string. final JsonValue
_json()
final <T extends Any> T
accept(EmbeddingValue.Visitor<T> visitor)
final EmbeddingValue
validate()
final Boolean
isValid()
Boolean
equals(Object other)
Integer
hashCode()
String
toString()
final static EmbeddingValue
ofFloats(List<Float> floats)
final static EmbeddingValue
ofBase64(String base64)
-
-
Method Detail
-
asFloats
final List<Float> asFloats()
Returns the embedding data as a list of floats.
If this value represents base64 string data, then it's decoded into floats.
-
asBase64
final String asBase64()
Returns the embedding data as a base64 string.
If this value represents a list of floats, then it's decoded into floats.
-
accept
final <T extends Any> T accept(EmbeddingValue.Visitor<T> visitor)
-
validate
final EmbeddingValue validate()
-
ofFloats
final static EmbeddingValue ofFloats(List<Float> floats)
-
ofBase64
final static EmbeddingValue ofBase64(String base64)
-
-
-
-