gnodet commented on code in PR #25171:
URL: https://github.com/apache/camel/pull/25171#discussion_r3668700715
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/LlmClient.java:
##########
@@ -1481,8 +1582,89 @@ private String readBaseUrlFromPidFile(Path pidFile)
throws Exception {
// ---- URL helpers ----
+ static boolean isAzureOpenAiEndpoint(String endpoint) {
+ if (endpoint == null || endpoint.isBlank()) {
+ return false;
+ }
+ return endpoint.contains(".openai.azure.com") ||
endpoint.contains("/openai/deployments/");
+ }
+
+ static String stripTrailingSlash(String endpoint) {
+ if (endpoint == null || endpoint.isEmpty()) {
+ return endpoint;
+ }
+ return endpoint.endsWith("/") ? endpoint.substring(0,
endpoint.length() - 1) : endpoint;
+ }
+
+ String azureResourceBase(String endpoint) {
+ String u = stripTrailingSlash(endpoint);
+ int openAiPath = u.indexOf("/openai");
+ if (openAiPath > 0) {
+ return u.substring(0, openAiPath);
+ }
+ return u;
+ }
+
+ String resolveAzureApiVersion() {
+ String fromEnv = System.getenv("AZURE_OPENAI_API_VERSION");
+ if (fromEnv != null && !fromEnv.isBlank()) {
+ return fromEnv;
+ }
+ return azureApiVersion != null ? azureApiVersion :
DEFAULT_AZURE_API_VERSION;
+ }
Review Comment:
Minor: `resolveAzureApiVersion()` re-reads `AZURE_OPENAI_API_VERSION` from
`System.getenv()` but `tryAzureOpenAi()` already cached it in the
`azureApiVersion` field (which defaults to `DEFAULT_AZURE_API_VERSION`). The
null check on line 1613 is dead code since the field is always initialized.
This could be simplified to:
```suggestion
String resolveAzureApiVersion() {
return azureApiVersion;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]