Skip to content

Commit

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

Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer authored and Pshatsillo committed Sep 29, 2023
1 parent 4b3beef commit 03c1562
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 03c1562

Please sign in to comment.