transitive-bullshit / bing-chat

Node.js client for Bing's new AI-powered search. It's like ChatGPT on steroids 🔥
MIT License
1.22k stars 128 forks source link

Use in a normal nodejs program... #70

Open Zibri opened 3 months ago

Zibri commented 3 months ago

after issuing npm install bing-chat, I tried this:

$ cat >chat.js
   import { BingChat } from 'bing-chat';

   async function main() {
       // Initialize the API with your valid cookie
       const api = new BingChat({ cookie: process.env.BING_COOKIE });

       // Send a message to Bing Chat
       const response = await api.sendMessage('Hello, how can I help?');
       console.log('Bing Chat response:', response.text);
   }

   main();

then node chat.js

obviously import can't be used outside a module so it does not work. how can I use it in a normal main.js file executed as node main.js ?

Zibri commented 3 months ago

Done:

import('bing-chat').then(_=>{

   BingChat=_.BingChat;
   async function main() {
       // Initialize the API with your valid cookie
       const api = new BingChat({ cookie: process.env.BING_COOKIE });

       // Send a message to Bing Chat
       const response = await api.sendMessage('Hello, how can I help?');
       console.log('Bing Chat response:', response.text);
   }

   main();

});
carefulcomputer commented 3 months ago

i am getting blank response. any ideas ? also my cookies do not have any _U cookie, did anything change in Bing ?

murnifine commented 3 months ago

i am getting blank response. any ideas ? also my cookies do not have any _U cookie, did anything change in Bing ?

same with me