Skip to content

Commit 2e5ee43

Browse files
committed
Ignore embedding field for Document deserialization
- VectorStore implementations may still be returning the embedding values and mapping onto Document.class with Jackson This change ignores that field, but vector store implementations should change to not return the embedding data that is no longer stored in Document
1 parent f92a3f0 commit 2e5ee43

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiImageOptions.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ public class OpenAiImageOptions implements ImageOptions {
4747

4848
/**
4949
* The width of the generated images. Must be one of 256, 512, or 1024 for dall-e-2.
50-
* This property is interconnected with the 'size' property - setting both width and height
51-
* will automatically compute and set the size in "widthxheight" format. Conversely,
52-
* setting a valid size string will parse and set the individual width and height values.
50+
* This property is interconnected with the 'size' property - setting both width and
51+
* height will automatically compute and set the size in "widthxheight" format.
52+
* Conversely, setting a valid size string will parse and set the individual width and
53+
* height values.
5354
*/
5455
@JsonProperty("size_width")
5556
private Integer width;
5657

5758
/**
5859
* The height of the generated images. Must be one of 256, 512, or 1024 for dall-e-2.
59-
* This property is interconnected with the 'size' property - setting both width and height
60-
* will automatically compute and set the size in "widthxheight" format. Conversely,
61-
* setting a valid size string will parse and set the individual width and height values.
60+
* This property is interconnected with the 'size' property - setting both width and
61+
* height will automatically compute and set the size in "widthxheight" format.
62+
* Conversely, setting a valid size string will parse and set the individual width and
63+
* height values.
6264
*/
6365
@JsonProperty("size_height")
6466
private Integer height;
@@ -81,10 +83,10 @@ public class OpenAiImageOptions implements ImageOptions {
8183
/**
8284
* The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 for
8385
* dall-e-2. Must be one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3 models.
84-
* This property is automatically computed when both width and height are set, following
85-
* the format "widthxheight". When setting this property directly, it must follow the
86-
* format "WxH" where W and H are valid integers. Invalid formats will result in null
87-
* width and height values.
86+
* This property is automatically computed when both width and height are set,
87+
* following the format "widthxheight". When setting this property directly, it must
88+
* follow the format "WxH" where W and H are valid integers. Invalid formats will
89+
* result in null width and height values.
8890
*/
8991
@JsonProperty("size")
9092
private String size;

spring-ai-core/src/main/java/org/springframework/ai/document/Document.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
* }
7979
* }</pre>
8080
*/
81-
@JsonIgnoreProperties({ "contentFormatter" })
81+
@JsonIgnoreProperties({ "contentFormatter", "embedding" })
8282
public class Document {
8383

8484
public static final ContentFormatter DEFAULT_CONTENT_FORMATTER = DefaultContentFormatter.defaultConfig();

spring-ai-core/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,24 @@ public class FactCheckingEvaluator implements Evaluator {
7676
""";
7777

7878
private final ChatClient.Builder chatClientBuilder;
79+
7980
private final String evaluationPrompt;
8081

8182
/**
82-
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder.
83-
* Uses the default evaluation prompt suitable for general purpose LLMs.
84-
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
83+
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder. Uses
84+
* the default evaluation prompt suitable for general purpose LLMs.
85+
* @param chatClientBuilder The builder for the ChatClient used to perform the
86+
* evaluation
8587
*/
8688
public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder) {
8789
this(chatClientBuilder, DEFAULT_EVALUATION_PROMPT_TEXT);
8890
}
8991

9092
/**
91-
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder and evaluation prompt.
92-
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
93+
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder and
94+
* evaluation prompt.
95+
* @param chatClientBuilder The builder for the ChatClient used to perform the
96+
* evaluation
9397
* @param evaluationPrompt The prompt text to use for evaluation
9498
*/
9599
public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder, String evaluationPrompt) {
@@ -98,8 +102,10 @@ public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder, String evalua
98102
}
99103

100104
/**
101-
* Creates a FactCheckingEvaluator configured for use with the Bespoke Minicheck model.
102-
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
105+
* Creates a FactCheckingEvaluator configured for use with the Bespoke Minicheck
106+
* model.
107+
* @param chatClientBuilder The builder for the ChatClient used to perform the
108+
* evaluation
103109
* @return A FactCheckingEvaluator configured for Bespoke Minicheck
104110
*/
105111
public static FactCheckingEvaluator forBespokeMinicheck(ChatClient.Builder chatClientBuilder) {
@@ -121,9 +127,7 @@ public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {
121127

122128
String evaluationResponse = this.chatClientBuilder.build()
123129
.prompt()
124-
.user(userSpec -> userSpec.text(evaluationPrompt)
125-
.param("document", context)
126-
.param("claim", response))
130+
.user(userSpec -> userSpec.text(evaluationPrompt).param("document", context).param("claim", response))
127131
.call()
128132
.content();
129133

0 commit comments

Comments
 (0)