]> git.basschouten.com Git - openhab-addons.git/commitdiff
[chatgpt] Set proper default values for channel configuration (#15451)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Sat, 19 Aug 2023 18:49:37 +0000 (20:49 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Aug 2023 18:49:37 +0000 (20:49 +0200)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
bundles/org.openhab.binding.chatgpt/src/main/java/org/openhab/binding/chatgpt/internal/ChatGPTChannelConfiguration.java
bundles/org.openhab.binding.chatgpt/src/main/java/org/openhab/binding/chatgpt/internal/ChatGPTHandler.java

index c25aeaf98098a62fa26abcc953ff3c68fab94955..26e904263702a7e6356961c542f7ffc13b839945 100644 (file)
@@ -22,11 +22,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 @NonNullByDefault
 public class ChatGPTChannelConfiguration {
 
-    public String model = "";
+    public String model = "gpt-3.5-turbo";
 
-    public float temperature;
+    public float temperature = 0.5f;
 
     public String systemMessage = "";
 
-    int maxTokens;
+    int maxTokens = 500;
 }
index 62f4e5920009576b4bb9df6fd1b7521460d89275..e39b1bc11908538e4aedfaa80e0b0619fc46fe18 100644 (file)
@@ -122,9 +122,11 @@ public class ChatGPTHandler extends BaseThingHandler {
         messages.add(userMessage);
         root.add("messages", messages);
 
+        String queryJson = gson.toJson(root);
         Request request = httpClient.newRequest(OPENAI_API_URL).method(HttpMethod.POST)
                 .header("Content-Type", "application/json").header("Authorization", "Bearer " + apiKey)
-                .content(new StringContentProvider(gson.toJson(root)));
+                .content(new StringContentProvider(queryJson));
+        logger.trace("Query '{}'", queryJson);
         try {
             ContentResponse response = request.send();
             updateStatus(ThingStatus.ONLINE);