Class OpenAiEmbeddingDeserializer

java.lang.Object
com.fasterxml.jackson.databind.JsonDeserializer<float[]>
org.springframework.ai.openai.api.OpenAiEmbeddingDeserializer
All Implemented Interfaces:
com.fasterxml.jackson.databind.deser.NullValueProvider

public class OpenAiEmbeddingDeserializer extends com.fasterxml.jackson.databind.JsonDeserializer<float[]>
Used to deserialize the `embedding` field returned by the model.

Supports two input formats:

  1. float[] - returned directly as-is.
  2. A Base64-encoded string representing a float array stored in little-endian format. The string is first decoded into a byte array, then converted into a float[].
Author:
Sun Yuhan
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer

    com.fasterxml.jackson.databind.JsonDeserializer.None
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float[]
    deserialize(com.fasterxml.jackson.core.JsonParser jsonParser, com.fasterxml.jackson.databind.DeserializationContext deserializationContext)
     

    Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer

    deserialize, deserializeWithType, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getNullValue, getObjectIdReader, handledType, isCachable, logicalType, replaceDelegatee, supportsUpdate, unwrappingDeserializer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenAiEmbeddingDeserializer

      public OpenAiEmbeddingDeserializer()
  • Method Details

    • deserialize

      public float[] deserialize(com.fasterxml.jackson.core.JsonParser jsonParser, com.fasterxml.jackson.databind.DeserializationContext deserializationContext) throws IOException, com.fasterxml.jackson.core.JacksonException
      Specified by:
      deserialize in class com.fasterxml.jackson.databind.JsonDeserializer<float[]>
      Throws:
      IOException
      com.fasterxml.jackson.core.JacksonException