Add whitelist of openai models.

Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
Adam Treat 2025-02-21 11:41:15 -05:00
parent 51c45e5d47
commit e6429140dd
2 changed files with 13 additions and 1 deletions

View File

@ -62,6 +62,15 @@ ColumnLayout {
providerName: qsTr("OpenAI")
providerImage: "qrc:/gpt4all/icons/openai.svg"
providerDesc: qsTr('OpenAI provides access to advanced AI models, including GPT-4 supporting a wide range of applications, from conversational AI to content generation and code completion.<br><br>Get your API key: <a href="https://platform.openai.com/signup">https://openai.com/</a>')
Component.onCompleted: {
filterModels = function(names) {
// Define a whitelist of allowed names
var whitelist = ["gpt-3.5-turbo", "gpt-4o", "gpt-4", "gpt-4-turbo", "gpt-4-32k", "gpt-3.5-turbo-16k"];
// Filter names based on the whitelist
return names.filter(name => whitelist.includes(name));
}
}
}
RemoteModelCard {
Layout.preferredWidth: 600

View File

@ -23,6 +23,9 @@ Rectangle {
property alias providerDesc: providerDescLabel.helpText
property string providerBaseUrl: ""
property bool providerIsCustom: false
property var filterModels: function(names) {
return names;
};
color: theme.conversationBackground
radius: 10
@ -103,7 +106,7 @@ Rectangle {
onTextChanged: {
apiKeyField.placeholderTextColor = theme.mutedTextColor;
if (!providerIsCustom) {
myModelList.model = ModelList.remoteModelList(apiKeyField.text, providerBaseUrl);
myModelList.model = filterModels(ModelList.remoteModelList(apiKeyField.text, providerBaseUrl));
myModelList.currentIndex = -1;
}
}