diff --git a/docs/modules/ROOT/pages/includes/quarkus-langchain4j-openai.adoc b/docs/modules/ROOT/pages/includes/quarkus-langchain4j-openai.adoc index 801b1ded4..19df5e0d6 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-langchain4j-openai.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-langchain4j-openai.adoc @@ -215,6 +215,57 @@ endif::add-copy-button-to-env-var[] |`true` +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-type]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-type[quarkus.langchain4j.openai.proxy-type]` + + +[.description] +-- +The Proxy type + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_TYPE+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_TYPE+++` +endif::add-copy-button-to-env-var[] +--|string +|`HTTP` + + +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-host]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-host[quarkus.langchain4j.openai.proxy-host]` + + +[.description] +-- +The Proxy host + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_HOST+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_HOST+++` +endif::add-copy-button-to-env-var[] +--|string +| + + +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-port]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-proxy-port[quarkus.langchain4j.openai.proxy-port]` + + +[.description] +-- +The Proxy port + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_PORT+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_PROXY_PORT+++` +endif::add-copy-button-to-env-var[] +--|int +|`3128` + + a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-chat-model-model-name]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-chat-model-model-name[quarkus.langchain4j.openai.chat-model.model-name]` @@ -851,6 +902,57 @@ endif::add-copy-button-to-env-var[] |`true` +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-type]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-type[quarkus.langchain4j.openai."model-name".proxy-type]` + + +[.description] +-- +The Proxy type + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_TYPE+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_TYPE+++` +endif::add-copy-button-to-env-var[] +--|string +|`HTTP` + + +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-host]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-host[quarkus.langchain4j.openai."model-name".proxy-host]` + + +[.description] +-- +The Proxy host + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_HOST+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_HOST+++` +endif::add-copy-button-to-env-var[] +--|string +| + + +a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-port]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-proxy-port[quarkus.langchain4j.openai."model-name".proxy-port]` + + +[.description] +-- +The Proxy port + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_PORT+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI__MODEL_NAME__PROXY_PORT+++` +endif::add-copy-button-to-env-var[] +--|int +|`3128` + + a| [[quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-chat-model-model-name]]`link:#quarkus-langchain4j-openai_quarkus-langchain4j-openai-model-name-chat-model-model-name[quarkus.langchain4j.openai."model-name".chat-model.model-name]` 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 index 7f4e8b791..bb8fce130 100644 --- 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 @@ -1,5 +1,8 @@ package io.quarkiverse.langchain4j.openai.runtime; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.Proxy.Type; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; @@ -74,6 +77,10 @@ public Function, ChatLanguageModel .stop(chatModelConfig.stop().orElse(null)); openAiConfig.organizationId().ifPresent(builder::organizationId); + openAiConfig.proxyHost().ifPresent(host -> { + builder.proxy(new Proxy(Type.valueOf(openAiConfig.proxyType()), + new InetSocketAddress(host, openAiConfig.proxyPort()))); + }); if (chatModelConfig.maxTokens().isPresent()) { builder.maxTokens(chatModelConfig.maxTokens().get()); @@ -121,6 +128,10 @@ public Supplier streamingChatModel(LangChain4jOpenAi .stop(chatModelConfig.stop().orElse(null)); openAiConfig.organizationId().ifPresent(builder::organizationId); + openAiConfig.proxyHost().ifPresent(host -> { + builder.proxy(new Proxy(Type.valueOf(openAiConfig.proxyType()), + new InetSocketAddress(host, openAiConfig.proxyPort()))); + }); if (chatModelConfig.maxTokens().isPresent()) { builder.maxTokens(chatModelConfig.maxTokens().get()); @@ -165,6 +176,10 @@ public Supplier embeddingModel(LangChain4jOpenAiConfig runtimeCo } openAiConfig.organizationId().ifPresent(builder::organizationId); + openAiConfig.proxyHost().ifPresent(host -> { + builder.proxy(new Proxy(Type.valueOf(openAiConfig.proxyType()), + new InetSocketAddress(host, openAiConfig.proxyPort()))); + }); return new Supplier<>() { @Override @@ -201,6 +216,10 @@ public Supplier moderationModel(LangChain4jOpenAiConfig runtime .modelName(moderationModelConfig.modelName()); openAiConfig.organizationId().ifPresent(builder::organizationId); + openAiConfig.proxyHost().ifPresent(host -> { + builder.proxy(new Proxy(Type.valueOf(openAiConfig.proxyType()), + new InetSocketAddress(host, openAiConfig.proxyPort()))); + }); return new Supplier<>() { @Override diff --git a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/LangChain4jOpenAiConfig.java b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/LangChain4jOpenAiConfig.java index dbf39c46b..b09049352 100644 --- a/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/LangChain4jOpenAiConfig.java +++ b/model-providers/openai/openai-vanilla/runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/config/LangChain4jOpenAiConfig.java @@ -93,6 +93,23 @@ interface OpenAiConfig { @WithDefault("true") Boolean enableIntegration(); + /** + * The Proxy type + */ + @WithDefault("HTTP") + String proxyType(); + + /** + * The Proxy host + */ + Optional proxyHost(); + + /** + * The Proxy port + */ + @WithDefault("3128") + Integer proxyPort(); + /** * Chat model related settings */