Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lowczarc authored Aug 11, 2023
1 parent 0e4ed06 commit 69d7f4c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,24 @@ import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
import { Chat } from "polyfact";

// We use the nodeJS readline API to extract the user inputs from the standard input of the terminal
// It can be change to whatever interface you want the user to interact with, readline is just for
// the example.
const rl = readline.createInterface({ input, output });

async function chatREPL() {
// We initialize a new polyfact chat
const chat = new Chat();

while (true) {
// We retrieve the userInput from the nodeJS readline API
const userInput = await rl.question("> ");

console.log(await chat.sendMessage(userInput));
// We get an answer from the polyfact API to the message the user sent
const aiAnswer = await chat.sendMessage(userInput);

// And we print it to the standard output
console.log(aiAnswer);
}
}

Expand Down

0 comments on commit 69d7f4c

Please sign in to comment.