Skip to content

Commit aa33a37

Browse files
authored
[chatgpt] Adapt HLI service to support core's LLM-based HLI framework (#21132)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
1 parent aba648a commit aa33a37

24 files changed

Lines changed: 1088 additions & 747 deletions

bundles/org.openhab.binding.chatgpt/README.md

Lines changed: 35 additions & 119 deletions
Large diffs are not rendered by default.

bundles/org.openhab.binding.chatgpt/src/main/java/org/openhab/binding/chatgpt/internal/ChatGPTBindingConstants.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@
2424
*/
2525
@NonNullByDefault
2626
public class ChatGPTBindingConstants {
27-
2827
private static final String BINDING_ID = "chatgpt";
2928

3029
// List of all Thing Type UIDs
3130
public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, "account");
3231

3332
// List of all Channel ids
3433
public static final String CHANNEL_CHAT = "chat";
35-
3634
public static final ChannelTypeUID CHANNEL_TYPE_UID_CHAT = new ChannelTypeUID(BINDING_ID, CHANNEL_CHAT);
35+
36+
// Default values for configuration parameters
37+
public static final String DEFAULT_BASE_URL = "https://api.openai.com/v1";
38+
public static final String DEFAULT_MODEL = "gpt-4o-mini";
39+
public static final double DEFAULT_TEMPERATURE = 1.0;
40+
public static final double DEFAULT_TOP_P = 1.0;
41+
public static final int DEFAULT_MAX_TOKENS = 1000;
42+
public static final int DEFAULT_MAX_MODEL_TURNS = 10;
43+
public static final String DEFAULT_SYSTEM_MESSAGE = "You are a helpful assistant.";
44+
public static final int DEFAULT_REQUEST_TIMEOUT = 10;
3745
}

bundles/org.openhab.binding.chatgpt/src/main/java/org/openhab/binding/chatgpt/internal/ChatGPTChannelConfiguration.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,10 @@
2222
*/
2323
@NonNullByDefault
2424
public class ChatGPTChannelConfiguration {
25-
26-
public String model = "gpt-4o-mini";
27-
28-
public Double temperature = 0.5;
29-
30-
public Double topP = 1.0;
31-
32-
public String systemMessage = "";
33-
34-
public int maxTokens = 500;
35-
25+
public @Nullable String model;
26+
public @Nullable Double temperature;
27+
public @Nullable Double topP;
28+
public @Nullable Integer maxTokens;
29+
public @Nullable String systemMessage;
3630
public @Nullable Integer requestTimeout;
3731
}

bundles/org.openhab.binding.chatgpt/src/main/java/org/openhab/binding/chatgpt/internal/ChatGPTConfiguration.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
*/
1313
package org.openhab.binding.chatgpt.internal;
1414

15+
import static org.openhab.binding.chatgpt.internal.ChatGPTBindingConstants.*;
16+
1517
import org.eclipse.jdt.annotation.NonNullByDefault;
18+
import org.eclipse.jdt.annotation.Nullable;
1619

1720
/**
1821
* The {@link ChatGPTConfiguration} class contains fields mapping thing configuration parameters.
@@ -21,17 +24,17 @@
2124
*/
2225
@NonNullByDefault
2326
public class ChatGPTConfiguration {
24-
27+
// API
28+
public String baseUrl = DEFAULT_BASE_URL;
29+
// Kept for backward compatibility
30+
public @Nullable String apiUrl;
2531
public String apiKey = "";
26-
public String apiUrl = "https://api.openai.com/v1/chat/completions";
27-
public String modelUrl = "https://api.openai.com/v1/models";
28-
public boolean useSemanticModel = true;
29-
public String model = "gpt-4o-mini";
30-
public Double temperature = 1.0;
31-
public Integer maxTokens = 1000;
32-
public Double topP = 1.0;
33-
public String systemMessage = "";
34-
public Integer keepContext = 2;
35-
public Integer contextThreshold = 10000;
36-
public Integer requestTimeout = ChatGPTHandler.DEFAULT_REQUEST_TIMEOUT_S;
32+
// Connection
33+
public Integer requestTimeout = DEFAULT_REQUEST_TIMEOUT;
34+
// HLI
35+
public String model = DEFAULT_MODEL;
36+
public Double temperature = DEFAULT_TEMPERATURE;
37+
public Double topP = DEFAULT_TOP_P;
38+
public Integer maxTokens = DEFAULT_MAX_TOKENS;
39+
public Integer maxModelTurns = DEFAULT_MAX_MODEL_TURNS;
3740
}

0 commit comments

Comments
 (0)