Skip to content

Commit

Permalink
Attach the handler once to avoid too many listeners error
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Mar 11, 2024
1 parent e259ece commit 8f43f11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ask-llm.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ const SYSTEM_PROMPT = 'Answer the question politely and concisely.';
const messages = [];
messages.push({ role: 'system', content: SYSTEM_PROMPT });

let loop = true;
const interface = readline.createInterface({ input: process.stdin, output: process.stdout });
interface.on('close', () => { loop = false; });

const qa = () => {
let loop = true;
interface.on('close', () => { loop = false; });
interface.question('>> ', async (question) => {
messages.push({ role: 'user', content: question });
const start = Date.now();
Expand Down

0 comments on commit 8f43f11

Please sign in to comment.