Skip to content

Commit

Permalink
Properly store credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
HaroldPetersInskipp authored Jan 13, 2024
1 parent 52f32df commit ccbcf96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# Change Log

## [1.2.15] - 2024-01-12

### Changed

- Properly store credentials so they don't accidentally get exported in a flow

## [1.2.14] - 2024-01-12

### Changed
Expand Down
6 changes: 4 additions & 2 deletions chatgpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
color: '#10A37F',
defaults: {
name: { value: "" },
API_KEY: { value: "", required: true },
Organization: { value: "", required: true },
topic: { value: ""},
BaseUrl: { value: "https://api.openai.com" }
},
credentials: {
API_KEY: {type:"text", required: true },
Organization: { type:"text", required: false },
},
inputs:1,
outputs:1,
icon: "arrow-in.png",
Expand Down
13 changes: 9 additions & 4 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = (RED) => {
const node = this;
RED.nodes.createNode(node, config);

// Extract API key and organization information from node configuration
const API_KEY = config.API_KEY;
const ORGANIZATION = config.Organization;
// Extract API key and organization information from credentials
const API_KEY = this.credentials.API_KEY;
const ORGANIZATION = this.credentials.Organization;

// Create OpenAI configuration with the provided API key and organization
const configuration = new Configuration({
Expand Down Expand Up @@ -353,5 +353,10 @@ module.exports = (RED) => {
};

// Register the node type with Node-RED
RED.nodes.registerType("chatgpt", main);
RED.nodes.registerType("chatgpt", main, {
credentials: {
API_KEY: {type:"text"},
Organization: { type:"text"},
},
});
};

0 comments on commit ccbcf96

Please sign in to comment.