java.lang.Object
java.lang.Record
org.elasticsearch.inference.EmbeddingRequest
- Record Components:
inputs- The list ofInferenceStringGroupinputs to generate embeddings forinputType- TheInputTypeof the requesttaskSettings- The map of task settings specific to this request
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentFragment
public record EmbeddingRequest(List<InferenceStringGroup> inputs, InputType inputType, Map<String,Object> taskSettings)
extends Record
implements Writeable, ToXContentFragment
This class handles the parsing of inputs used by the
TaskType.EMBEDDING task type. The input for this task is specified using
a list of "content" objects, each of which specifies the DataType, DataFormat and the String value of the input. The
format field is optional, and if not specified will use the default DataFormat for the given DataType:
"input": [
{
"content": {"type": "image", "format": "base64", "value": "data:image/png;base64,..."},
},
{
"content": [
{"type": "text", "value": "text input"},
{"type": "image", "value": "data:image/png;base64,..."}
]
}
]
It is also possible to specify a single content object rather than a
list:
"input": {
"content": {"type": "text", "format": "text", "value": "text input"}
}
To preserve input compatibility with the existing TaskType.TEXT_EMBEDDING task, the input can also be specified as a single
String or a list of Strings, each of which will be parsed into a content object with DataType equal to
DataType.TEXT and DataFormat equal to DataFormat.TEXT:
"input": "singe text input"OR
"input": ["first text input", "second text input"]
-
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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final TransportVersionstatic final ConstructingObjectParser<EmbeddingRequest, Void> Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddingRequest(List<InferenceStringGroup> inputs, InputType inputType, Map<String, Object> taskSettings) Creates an instance of aEmbeddingRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.inputs()Returns the value of theinputsrecord component.Returns the value of theinputTyperecord component.static EmbeddingRequestof(List<InferenceStringGroup> contents) Returns the value of thetaskSettingsrecord component.final StringtoString()Returns a string representation of this record class.toXContent(XContentBuilder builder, ToXContent.Params params) 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.ToXContentFragment
isFragment
-
Field Details
-
JINA_AI_EMBEDDING_TASK_ADDED
-
INPUT_FIELD
- See Also:
-
PARSER
-
-
Constructor Details
-
EmbeddingRequest
public EmbeddingRequest(List<InferenceStringGroup> inputs, @Nullable InputType inputType, @Nullable Map<String, Object> taskSettings) Creates an instance of aEmbeddingRequestrecord class.- Parameters:
inputs- the value for theinputsrecord componentinputType- the value for theinputTyperecord componenttaskSettings- the value for thetaskSettingsrecord component
-
EmbeddingRequest
- Throws:
IOException
-
-
Method Details
-
of
-
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
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
inputs
Returns the value of theinputsrecord component.- Returns:
- the value of the
inputsrecord component
-
inputType
Returns the value of theinputTyperecord component.- Returns:
- the value of the
inputTyperecord component
-
taskSettings
Returns the value of thetaskSettingsrecord component.- Returns:
- the value of the
taskSettingsrecord component
-