You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to access 2 different remote OpenAI-API-compatible services for the chat and embed-models.
This fails, as the embedding model does not have its own base-url and api-key
Same applies to imageModel and moderationModel.
I think having those overrides is important as the OpenAI-API is kind of becoming a default API for many LLM-servers (InstructLab , Ollama in OpenAI mode, ..)
The following patch illustrates a potential fix, that works on my laptop :)
---
Index: model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/EmbeddingModelConfig.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/EmbeddingModelConfig.java b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/EmbeddingModelConfig.java
--- a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/EmbeddingModelConfig.java (revision a8864444916d915b178eda65ee7665934e0ac7e8)
+++ b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/EmbeddingModelConfig.java (date 1737111305494)
@@ -31,4 +31,14 @@
* A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
*/
Optional<String> user();
+
+ /**
+ * Base URL override for the embedding model
+ */
+ Optional<String> baseUrl();
+
+ /**
+ * Api key override for the embedding model
+ */
+ Optional<String> apiKey();
}
Index: model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/OpenAiRecorder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/OpenAiRecorder.java b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/OpenAiRecorder.java
--- a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/OpenAiRecorder.java (revision a8864444916d915b178eda65ee7665934e0ac7e8)
+++ b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/OpenAiRecorder.java (date 1737110791953)
@@ -189,8 +189,8 @@
builder
.tlsConfigurationName(openAiConfig.tlsConfigurationName().orElse(null))
.configName(configName)
- .baseUrl(openAiConfig.baseUrl())
- .apiKey(apiKey)
+ .baseUrl(embeddingModelConfig.baseUrl().orElse(openAiConfig.baseUrl()))
+ .apiKey(embeddingModelConfig.apiKey().orElse(apiKey))
.timeout(openAiConfig.timeout().orElse(Duration.ofSeconds(10)))
.maxRetries(openAiConfig.maxRetries())
.logRequests(firstOrDefault(false, embeddingModelConfig.logRequests(), openAiConfig.logRequests()))
The text was updated successfully, but these errors were encountered:
To be honest, I am not terribly excited about the each component of LangChain4jOpenAiConfig having it's own base URL and api key configuration.
Can you please attach a sample project that you are using and that currently fails? I want to fully understand your use case and how you are trying to implement it.
I am trying to access 2 different remote OpenAI-API-compatible services for the chat and embed-models.
This fails, as the embedding model does not have its own base-url and api-key
Same applies to imageModel and moderationModel.
I think having those overrides is important as the OpenAI-API is kind of becoming a default API for many LLM-servers (InstructLab , Ollama in OpenAI mode, ..)
The following patch illustrates a potential fix, that works on my laptop :)
The text was updated successfully, but these errors were encountered: