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


##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/FakeLlmServer.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
+
+/**
+ * A local server that plays an LLM for the tests of the AI commands: Ollama 
(its models, and the answer of the model,
+ * whole or streamed in two parts) and an OpenAI-compatible chat completion. 
It keeps the last question it answered.
+ */
+final class FakeLlmServer implements AutoCloseable {
+
+    private final HttpServer server;
+    private volatile String answer;

Review Comment:
   Done in a6b04463e2d9: `answer` is `final` now (only `lastRequest` crosses 
threads).
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Harden.java:
##########
@@ -230,20 +237,21 @@ public Integer doCall() throws Exception {
     }
 
     private void printConfiguration(String endpoint, String resolvedApiKey) {
-        printer().println("LLM Configuration:");
-        printer().println("  URL: " + endpoint);
-        printer().println("  API Type: " + apiType);
-        printer().println("  Model: " + model);
+        printer().printDiagnostic("LLM Configuration:");
+        printer().printDiagnostic("  URL: " + endpoint);
+        printer().printDiagnostic("  API Type: " + apiType);
+        printer().printDiagnostic("  Model: " + model);
         printMaskedApiKey(resolvedApiKey);
-        printer().println();
+        printer().printDiagnostic("");
     }
 
     private void printMaskedApiKey(String key) {

Review Comment:
   Agreed — left for a follow-up rather than this test PR: `Harden` still has 
its own HTTP client, and moving it onto `LlmClient` (as `Explain` and `overview 
--ai` use) would give the three commands one configuration, prompt and key 
handling in one go.
   
   _Claude Code on behalf of davsclaus_



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