1.0.6 • Published 4 months ago

@sumit_shinde_84/node-red-contrib-node-gpt v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

overview

Inquires ChatGPT from the payload string.

install

npm i node-red-contrib-simple-chatgpt

or

Install from the node-red pallete manager

How to use

Input items

ItemDescription
TokenSet the API key for OpenAPI, also you can set token dynamically by msg.token
ModelSpecifies the model name to use. The default is gpt-3.5-turbo.
SystemSettingDescribe the AI assistant settings.
pastMessagesPasses conversation history. Required to continue the conversation.
functionsCan be used from gpt-3.5-turbo-0613 or later. Specified samples are sold separately.
You can forcibly execute the function name specified byfunction_callfunctions. If you set it to auto, the function will be automatically determined and called. If it is none, it will not be called. Specifying {name: function name} will force execution of the target function.

Output items

ItemDescription
payloadYou will receive a ChatGPT response. If the function is executed, null is returned.
pastMessagesReturns a history array of conversations.
When executed withpayloadFunctionFunctionCalling, the executed function name and JSON parsed arguments are returned.

How to specify Functions

A sample of Functions is shown below. Specify the function name, function details, and parameters in array format.

ItemDescription
nameName of the function. You can choose any name you like.
descriptionDetailed description of the function. It is preferable to write in some detail.
parameters.propertiesParameters details. Enter the property name, type, and description you want to set.
parameters.requiredSpecify the required property name that you want returned in the property.
[
     {
         "name": "get_weather",
         "description": "Get the weather for the specified location and date",
         "parameters": {
             "type": "object",
             "properties": {
                 "location": {
                     "type": "string",
                     "description": "Name of prefecture, city, or town, e.g. London"
                 },
                 "date": {
                     "type": "string",
                     "description": "Date formatted in YYYY/MM/DD, e.g. 2023/06/13"
                 }
             },
             "required": [
                 "location",
                 "date"
             ]
         }
     },
     {
         "name": "recommend_book",
         "description": "Introduce one recommended book",
         "parameters": {
             "type": "object",
             "properties": {
                 "title": {
                     "type": "string",
                     "description": "Book title"
                 },
                 "description": {
                     "type": "string",
                     "description": "Book contents"
                 }
             },
             "required": [
                 "title",
                 "description"
             ]
         }
     },
     {
         "name": "hashtag_text",
         "description": "Output a hashtag from the text provided by the user.",
         "parameters": {
             "type": "object",
             "properties": {
                 "tag": {
                     "type": "string",
                     "description": "Please output at least 3 hashtags."
                 }
             },
             "required": [
                 "tag"
             ]
         }
     }
]

For details on how to specify, please see here.

How to specify function_call

In addition to auto or none as a string, specify the name of the function to be forcibly executed on the Json object. This is an example when the above Functions are given. hashtag_text is now forced.

{
     "name": "hashtag_text"
}
1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago