Skip to content

Commit

Permalink
Update node to 1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
HaroldPetersInskipp authored Mar 29, 2023
1 parent 88ca52d commit 1a01537
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 41 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@

# Change Log

## [1.2.5] - 2023-03-29

### Added

- Included support for using case insensitive topics input with the `msg.topic` property.

### Changed

- Updated help information displayed in the info tab of the editor. (less verbose "details" section)
- Updated error message and removed unnecessary whitespace.
- Updated `README.md` formating and usage information.

## [1.2.4] - 2023-03-28

### Added
Expand All @@ -9,8 +21,8 @@

### Changed

- Updated help information displayed in the info tab of the editor (`msg.max_tokens` support is now documented)
- Updated the included example to demonstrate new features
- Updated help information displayed in the info tab of the editor. (`msg.max_tokens` support is now documented)
- Updated the included example to demonstrate new features.

## [1.2.3] - 2023-03-23

Expand All @@ -27,7 +39,7 @@

### Changed

- Improved help information displayed in the info tab of the editor
- Improved help information displayed in the info tab of the editor.

## [1.2.2] - 2023-03-10

Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## node-red-contrib-custom-chatgpt

A Node-RED node that interacts with OpenAI machine learning models like "ChatGPT".
A Node-RED node that interacts with OpenAI machine learning models to generate text and image outputs like "ChatGPT" and "DALL·E 2".

### Quick Start

Expand All @@ -26,43 +26,37 @@ To get your `Organization` visit https://platform.openai.com/account/org-setting

Once set-up the node can be controlled with as little as a single required message property `msg.payload`.

### Alternatively you can set the Topic to `read from msg.topic` to set the behavior dynamically with incoming messages, by setting `msg.topic` to a string with the value of `completion`, `image`, `edit`, `turbo` , or `gpt4`.
### Alternatively you can set the Topic to `read from msg.topic` to set the behavior dynamically with incoming messages.

### 1. If `msg.topic` is set to `completion`:
1. When `msg.topic` is set to `completion`:

[Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond.
- [Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond. Its success generally depends on the complexity of the task and quality of your prompt. A good rule of thumb is to think about how you would write a word problem for a middle schooler to solve.

Its success generally depends on the complexity of the task and quality of your prompt. A good rule of thumb is to think about how you would write a word problem for a middle schooler to solve.
2. When `msg.topic` is set to `image`:

### 2. If `msg.topic` is set to `image`:
- [Required] `msg.payload` should be a prompt of text description of the desired image.

[Required] `msg.payload` should be a prompt of text description of the desired image.
- [Optional] `msg.size` should be a string of the desired image dimensions. [Default:`256x256`]

[Optional] `msg.size` should be a string of the desired image dimensions. [Default:`256x256`]
- [Optional] `msg.format` should be a string of either `b64_json` or `url`. [Default:`b64_json`]

[Optional] `msg.format` should be a string of either `b64_json` or `url`. [Default:`b64_json`]
3. When `msg.topic` is set to `edit`:

### 3. If `msg.topic` is set to `edit`:
- [Required] `msg.payload` should be a prompt of text to use as a starting point for the edit.

[Required] `msg.payload` should be a prompt of text to use as a starting point for the edit.
- [Required] `msg.last` should be a string of text to use as the input to be edited.

[Required] `msg.last` should be a string of text to use as the input to be edited.
4. When `msg.topic` is set to `turbo`:

### 4. If `msg.topic` is set to `turbo`:
- [Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond. Its success generally depends on the complexity of the task and quality of your prompt.

[Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond.
- [Optional] `msg.history` should be an array of objects containing the conversation history. [Default:`[]`]

Its success generally depends on the complexity of the task and quality of your prompt.
5. When `msg.topic` is set to `gpt4`:

[Optional] `msg.history` should be an array of objects containing the conversation history. [Default:`[]`]
- [Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond. Its success generally depends on the complexity of the task and quality of your prompt.

### 5. If `msg.topic` is set to `gpt4`:

[Required] `msg.payload` should be a well-written prompt that provides enough information for the model to know what you want and how it should respond.

Its success generally depends on the complexity of the task and quality of your prompt.

[Optional] `msg.history` should be an array of objects containing the conversation history. [Default:`[]`]
- [Optional] `msg.history` should be an array of objects containing the conversation history. [Default:`[]`]


#### Additional optional properties:
Expand Down Expand Up @@ -95,4 +89,8 @@ Please report any issues or feature requests at <a href="https://github.com/Haro

### Changelog

View the full list of [changes](https://github.com/HaroldPetersInskipp/node-red-contrib-chatgpt/blob/main/CHANGELOG.md).
View the full list of [changes](https://github.com/HaroldPetersInskipp/node-red-contrib-chatgpt/blob/main/CHANGELOG.md).

## License

[MIT License](LICENSE)
14 changes: 7 additions & 7 deletions chatgpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</script>
<script type="text/html" data-help-name="chatgpt">
<h1>Description</h1>
<p>A Node-RED node that interacts with OpenAI machine learning models like <a href="https://chat.openai.com/chat">ChatGPT</a>.</p>
<p>A Node-RED node that interacts with OpenAI machine learning models to generate text and image outputs like <a href="https://chat.openai.com/chat">ChatGPT</a> and <a href="https://openai.com/product/dall-e-2">DALL·E 2</a>.</p>
<h2>Setup</h2>
<p>When editing the nodes properties, to get your <code>OPENAI_API_KEY</code> log in to <a href="https://chat.openai.com/chat">ChatGPT</a> then visit <a href="https://platform.openai.com/account/api-keys">https://platform.openai.com/account/api-keys</a> click "+ Create new secret key" then copy and paste the "API key" into the nodes <code>API_KEY</code> property value.</p>
<p>To get your <code>Organization</code> visit <a href="https://platform.openai.com/account/org-settings">https://platform.openai.com/account/org-settings</a> then copy and paste the "OrganizationID" into the nodes <code>Organization</code> property value.</p>
Expand Down Expand Up @@ -135,20 +135,20 @@ <h3>Outputs</h3>
</ol>
<h3>Details</h3>
<p>Select the node's behavior by setting the Topic property value to <code>completion</code>, <code>edit</code>, <code>image</code>, <code>turbo</code>, or <code>gpt4</code>.</p>
<p>Alternatively you can set the Topic to <code>read from msg.topic</code> to set the behavior dynamically with incoming messages, by setting <code>msg.topic</code> to a string with the value of <code>completion</code>, <code>edit</code>, <code>image</code>, <code>turbo</code>, or <code>gpt4</code>.</p>
<p>1. If <code>msg.topic</code> is set to <code>completion</code>:</p>
<p>Alternatively you can set the Topic to <code>read from msg.topic</code> to set the behavior dynamically with incoming messages.</p>
<p>1. When <code>msg.topic</code> is set to <code>completion</code>:</p>
<p>Required <code>msg.payload</code> should be a well-written prompt that provides enough information for the model to know what you want and how it should respond. Its success generally depends on the complexity of the task and quality of your prompt. A good rule of thumb is to think about how you would write a word problem for a middle schooler to solve.</p>
<p>2. If <code>msg.topic</code> is set to <code>image</code>:</p>
<p>2. When <code>msg.topic</code> is set to <code>image</code>:</p>
<p>Required <code>msg.payload</code> should be a prompt of text description of the desired image.</p>
<p>Optional <code>msg.size</code> should be a string of the desired image dimensions. [Default:<code>256x256</code>]</p>
<p>Optional <code>msg.format</code> should be a string of either <code>b64_json</code> or <code>url</code>. [Default:<code>b64_json</code>]</p>
<p>3. If <code>msg.topic</code> is set to <code>edit</code>:</p>
<p>3. When <code>msg.topic</code> is set to <code>edit</code>:</p>
<p>Required <code>msg.payload</code> should be a prompt of text to use as a starting point for the edit.</p>
<p>Required <code>msg.last</code> should be a string of text to use as the input to be edited.</p>
<p>4. If <code>msg.topic</code> is set to <code>turbo</code>:</p>
<p>4. When <code>msg.topic</code> is set to <code>turbo</code>:</p>
<p>Required <code>msg.payload</code> should be a well-written prompt.</p>
<p>Optional <code>msg.history</code> should be an array of objects containing the conversation history. [Default:<code>[]</code>]</p>
<p>5. If <code>msg.topic</code> is set to <code>gpt4</code>:</p>
<p>5. When <code>msg.topic</code> is set to <code>gpt4</code>:</p>
<p>Required <code>msg.payload</code> should be a well-written prompt.</p>
<p>Optional <code>msg.history</code> should be an array of objects containing the conversation history. [Default:<code>[]</code>]</p>
</script>
9 changes: 6 additions & 3 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = (RED) => {
Configuration,
OpenAIApi
} = require("openai");
const ACCEPT_TOPIC_LIST = ["completion", "image", "edit", "turbo", "gpt4"];
const ACCEPT_TOPIC_LIST = ["completion", "image", "edit", "turbo", "gpt4"].map(item => item.toLowerCase());
const main = function (config) {
const node = this;
RED.nodes.createNode(node, config);
Expand All @@ -24,13 +24,16 @@ module.exports = (RED) => {
if (config.topic != "__EMPTY__") {
msg.topic = config.topic;
};
if ((msg.topic != "completion") && (msg.topic != "image") && (msg.topic != "edit") && (msg.topic != "turbo") && (msg.topic != "gpt4") && (msg.topic != "__EMPTY__")) {
if (msg.topic) {
msg.topic.toLowerCase();
};
if (!ACCEPT_TOPIC_LIST.includes(msg.topic) && msg.topic !== "__empty__") {
node.status({
fill: "red",
shape: "dot",
text: "msg.topic is incorrect"
});
node.error(`msg.topic must be one of ${ACCEPT_TOPIC_LIST.map(item => ` '${item}' `).join(", ")}`)
node.error(`msg.topic must be a string set to one of the following values: ${ACCEPT_TOPIC_LIST.map(item => `'${item}'`).join(", ")}`)
node.send(msg)
} else if (msg.topic === "image") {
try {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-red-contrib-custom-chatgpt",
"version": "1.2.4",
"description": "ChatGPT in Node-RED",
"version": "1.2.5",
"description": "A Node-RED node that interacts with OpenAI machine learning models to generate text and image outputs like 'ChatGPT' and 'DALL·E 2'.",
"main": "chatgpt.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -27,9 +27,9 @@
"code-generation",
"conversational-ai",
"gpt-3",
"gpt-35-turbo-0301",
"gpt-4",
"gpt-4-0314"
"dall-e",
"ai"
],
"node-red": {
"version": ">=2.0.0",
Expand Down

0 comments on commit 1a01537

Please sign in to comment.