chatgpt-official
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -16,2 +16,5 @@ import axios from "axios"; | ||
presence_penalty: options?.presence_penalty || 0, | ||
instructions: options?.instructions || | ||
`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09`, | ||
}; | ||
@@ -24,5 +27,4 @@ } | ||
}; | ||
conversation.messages.push(`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09 | ||
Current date: ${this.getToday()}\n\n`); | ||
conversation.messages.push(`${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`); | ||
this.conversations.push(conversation); | ||
@@ -45,5 +47,4 @@ return conversation; | ||
conversation.messages = []; | ||
conversation.messages.push(`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09 | ||
Current date: ${this.getToday()}\n\n`); | ||
conversation.messages.push(`${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`); | ||
conversation.lastActive = Date.now(); | ||
@@ -56,4 +57,7 @@ } | ||
prompt = prompt[prompt.length - 1].includes([",", "!", "?", "."]) ? prompt : `${prompt}.`; | ||
conversation.messages.push(`${prompt}\n\n`); | ||
conversation.messages.push(`${prompt}<|im_end|>`); | ||
conversation.messages = conversation.messages.slice(-this.options.historySize); | ||
if (!conversation.messages[0].includes("Current date:")) | ||
conversation.messages[0] = `${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`; | ||
conversation.lastActive = Date.now(); | ||
@@ -69,3 +73,3 @@ let promptStr = conversation.messages.join("\n"); | ||
presence_penalty: this.options.presence_penalty, | ||
stop: ["\n\n"], | ||
stop: ["<|im_end|>"], | ||
}, { | ||
@@ -77,7 +81,4 @@ headers: { | ||
}); | ||
let responseStr = response.data.choices[0].text | ||
.replace(/<\|im_end\|>/g, "") | ||
.replace(/\n\n/g, "") | ||
.trim(); | ||
conversation.messages.push(`${responseStr}\n\n`); | ||
let responseStr = response.data.choices[0].text.replace(/<\|im_end\|>/g, "").trim(); | ||
conversation.messages.push(`${responseStr}<|im_end|>`); | ||
return responseStr; | ||
@@ -84,0 +85,0 @@ } |
@@ -8,3 +8,4 @@ interface options { | ||
presence_penalty?: number; | ||
instructions?: string; | ||
} | ||
export default options; |
{ | ||
"name": "chatgpt-official", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "ChatGPT Client using official OpenAI API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -20,2 +20,6 @@ import axios from "axios"; | ||
presence_penalty: options?.presence_penalty || 0, | ||
instructions: | ||
options?.instructions || | ||
`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09`, | ||
}; | ||
@@ -29,5 +33,4 @@ } | ||
}; | ||
conversation.messages.push(`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09 | ||
Current date: ${this.getToday()}\n\n`); | ||
conversation.messages.push(`${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`); | ||
this.conversations.push(conversation); | ||
@@ -53,5 +56,4 @@ | ||
conversation.messages = []; | ||
conversation.messages.push(`You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. | ||
Knowledge cutoff: 2021-09 | ||
Current date: ${this.getToday()}\n\n`); | ||
conversation.messages.push(`${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`); | ||
conversation.lastActive = Date.now(); | ||
@@ -66,4 +68,6 @@ } | ||
prompt = prompt[prompt.length - 1].includes([",", "!", "?", "."]) ? prompt : `${prompt}.`; // Thanks to https://github.com/optionsx | ||
conversation.messages.push(`${prompt}\n\n`); | ||
conversation.messages.push(`${prompt}<|im_end|>`); | ||
conversation.messages = conversation.messages.slice(-this.options.historySize); | ||
if(!conversation.messages[0].includes("Current date:")) conversation.messages[0] = `${this.options.instructions} | ||
Current date: ${this.getToday()}<|im_end|>`; | ||
conversation.lastActive = Date.now(); | ||
@@ -81,3 +85,3 @@ let promptStr = conversation.messages.join("\n"); | ||
presence_penalty: this.options.presence_penalty, | ||
stop: ["\n\n"], | ||
stop: ["<|im_end|>"], | ||
}, | ||
@@ -92,7 +96,4 @@ { | ||
let responseStr = response.data.choices[0].text | ||
.replace(/<\|im_end\|>/g, "") | ||
.replace(/\n\n/g, "") | ||
.trim(); | ||
conversation.messages.push(`${responseStr}\n\n`); | ||
let responseStr = response.data.choices[0].text.replace(/<\|im_end\|>/g, "").trim(); | ||
conversation.messages.push(`${responseStr}<|im_end|>`); | ||
return responseStr; | ||
@@ -99,0 +100,0 @@ } |
@@ -8,4 +8,5 @@ interface options { | ||
presence_penalty?: number; | ||
instructions?: string; | ||
} | ||
export default options; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45326
285