Skip to content

Commit

Permalink
fix: write chatGptLabel instead of chatGPTLabel for consistency with …
Browse files Browse the repository at this point in the history
…chatGptClient object
  • Loading branch information
waylaidwanderer committed Feb 2, 2023
1 parent 933fca4 commit 3170de2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const clientOptions = {
// (Optional) Set a custom name for the user
// userLabel: 'User',
// (Optional) Set a custom name for ChatGPT
// chatGPTLabel: 'ChatGPT',
// chatGptLabel: 'ChatGPT',
// (Optional) Set to true to enable `console.debug()` logging
debug: false,
};
Expand Down Expand Up @@ -107,7 +107,7 @@ module.exports = {
// (Optional) Set a custom name for the user
// userLabel: 'User',
// (Optional) Set a custom name for ChatGPT
// chatGPTLabel: 'ChatGPT',
// chatGptLabel: 'ChatGPT',
// (Optional) Set to true to enable `console.debug()` logging
debug: false,
},
Expand Down
6 changes: 3 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async function conversation(conversationId = null, parentMessageId = null) {
if (message === '!exit') {
return true;
}
const chatGPTLabel = settings.chatGptClient?.chatGPTLabel || 'ChatGPT';
const spinner = ora(`${chatGPTLabel} is typing...`);
const chatGptLabel = settings.chatGptClient?.chatGptLabel || 'ChatGPT';
const spinner = ora(`${chatGptLabel} is typing...`);
spinner.prefixText = '\n';
spinner.start();
try {
Expand All @@ -56,7 +56,7 @@ async function conversation(conversationId = null, parentMessageId = null) {
spinner.stop();
conversationId = response.conversationId;
parentMessageId = response.messageId;
console.log(boxen(response.response, { title: chatGPTLabel, padding: 0.7, margin: 1, dimBorder: true }));
console.log(boxen(response.response, { title: chatGptLabel, padding: 0.7, margin: 1, dimBorder: true }));
} catch (error) {
spinner.stop();
console.log(boxen(error?.json?.error?.message || error.body, { title: 'Error', padding: 0.7, margin: 1, borderColor: 'red' }));
Expand Down
2 changes: 1 addition & 1 deletion settings.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
// (Optional) Set a custom name for the user
// userLabel: 'User',
// (Optional) Set a custom name for ChatGPT
// chatGPTLabel: 'ChatGPT',
// chatGptLabel: 'ChatGPT',
// (Optional) Set to true to enable `console.debug()` logging
debug: false,
},
Expand Down
6 changes: 3 additions & 3 deletions src/ChatGPTClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export default class ChatGPTClient {
}

const userLabel = this.options.userLabel || 'User';
const chatGPTLabel = this.options.chatGPTLabel || 'ChatGPT';
const chatGptLabel = this.options.chatGptLabel || 'ChatGPT';

const promptSuffix = `${chatGPTLabel}:\n`; // Prompt should end with 2 newlines, so we add one here.
const promptSuffix = `${chatGptLabel}:\n`; // Prompt should end with 2 newlines, so we add one here.

let currentTokenCount = this.getTokenCount(`${promptPrefix}${promptSuffix}`);
let promptBody = '';
Expand All @@ -147,7 +147,7 @@ export default class ChatGPTClient {
// Iterate backwards through the messages, adding them to the prompt until we reach the max token count.
while (currentTokenCount < maxTokenCount && orderedMessages.length > 0) {
const message = orderedMessages.pop();
const roleLabel = message.role === 'User' ? userLabel : chatGPTLabel;
const roleLabel = message.role === 'User' ? userLabel : chatGptLabel;
const messageString = `${roleLabel}:\n${message.message}<|im_sep|>\n`;
const newPromptBody = `${messageString}${promptBody}`;

Expand Down

0 comments on commit 3170de2

Please sign in to comment.