Skip to content

Commit 18db9b6

Browse files
committed
In azure openai extension, need a way to override the base url
Fixes #149
1 parent 3362655 commit 18db9b6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/AzureOpenAiRecorder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ public Object get() {
9090
}
9191

9292
private String getBaseUrl(Langchain4jAzureOpenAiConfig runtimeConfig) {
93-
return String.format("https://%s.openai.azure.com/openai/deployments/%s", runtimeConfig.resourceName(),
94-
runtimeConfig.deploymentId());
93+
var baseUrl = runtimeConfig.baseUrl();
94+
95+
return !baseUrl.trim().isEmpty() ? baseUrl
96+
: String.format("https://%s.openai.azure.com/openai/deployments/%s", runtimeConfig.resourceName(),
97+
runtimeConfig.deploymentId());
9598
}
9699

97100
public void cleanUp(ShutdownContext shutdown) {

openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/config/Langchain4jAzureOpenAiConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public interface Langchain4jAzureOpenAiConfig {
2222
*/
2323
String deploymentId();
2424

25+
/**
26+
* The base url for the Azure OpenAI resource. Defaults to
27+
* {@code https://${quarkus.langchain4j.azure-openai.resource-name}.openai.azure.com/openai/deployments/${quarkus.langchain4j.azure-openai.deployment-id}}.
28+
*/
29+
@WithDefault("https://${quarkus.langchain4j.azure-openai.resource-name}.openai.azure.com/openai/deployments/${quarkus.langchain4j.azure-openai.deployment-id}")
30+
String baseUrl();
31+
2532
/**
2633
* The API version to use for this operation. This follows the YYYY-MM-DD format
2734
*/

0 commit comments

Comments
 (0)