initial version

This commit is contained in:
Maciej Lebiest 2025-06-09 17:44:57 +02:00
parent 529afd4eaa
commit edb5499caf
3 changed files with 65 additions and 0 deletions

31
openai-config.html Normal file
View file

@ -0,0 +1,31 @@
<script type="text/javascript">
RED.nodes.registerType('openai-config', {
category: 'config',
color: '#a6bbcf',
defaults: {
name: {value: ""},
apiUrl: {value: ""}
},
credentials: {
apiToken: {type: "password"}
},
label: function () {
return this.name || "openai-config";
}
});
</script>
<script type="text/html" data-template-name="openai-config">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-apiUrl"><i class="fa fa-link"></i> API URL</label>
<input type="text" id="node-input-apiUrl" placeholder="API URL">
</div>
<div class="form-row">
<label for="node-input-apiToken"><i class="fa fa-key"></i> API Token</label>
<input type="password" id="node-input-apiToken" placeholder="API Token">
</div>
</script>

12
openai-config.js Normal file
View file

@ -0,0 +1,12 @@
module.exports = function(RED) {
function OpenAIConfigNode(config) {
RED.nodes.createNode(this, config);
this.apiUrl = config.apiUrl;
this.apiToken = config.apiToken;
}
RED.nodes.registerType("openai-config", OpenAIConfigNode, {
credentials: {
apiToken: { type: "password" }
}
});
}

22
package.json Normal file
View file

@ -0,0 +1,22 @@
{
"name": "node-red-contrib-openai-config",
"version": "1.0.0",
"description": "A configuration node for OpenAI-like API URL and token",
"main": "openai-config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"node-red",
"openai",
"config"
],
"author": "Your Name",
"license": "MIT",
"node-red": {
"nodes": {
"openai-config": "openai-config.js"
}
},
"dependencies": {}
}