npm install @rubberduckai/chatbot.js
mkdir template
cd template
wget https://raw.githubusercontent.com/rubberduck-ai/chatbot.js/main/example/prompt.template
cd ..
npm chatbot --host 127.0.0.1 --port 3000 --template-folder template --open-ai-api-key YOUR_OPEN_AI_API_KEY
curl -X POST http://127.0.0.1:3000/chat
Response:
{"id":"0","messages":[]}%
curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{ "message": "how can i get the current date in javascript" }' http://127.0.0.1:3000/chat/0/message
Response:
{"id":"0","messages":[{"author":"user","text":"how can i get the current date in javascript"},{"author":"bot","text":" To get the current date in JavaScript, you can use the Date object. The Date object provides methods for working with dates and times. For example, you can use the Date.now() method to get the current timestamp in milliseconds. You can also use the Date.getFullYear() method to get the current year. If you need to format the date in a specific way, you can use the Intl.DateTimeFormat() method. This method allows you to specify the locale and the format of the date."}]}%
Pre-requisites: brew install pnpm
- Install dependencies:
pnpm install
- Start server:
pnpm start