WIP: provider types are recongized properly in qml

This commit is contained in:
Jared Van Bortel
2025-03-19 19:32:59 -04:00
parent b359c9245c
commit f71f8577ae
11 changed files with 90 additions and 55 deletions

View File

@@ -13,6 +13,7 @@ import download
import modellist
import network
import gpt4all
import gpt4all.store_provider
import mysettings
import localdocs
@@ -55,28 +56,38 @@ ColumnLayout {
height: parent.childHeight
provider: modelData
providerName: provider.name
providerImage: provider.icon
providerDesc: ({
'{20f963dc-1f99-441e-ad80-f30a0a06bcac}': qsTr(
'Groq offers a high-performance AI inference engine designed for low-latency and ' +
'efficient processing. Optimized for real-time applications, Groqs technology is ideal ' +
'for users who need fast responses from open large language models and other AI ' +
'workloads.<br><br>Get your API key: ' +
'<a href="https://console.groq.com/keys">https://groq.com/</a>'
),
'{6f874c3a-f1ad-47f7-9129-755c5477146c}': 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>'
),
'{7ae617b3-c0b2-4d2c-9ff2-bc3f049494cc}': qsTr(
'Mistral AI specializes in efficient, open-weight language models optimized for various ' +
'natural language processing tasks. Their models are designed for flexibility and ' +
'performance, making them a solid option for applications requiring scalable AI ' +
'solutions.<br><br>Get your API key: <a href="https://mistral.ai/">https://mistral.ai/</a>'
),
})[provider.id.toString()]
providerImage: "icon" in provider ? provider.icon : "qrc:/gpt4all/icons/antenna_3.svg"
providerDesc: {
if (!provider.isBuiltin) {
switch (provider.type) {
case ProviderStore.ProviderType.openai:
return qsTr("A custom OpenAI provider.");
case ProviderStore.ProviderType.ollama:
return qsTr("A custom Ollama provider.");
}
}
return ({
'{20f963dc-1f99-441e-ad80-f30a0a06bcac}': qsTr(
'Groq offers a high-performance AI inference engine designed for low-latency and ' +
'efficient processing. Optimized for real-time applications, Groqs technology is ideal ' +
'for users who need fast responses from open large language models and other AI ' +
'workloads.<br><br>Get your API key: ' +
'<a href="https://console.groq.com/keys">https://groq.com/</a>'
),
'{6f874c3a-f1ad-47f7-9129-755c5477146c}': 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>'
),
'{7ae617b3-c0b2-4d2c-9ff2-bc3f049494cc}': qsTr(
'Mistral AI specializes in efficient, open-weight language models optimized for various ' +
'natural language processing tasks. Their models are designed for flexibility and ' +
'performance, making them a solid option for applications requiring scalable AI ' +
'solutions.<br><br>Get your API key: <a href="https://mistral.ai/">https://mistral.ai/</a>'
),
})[provider.id.toString()];
}
}
}
}

View File

@@ -131,6 +131,8 @@ Rectangle {
}
onTextChanged: {
if (!initialized) return;
console.log(`${provider} has an apiKey: ${('apiKey' in provider)},${typeof provider.apiKey},${provider.apiKey}`);
return;
ok = provider.setApiKeyQml(text.trim()) && text.trim() !== "";
}
placeholderText: qsTr("Provider API Key")
@@ -208,7 +210,7 @@ Rectangle {
property string apiKeyText: apiKeyField.text.trim()
property string modelNameText: myModelList.currentText.trim()
enabled: baseUrlGood && apiKeyGood && modelNameText !== ""
enabled: nameField.ok && baseUrlField.ok && apiKeyField.ok && modelNameText !== ""
onClicked: {
Download.installCompatibleModel(