davsclaus commented on code in PR #24594:
URL: https://github.com/apache/camel/pull/24594#discussion_r3564893489


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/LlmClient.java:
##########
@@ -1126,11 +1215,41 @@ private String sendAnthropicStreamingRequest(String 
requestUrl, JsonObject body,
 
     // ---- Endpoint detection helpers ----
 
+    // Order matters: /api/tags is checked before /v1/models, matching the 
original priority.
+    private static final List<Map.Entry<String, ApiType>> 
EXPLICIT_URL_HEALTH_CHECK_SUFFIXES = List.of(

Review Comment:
   The previous `tryExplicitUrl()` made a single `isEndpointReachable(url)` 
call. This now probes `url + "/api/tags"` and `url + "/v1/models"` first, 
adding 1–2 extra HTTP requests during endpoint detection. If a non-Ollama 
service happens to respond at `/api/tags`, the API type could be mis-detected. 
Worth a quick note in the PR description or a comment here explaining the 
detection priority.



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AiPanel.java:
##########
@@ -187,22 +234,29 @@ void open() {
 
     void close() {
         visible = false;
+        providerSwitchPopup.close();
     }
 
     void destroy() {
         close();
-        Thread t = agentThread;
-        if (t != null) {
-            t.interrupt();
-        }
+        stopAgentThread();
     }
 
     private void initClient() {
         try {
-            client = LlmClient.create()
+            LlmClient created = LlmClient.create()
                     .withTemperature(0.3)
                     .withTimeout(120)
-                    .withMaxTokens(4096);
+                    .withMaxTokens(4096)
+                    .withModel("llama3.2");

Review Comment:
   The default model `llama3.2` is set here before `applyChoice()` runs. If the 
user configures `camel.tui.ai.provider=anthropic` (or `openai`) in settings but 
leaves `camel.tui.ai.model` blank, `applyChoice()` skips the model override 
(because `model` is null/blank) and `llama3.2` is sent to the Anthropic/OpenAI 
API, which would reject it.
   
   Before this PR, `initClient()` did not set a default model at all.
   
   Consider either:
   - Removing the default and letting each provider use its own default, or
   - Setting the default conditionally based on the detected/configured 
provider.



-- 
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]

Reply via email to