diff --git a/models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/api/DeepSeekApi.java b/models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/api/DeepSeekApi.java index 711a3359c1a..5795dffc1c5 100644 --- a/models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/api/DeepSeekApi.java +++ b/models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/api/DeepSeekApi.java @@ -16,11 +16,8 @@ package org.springframework.ai.deepseek.api; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.ai.model.ApiKey; import org.springframework.ai.model.ChatModelDescription; import org.springframework.ai.model.ModelOptionsUtils; @@ -484,12 +481,13 @@ public void setJsonSchema(String jsonSchema) { * @param toolChoice Controls which (if any) function is called by the model. none * means the model will not call a function and instead generates a message. auto * means the model can pick between generating a message or calling a function. - * Specifying a particular function via {"type: "function", "function": {"name": + * Specifying a particular function via {"type": "function", "function": {"name": * "my_function"}} forces the model to call that function. none is the default when no * functions are present. auto is the default if functions are present. Use the * {@link ToolChoiceBuilder} to create the tool choice value. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChatCompletionRequest(// @formatter:off @JsonProperty("messages") List messages, @JsonProperty("model") String model, @@ -587,6 +585,7 @@ public static Object FUNCTION(String functionName) { * Applicable only for {@link Role#ASSISTANT} role and null otherwise. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChatCompletionMessage(// @formatter:off @JsonProperty("content") Object rawContent, @JsonProperty("role") Role role, @@ -675,6 +674,7 @@ public enum Role { * @param function The function definition. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ToolCall(// @formatter:off @JsonProperty("index") Integer index, @JsonProperty("id") String id, @@ -695,6 +695,7 @@ public ToolCall(String id, String type, ChatCompletionFunction function) { * function. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChatCompletionFunction(// @formatter:off @JsonProperty("name") String name, @JsonProperty("arguments") String arguments) { // @formatter:on @@ -718,6 +719,7 @@ public record ChatCompletionFunction(// @formatter:off * @param usage Usage statistics for the completion request. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChatCompletion(// @formatter:off @JsonProperty("id") String id, @JsonProperty("choices") List choices, @@ -737,6 +739,7 @@ public record ChatCompletion(// @formatter:off * @param logprobs Log probability information for the choice. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record Choice(// @formatter:off @JsonProperty("finish_reason") ChatCompletionFinishReason finishReason, @JsonProperty("index") Integer index, @@ -753,6 +756,7 @@ public record Choice(// @formatter:off * @param refusal A list of message refusal tokens with log probability information. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record LogProbs(@JsonProperty("content") List content, @JsonProperty("refusal") List refusal) { @@ -771,6 +775,7 @@ public record LogProbs(@JsonProperty("content") List content, * requested top_logprobs returned. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record Content(// @formatter:off @JsonProperty("token") String token, @JsonProperty("logprob") Float logprob, @@ -789,6 +794,7 @@ public record Content(// @formatter:off * is no bytes representation for the token. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record TopLogProbs(// @formatter:off @JsonProperty("token") String token, @JsonProperty("logprob") Float logprob, @@ -812,6 +818,7 @@ public record TopLogProbs(// @formatter:off * @param promptTokensDetails Breakdown of tokens used in the prompt. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record Usage(// @formatter:off @JsonProperty("completion_tokens") Integer completionTokens, @JsonProperty("prompt_tokens") Integer promptTokens, @@ -828,6 +835,7 @@ public Usage(Integer completionTokens, Integer promptTokens, Integer totalTokens * @param cachedTokens Cached tokens present in the prompt. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record PromptTokensDetails(// @formatter:off @JsonProperty("cached_tokens") Integer cachedTokens) { // @formatter:on } @@ -853,6 +861,7 @@ public record PromptTokensDetails(// @formatter:off * only if the StreamOptions.includeUsage is set to true. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChatCompletionChunk(// @formatter:off @JsonProperty("id") String id, @JsonProperty("choices") List choices, @@ -872,6 +881,7 @@ public record ChatCompletionChunk(// @formatter:off * @param logprobs Log probability information for the choice. */ @JsonInclude(Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) public record ChunkChoice(// @formatter:off @JsonProperty("finish_reason") ChatCompletionFinishReason finishReason, @JsonProperty("index") Integer index,