Fix config option provider to only become active for chatgpt things (#15578)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2023-09-23 17:59:40 +02:00 committed by GitHub
parent 7f56f0579a
commit 4059003e9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -39,16 +39,18 @@ public class ChatGPTModelOptionProvider implements ThingHandlerService, ConfigOp
@Override @Override
public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable String context, public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable String context,
@Nullable Locale locale) { @Nullable Locale locale) {
String accountParameterUrl = "thing-type:" + ChatGPTBindingConstants.THING_TYPE_ACCOUNT.getAsString();
if (accountParameterUrl.equals(uri.toString())) {
if ("model".equals(param)) { if ("model".equals(param)) {
List<ParameterOption> options = new ArrayList<>(); List<ParameterOption> options = new ArrayList<>();
if (thingHandler instanceof ChatGPTHandler chatGPTHandler) { if (thingHandler instanceof ChatGPTHandler chatGPTHandler) {
chatGPTHandler.getModels().forEach(model -> options.add(new ParameterOption(model, model))); chatGPTHandler.getModels().forEach(model -> options.add(new ParameterOption(model, model)));
} }
return options; return options;
} else {
return null;
} }
} }
return null;
}
@Override @Override
public void setThingHandler(ThingHandler handler) { public void setThingHandler(ThingHandler handler) {