Bug description JONS

{"id":"d7ae7c4a-1524-4fe5-9d58-e4d59b89d8f0","object":"chat.completion.chunk","created":1709899323,"model":"step-1-8k","choices":[{"index":0,"delta":{"role":"","content":"跃"},"finish_reason":""}],"usage":{"prompt_tokens":83,"completion_tokens":5,"total_tokens":88}}

Steps to reproduce role is “”

Error Code: ModelOptionsUtils$mapToClass

    public static <T> T mapToClass(Map<String, Object> source, Class<T> clazz) {
        try {
            String json = OBJECT_MAPPER.writeValueAsString(source);
            return OBJECT_MAPPER.readValue(json, clazz);
        } catch (JsonProcessingException var3) {
            JsonProcessingException e = var3;
            throw new RuntimeException(e);
        }
    }

**Solution **

Set at program startup

ModelOptionsUtils.OBJECT_MAPPER.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);

Comment From: ilayaperumalg

Hi @chansanya , Could you confirm which ChatModel API are you using with this? In general, Spring AI relies on the chat response message role to process the response correctly. More information can be helpful to understand when the role can be empty. Thanks

Comment From: chansanya

I am using step-1-8k,the sample api document is https://platform.stepfun.com/docs/api-reference/chat/streaming.