fix: setting extension placeholder and input action apikey (#3430)
* fix: setting extension placeholder apikey * fix: extension settings migration --------- Co-authored-by: Louis <louis@jan.ai>
This commit is contained in:
parent
7c9d49ba60
commit
ab8af53a24
@ -122,13 +122,16 @@ export abstract class BaseExtension implements ExtensionType {
|
||||
await fs.mkdir(extensionSettingFolderPath)
|
||||
const settingFilePath = await joinPath([extensionSettingFolderPath, this.settingFileName])
|
||||
|
||||
// Persists new setting only
|
||||
// Persists new settings
|
||||
if (await fs.existsSync(settingFilePath)) {
|
||||
const oldSettings = JSON.parse(await fs.readFileSync(settingFilePath, 'utf-8'))
|
||||
if (Array.isArray(oldSettings))
|
||||
settings = oldSettings.concat(
|
||||
settings.filter((e) => !oldSettings.some((o) => o.key === e.key))
|
||||
)
|
||||
settings.forEach((setting) => {
|
||||
// Keep setting value
|
||||
if (setting.controllerProps && Array.isArray(oldSettings))
|
||||
setting.controllerProps.value = oldSettings.find(
|
||||
(e: any) => e.key === setting.key
|
||||
)?.controllerProps?.value
|
||||
})
|
||||
}
|
||||
await fs.writeFileSync(settingFilePath, JSON.stringify(settings, null, 2))
|
||||
} catch (err) {
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "anthropic-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Anthropic API uses API keys for authentication. Visit your [API Keys](https://console.anthropic.com/settings/keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://api.anthropic.com/v1/messages",
|
||||
"value": "https://api.anthropic.com/v1/messages"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "anthropic-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Anthropic API uses API keys for authentication. Visit your [API Keys](https://console.anthropic.com/settings/keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "cohere-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Cohere API uses API keys for authentication. Visit your [API Keys](https://dashboard.cohere.com/api-keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://api.cohere.ai/v1/chat",
|
||||
"value": "https://api.cohere.ai/v1/chat"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "cohere-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Cohere API uses API keys for authentication. Visit your [API Keys](https://dashboard.cohere.com/api-keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "groq-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Groq API uses API keys for authentication. Visit your [API Keys](https://console.groq.com/keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://api.groq.com/openai/v1/chat/completions",
|
||||
"value": "https://api.groq.com/openai/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "groq-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Groq API uses API keys for authentication. Visit your [API Keys](https://console.groq.com/keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "martian-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Martian API uses API keys for authentication. Visit your [API Keys](https://withmartian.com/dashboard) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://withmartian.com/api/openai/v1/chat/completions",
|
||||
"value": "https://withmartian.com/api/openai/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "martian-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Martian API uses API keys for authentication. Visit your [API Keys](https://withmartian.com/dashboard) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "mistral-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Mistral API uses API keys for authentication. Visit your [API Keys](https://console.mistral.ai/api-keys/) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://api.mistral.ai/v1/chat/completions",
|
||||
"value": "https://api.mistral.ai/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "mistral-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Mistral API uses API keys for authentication. Visit your [API Keys](https://console.mistral.ai/api-keys/) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "nvidia-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The NVIDIA API uses API keys for authentication. Visit your [API Keys](https://org.ngc.nvidia.com/setup/personal-keys) page to retrieve the API key you'll use in your requests..",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,17 +20,5 @@
|
||||
"placeholder": "https://integrate.api.nvidia.com/v1/chat/completions",
|
||||
"value": "https://integrate.api.nvidia.com/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "nvidia-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The NVIDIA API uses API keys for authentication. Visit your [API Keys](https://org.ngc.nvidia.com/setup/personal-keys) page to retrieve the API key you'll use in your requests..",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "nvapi-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "openai-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The OpenAI API uses API keys for authentication. Visit your [API Keys](https://platform.openai.com/account/api-keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "https://api.openai.com/v1/chat/completions",
|
||||
"value": "https://api.openai.com/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "openai-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The OpenAI API uses API keys for authentication. Visit your [API Keys](https://platform.openai.com/account/api-keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,23 +1,14 @@
|
||||
[
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
"description": "The endpoint to use for chat completions. See the [OpenRouter API documentation](https://openrouter.ai/docs) for more information.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "https://openrouter.ai/api/v1/chat/completions",
|
||||
"value": "https://openrouter.ai/api/v1/chat/completions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "openrouter-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The OpenRouter API uses API keys for authentication. Visit your [API Keys](https://openrouter.ai/keys) page to retrieve the API key you'll use in your requests.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -28,6 +19,6 @@
|
||||
"controllerProps": {
|
||||
"placeholder": "Leave empty for default model",
|
||||
"value": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"key": "tritonllm-api-key",
|
||||
"title": "API Key",
|
||||
"description": "The Triton LLM API uses API keys for authentication.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "Insert API Key",
|
||||
"value": "",
|
||||
"type": "password",
|
||||
"inputActions": ["unobscure", "copy"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "chat-completions-endpoint",
|
||||
"title": "Chat Completions Endpoint",
|
||||
@ -8,16 +20,5 @@
|
||||
"placeholder": "http://localhost:8000/v2/models/tensorrt_llm_bls/generate",
|
||||
"value": "http://localhost:8000/v2/models/tensorrt_llm_bls/generate"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "tritonllm-api-key",
|
||||
"title": "Triton LLM API Key",
|
||||
"description": "The Triton LLM API uses API keys for authentication.",
|
||||
"controllerType": "input",
|
||||
"controllerProps": {
|
||||
"placeholder": "xxxxxxxxxxxxxxxxxxxx",
|
||||
"value": "",
|
||||
"type": "password"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user