-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add JsonIgnoreProperties to DeepSeek Model Response objects #3057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to add this annotation only for the response objects. Hence, we can remove this. Will fix it when merging. |
||
public record ChatCompletionRequest(// @formatter:off | ||
@JsonProperty("messages") List<ChatCompletionMessage> 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<Choice> 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> content, | ||
@JsonProperty("refusal") List<Content> refusal) { | ||
|
||
|
@@ -771,6 +775,7 @@ public record LogProbs(@JsonProperty("content") List<Content> 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<ChunkChoice> 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, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wildcard imports aren't allowed - will fix when merging.