-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.2 version that fixes repetitive answers and added user context (#98)
* fix: Stop Sydney from repeating previous answers * feat: Added easy way for users to set their own context * 1.0.2
- Loading branch information
Showing
5 changed files
with
244 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "sydney-whatsapp-bot", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "WhatsApp chatbot", | ||
"main": "src/index.ts", | ||
"scripts": { | ||
|
@@ -11,6 +11,7 @@ | |
"author": "Matheus Veiga <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/common-tags": "^1.8.1", | ||
"@types/fluent-ffmpeg": "^2.1.21", | ||
"@types/node": "^20.3.2", | ||
"nodemon": "^2.0.22", | ||
|
@@ -22,7 +23,8 @@ | |
"@ffmpeg/ffmpeg": "^0.11.6", | ||
"@keyv/sqlite": "^3.6.5", | ||
"@types/qrcode-terminal": "^0.12.0", | ||
"@waylaidwanderer/chatgpt-api": "^1.37.1", | ||
"@waylaidwanderer/chatgpt-api": "1.37.0", | ||
"common-tags": "^1.8.2", | ||
"fluent-ffmpeg": "^2.1.2", | ||
"keyv": "^4.5.2", | ||
"openai": "^3.2.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { oneLine, stripIndent } from "common-tags"; | ||
import { Message } from "whatsapp-web.js"; | ||
|
||
export async function getContext(message: Message) { | ||
let context = "[system](#additional_instructions)\n"; | ||
let context = stripIndent`[system](#additional_instructions) | ||
# Important guidelines for your role as an assistant: | ||
- You should not present yourself in every message.`; | ||
|
||
const contact = await message.getContact(); | ||
const chat = await message.getChat(); | ||
|
||
if (chat.isGroup) | ||
context += `You are in a WhatsApp group chat. You don't know the group chat's name. This message was sent by: ${contact.pushname}.\nDon't use '@' to mention users when referring to them.`; | ||
context += `- You are in a WhatsApp group chat. You don't know the group chat's name. This message was sent by: ${contact.pushname}.\nWhen referring to users, do not use '@' mentions.`; | ||
else | ||
context += `You are in a WhatsApp private chat. The user name is ${contact.pushname}.`; | ||
context += `- You are in a WhatsApp private chat. The user's name is ${contact.pushname}.`; | ||
|
||
return context; | ||
return context + process.env.USER_CONTEXT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.