141 lines
4.4 KiB
Java
141 lines
4.4 KiB
Java
|
|
// 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.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 an LLM provider/model via liter-llm.
|
||
|
|
*
|
||
|
|
* Each feature (VLM OCR, VLM embeddings, structured extraction) carries
|
||
|
|
* its own {@code LlmConfig}, allowing different providers per feature.
|
||
|
|
*/
|
||
|
|
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||
|
|
@JsonDeserialize(builder = LlmConfig.Builder.class)
|
||
|
|
public record LlmConfig(
|
||
|
|
/**
|
||
|
|
* Provider/model string using liter-llm routing format.
|
||
|
|
*
|
||
|
|
* Examples: {@code "openai/gpt-4o"}, {@code "anthropic/claude-sonnet-4-20250514"},
|
||
|
|
* {@code "groq/llama-3.1-70b-versatile"}.
|
||
|
|
*/
|
||
|
|
@JsonProperty("model") String model,
|
||
|
|
/**
|
||
|
|
* API key for the provider. When {@code None}, liter-llm falls back to
|
||
|
|
* the provider's standard environment variable (e.g., {@code OPENAI_API_KEY}).
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("api_key") String apiKey,
|
||
|
|
/**
|
||
|
|
* Custom base URL override for the provider endpoint.
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("base_url") String baseUrl,
|
||
|
|
/**
|
||
|
|
* Request timeout in seconds (default: 60).
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("timeout_secs") Long timeoutSecs,
|
||
|
|
/**
|
||
|
|
* Maximum retry attempts (default: 3).
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("max_retries") Integer maxRetries,
|
||
|
|
/**
|
||
|
|
* Sampling temperature for generation tasks.
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("temperature") Double temperature,
|
||
|
|
/**
|
||
|
|
* Maximum tokens to generate.
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("max_tokens") Long maxTokens
|
||
|
|
) {
|
||
|
|
public static Builder builder() {
|
||
|
|
return new Builder();
|
||
|
|
}
|
||
|
|
|
||
|
|
// CPD-OFF
|
||
|
|
@JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
|
||
|
|
public static final class Builder {
|
||
|
|
|
||
|
|
private String model = "";
|
||
|
|
@JsonProperty("api_key")
|
||
|
|
private String apiKey = null;
|
||
|
|
@JsonProperty("base_url")
|
||
|
|
private String baseUrl = null;
|
||
|
|
@JsonProperty("timeout_secs")
|
||
|
|
private Long timeoutSecs = null;
|
||
|
|
@JsonProperty("max_retries")
|
||
|
|
private Integer maxRetries = null;
|
||
|
|
private Double temperature = null;
|
||
|
|
@JsonProperty("max_tokens")
|
||
|
|
private Long maxTokens = null;
|
||
|
|
|
||
|
|
/** Sets the model field. */
|
||
|
|
@JsonProperty("model")
|
||
|
|
public Builder withModel(final String value) {
|
||
|
|
this.model = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the apiKey field. */
|
||
|
|
@JsonProperty("api_key")
|
||
|
|
public Builder withApiKey(final @Nullable String value) {
|
||
|
|
this.apiKey = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the baseUrl field. */
|
||
|
|
@JsonProperty("base_url")
|
||
|
|
public Builder withBaseUrl(final @Nullable String value) {
|
||
|
|
this.baseUrl = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the timeoutSecs field. */
|
||
|
|
@JsonProperty("timeout_secs")
|
||
|
|
public Builder withTimeoutSecs(final @Nullable Long value) {
|
||
|
|
this.timeoutSecs = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the maxRetries field. */
|
||
|
|
@JsonProperty("max_retries")
|
||
|
|
public Builder withMaxRetries(final @Nullable Integer value) {
|
||
|
|
this.maxRetries = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the temperature field. */
|
||
|
|
@JsonProperty("temperature")
|
||
|
|
public Builder withTemperature(final @Nullable Double value) {
|
||
|
|
this.temperature = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the maxTokens field. */
|
||
|
|
@JsonProperty("max_tokens")
|
||
|
|
public Builder withMaxTokens(final @Nullable Long value) {
|
||
|
|
this.maxTokens = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Builds the LlmConfig instance. */
|
||
|
|
public LlmConfig build() {
|
||
|
|
return new LlmConfig(
|
||
|
|
model,
|
||
|
|
apiKey,
|
||
|
|
baseUrl,
|
||
|
|
timeoutSecs,
|
||
|
|
maxRetries,
|
||
|
|
temperature,
|
||
|
|
maxTokens
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// CPD-ON
|
||
|
|
}
|