[chatgpt] Set proper default values for channel configuration (#15451)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-08-19 20:49:37 +02:00 committed by Kai Kreuzer
parent 313cca64cc
commit 177d75e7dd
2 changed files with 6 additions and 4 deletions

View 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;
}

View 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);