Skip to content

Commit

Permalink
Ignore embedding field for Document deserialization
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Mark Pollack committed Dec 19, 2024
1 parent f92a3f0 commit 2e5ee43
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ public class OpenAiImageOptions implements ImageOptions {

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

/**
* The height of the generated images. Must be one of 256, 512, or 1024 for dall-e-2.
* This property is interconnected with the 'size' property - setting both width and height
* will automatically compute and set the size in "widthxheight" format. Conversely,
* setting a valid size string will parse and set the individual width and height values.
* This property is interconnected with the 'size' property - setting both width and
* height will automatically compute and set the size in "widthxheight" format.
* Conversely, setting a valid size string will parse and set the individual width and
* height values.
*/
@JsonProperty("size_height")
private Integer height;
Expand All @@ -81,10 +83,10 @@ public class OpenAiImageOptions implements ImageOptions {
/**
* The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 for
* dall-e-2. Must be one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3 models.
* This property is automatically computed when both width and height are set, following
* the format "widthxheight". When setting this property directly, it must follow the
* format "WxH" where W and H are valid integers. Invalid formats will result in null
* width and height values.
* This property is automatically computed when both width and height are set,
* following the format "widthxheight". When setting this property directly, it must
* follow the format "WxH" where W and H are valid integers. Invalid formats will
* result in null width and height values.
*/
@JsonProperty("size")
private String size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* }
* }</pre>
*/
@JsonIgnoreProperties({ "contentFormatter" })
@JsonIgnoreProperties({ "contentFormatter", "embedding" })
public class Document {

public static final ContentFormatter DEFAULT_CONTENT_FORMATTER = DefaultContentFormatter.defaultConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,24 @@ public class FactCheckingEvaluator implements Evaluator {
""";

private final ChatClient.Builder chatClientBuilder;

private final String evaluationPrompt;

/**
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder.
* Uses the default evaluation prompt suitable for general purpose LLMs.
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder. Uses
* the default evaluation prompt suitable for general purpose LLMs.
* @param chatClientBuilder The builder for the ChatClient used to perform the
* evaluation
*/
public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder) {
this(chatClientBuilder, DEFAULT_EVALUATION_PROMPT_TEXT);
}

/**
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder and evaluation prompt.
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
* Constructs a new FactCheckingEvaluator with the provided ChatClient.Builder and
* evaluation prompt.
* @param chatClientBuilder The builder for the ChatClient used to perform the
* evaluation
* @param evaluationPrompt The prompt text to use for evaluation
*/
public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder, String evaluationPrompt) {
Expand All @@ -98,8 +102,10 @@ public FactCheckingEvaluator(ChatClient.Builder chatClientBuilder, String evalua
}

/**
* Creates a FactCheckingEvaluator configured for use with the Bespoke Minicheck model.
* @param chatClientBuilder The builder for the ChatClient used to perform the evaluation
* Creates a FactCheckingEvaluator configured for use with the Bespoke Minicheck
* model.
* @param chatClientBuilder The builder for the ChatClient used to perform the
* evaluation
* @return A FactCheckingEvaluator configured for Bespoke Minicheck
*/
public static FactCheckingEvaluator forBespokeMinicheck(ChatClient.Builder chatClientBuilder) {
Expand All @@ -121,9 +127,7 @@ public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {

String evaluationResponse = this.chatClientBuilder.build()
.prompt()
.user(userSpec -> userSpec.text(evaluationPrompt)
.param("document", context)
.param("claim", response))
.user(userSpec -> userSpec.text(evaluationPrompt).param("document", context).param("claim", response))
.call()
.content();

Expand Down

0 comments on commit 2e5ee43

Please sign in to comment.