Files
fil/packages/java/dev/kreuzberg/StructuredExtractionConfig.java
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

128 lines
4.1 KiB
Java
Generated

// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;
/**
* Configuration for LLM-based structured data extraction.
*
* Sends extracted document content to a VLM with a JSON schema,
* returning structured data that conforms to the schema.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = StructuredExtractionConfig.Builder.class)
public record StructuredExtractionConfig(
/**
* JSON Schema defining the desired output structure.
*/
@JsonProperty("schema") JsonNode schema,
/**
* Schema name passed to the LLM's structured output mode.
*/
@Nullable @JsonProperty("schema_name") String schemaName,
/**
* Optional schema description for the LLM.
*/
@Nullable @JsonProperty("schema_description") String schemaDescription,
/**
* Enable strict mode — output must exactly match the schema.
*/
@Nullable @JsonProperty("strict") Boolean strict,
/**
* Custom Jinja2 extraction prompt template. When {@code None}, a default template is used.
*
* Available template variables:
* - {@code {{ content }}} — The extracted document text.
* - {@code {{ schema }}} — The JSON schema as a formatted string.
* - {@code {{ schema_name }}} — The schema name.
* - {@code {{ schema_description }}} — The schema description (may be empty).
*/
@Nullable @JsonProperty("prompt") String prompt,
/**
* LLM configuration for the extraction.
*/
@JsonProperty("llm") LlmConfig llm
) {
public static Builder builder() {
return new Builder();
}
// CPD-OFF
@JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
public static final class Builder {
private JsonNode schema = null;
@JsonProperty("schema_name")
private String schemaName = null;
@JsonProperty("schema_description")
private String schemaDescription = null;
private Boolean strict = null;
private String prompt = null;
private LlmConfig llm = null;
/** Sets the schema field. */
@JsonProperty("schema")
public Builder withSchema(final JsonNode value) {
this.schema = value;
return this;
}
/** Sets the schemaName field. */
@JsonProperty("schema_name")
public Builder withSchemaName(final @Nullable String value) {
this.schemaName = value;
return this;
}
/** Sets the schemaDescription field. */
@JsonProperty("schema_description")
public Builder withSchemaDescription(final @Nullable String value) {
this.schemaDescription = value;
return this;
}
/** Sets the strict field. */
@JsonProperty("strict")
public Builder withStrict(final @Nullable Boolean value) {
this.strict = value;
return this;
}
/** Sets the prompt field. */
@JsonProperty("prompt")
public Builder withPrompt(final @Nullable String value) {
this.prompt = value;
return this;
}
/** Sets the llm field. */
@JsonProperty("llm")
public Builder withLlm(final LlmConfig value) {
this.llm = value;
return this;
}
/** Builds the StructuredExtractionConfig instance. */
public StructuredExtractionConfig build() {
return new StructuredExtractionConfig(
schema,
schemaName,
schemaDescription,
strict,
prompt,
llm
);
}
}
// CPD-ON
}