Skip to content

Commit

Permalink
Fix config option provider to only become active for chatgpt things (#…
Browse files Browse the repository at this point in the history
…15578)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer authored Sep 23, 2023
1 parent 7f56f05 commit 4059003
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ public class ChatGPTModelOptionProvider implements ThingHandlerService, ConfigOp
@Override
public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable String context,
@Nullable Locale locale) {
if ("model".equals(param)) {
List<ParameterOption> options = new ArrayList<>();
if (thingHandler instanceof ChatGPTHandler chatGPTHandler) {
chatGPTHandler.getModels().forEach(model -> options.add(new ParameterOption(model, model)));
String accountParameterUrl = "thing-type:" + ChatGPTBindingConstants.THING_TYPE_ACCOUNT.getAsString();
if (accountParameterUrl.equals(uri.toString())) {
if ("model".equals(param)) {
List<ParameterOption> options = new ArrayList<>();
if (thingHandler instanceof ChatGPTHandler chatGPTHandler) {
chatGPTHandler.getModels().forEach(model -> options.add(new ParameterOption(model, model)));
}
return options;
}
return options;
} else {
return null;
}
return null;
}

@Override
Expand Down

0 comments on commit 4059003

Please sign in to comment.