java.lang.Object
org.elasticsearch.inference.InferenceStringGroup
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentObject
This class represents a group of one or more
InferenceString which will produce a single embedding when passed to an embedding
provider. Conceptually, this object is equivalent to a "content" object in the embedding request, e.g.
"input": {
"content": [
{"type": "text", "format": "text", "value": "text input"},
{"type": "image", "format": "base64", "value": "data:image/png;base64,..."}
]
}
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionInferenceStringGroup(String input) InferenceStringGroup(List<InferenceString> inferenceStrings) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanstatic booleancontainsNonTextEntry(List<InferenceStringGroup> inferenceStringGroups) Method used to determine if a list ofInferenceStringGroupcontains anyInferenceStringthat represent a non-text valuebooleaninthashCode()static IntegerindexContainingMultipleInferenceStrings(List<InferenceStringGroup> inferenceStringGroups) Method used to determine if a list ofInferenceStringGroupcontains any with more than oneInferenceStringin themstatic InferenceStringGroupparse(XContentParser parser) static List<InferenceString> toInferenceStringList(List<InferenceStringGroup> inferenceStringGroups) Converts a list ofInferenceStringGroupto an equally-sized list ofInferenceString.toString()toStringList(List<InferenceStringGroup> inferenceStringGroups) Converts a list ofInferenceStringGroupto an equally-sized list ofString.toXContent(XContentBuilder builder, ToXContent.Params params) value()voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
CONTENT_FIELD
- See Also:
-
-
Constructor Details
-
InferenceStringGroup
- Parameters:
inferenceStrings- the list ofInferenceStringwhich should result in generating a single embedding vector
-
InferenceStringGroup
- Throws:
IOException
-
InferenceStringGroup
-
InferenceStringGroup
-
-
Method Details
-
inferenceStrings
-
containsNonTextEntry
public boolean containsNonTextEntry() -
containsMultipleInferenceStrings
public boolean containsMultipleInferenceStrings() -
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
parse
- Throws:
IOException
-
value
-
textValue
-
toInferenceStringList
public static List<InferenceString> toInferenceStringList(List<InferenceStringGroup> inferenceStringGroups) Converts a list ofInferenceStringGroupto an equally-sized list ofInferenceString.This method should only be called in code paths that do not handle grouped embedding inputs, i.e. code paths that expect to generate one embedding per input rather than one embedding for multiple inputs.
- Parameters:
inferenceStringGroups- the list ofInferenceStringGroupto convert- Returns:
- a list of
InferenceString
-
toStringList
Converts a list ofInferenceStringGroupto an equally-sized list ofString.This method should only be called in code paths that both do not handle grouped embedding inputs AND that do not deal with multimodal inputs, i.e. code paths that expect to generate one embedding per input rather than one embedding for multiple inputs, AND where all inputs are guaranteed to be raw text.
- Parameters:
inferenceStringGroups- the list ofInferenceStringGroupto convert- Returns:
- a list of
InferenceString
-
containsNonTextEntry
Method used to determine if a list ofInferenceStringGroupcontains anyInferenceStringthat represent a non-text value- Parameters:
inferenceStringGroups- the list ofInferenceStringGroupto check- Returns:
- true if the input list contains any non-text values, false otherwise
-
indexContainingMultipleInferenceStrings
public static Integer indexContainingMultipleInferenceStrings(List<InferenceStringGroup> inferenceStringGroups) Method used to determine if a list ofInferenceStringGroupcontains any with more than oneInferenceStringin them- Parameters:
inferenceStringGroups- the list ofInferenceStringGroupto check- Returns:
- the index of the first
InferenceStringGroupfound to contain more than oneInferenceString, or null if no elements in the list contain more than oneInferenceString
-
equals
-
hashCode
public int hashCode() -
toString
-