From 96a97f9cd973e1aae1349d38ecb4e221c1ac4763 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 20 May 2024 17:34:31 +0300 Subject: [PATCH] Add default values for URLS of HuggingFace models This makes it much easier to construct these programmatically Closes: #602 --- .../langchain4j/huggingface/QuarkusHuggingFaceChatModel.java | 3 ++- .../huggingface/QuarkusHuggingFaceEmbeddingModel.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceChatModel.java b/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceChatModel.java index 02f0b74dd..a87d8033d 100644 --- a/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceChatModel.java +++ b/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceChatModel.java @@ -22,6 +22,7 @@ import dev.langchain4j.model.huggingface.client.TextGenerationResponse; import dev.langchain4j.model.huggingface.spi.HuggingFaceClientFactory; import dev.langchain4j.model.output.Response; +import io.quarkiverse.langchain4j.huggingface.runtime.config.ChatModelConfig; /** * This is a Quarkus specific version of the HuggingFace model. @@ -121,7 +122,7 @@ public static final class Builder { private Integer maxNewTokens; private Boolean returnFullText; private Boolean waitForModel = true; - private URI url; + private URI url = URI.create(ChatModelConfig.DEFAULT_INFERENCE_ENDPOINT); private Optional doSample; private OptionalInt topK; diff --git a/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceEmbeddingModel.java b/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceEmbeddingModel.java index 67d2b96c1..2a5da785a 100644 --- a/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceEmbeddingModel.java +++ b/hugging-face/runtime/src/main/java/io/quarkiverse/langchain4j/huggingface/QuarkusHuggingFaceEmbeddingModel.java @@ -15,6 +15,7 @@ import dev.langchain4j.model.huggingface.client.HuggingFaceClient; import dev.langchain4j.model.huggingface.spi.HuggingFaceClientFactory; import dev.langchain4j.model.output.Response; +import io.quarkiverse.langchain4j.huggingface.runtime.config.EmbeddingModelConfig; /** * This is a Quarkus specific version of the HuggingFace model. @@ -81,7 +82,7 @@ public static final class Builder { private String accessToken; private Duration timeout = Duration.ofSeconds(15); private Boolean waitForModel = true; - private URI url; + private URI url = URI.create(EmbeddingModelConfig.DEFAULT_INFERENCE_ENDPOINT_EMBEDDING); public Builder accessToken(String accessToken) { this.accessToken = accessToken;