Shortcut to my personal portfolio site.
npx transitive-bullshit
- transitivebullsh.it - Source for the portfolio site itself.
MIT © Travis Fischer
Support my OSS work by following me on twitter
Node.js client for Bing's new AI-powered search. It's like ChatGPT on steroids 🔥
License: MIT License
Shortcut to my personal portfolio site.
npx transitive-bullshit
MIT © Travis Fischer
Support my OSS work by following me on twitter
This project is great, but sometimes I don't get a reply when I use it. I use await
to receive response
, not onProgress
I just set the cookie to ''
and it still worked for the example in the README.
We should update the documentation if the project becomes active again
How can we use this module with Langchainjs https://js.langchain.com/docs/api/llms_base/classes/LLM
Native fetch is not present in Nodejs versions before v18. Many cloud environments are still running older nodejs versions (eg: AWS uses v16 for Alexa).
Using packages like Axios would enable support for older versions of nodejs.
Bing has a new feature additon to allow for us to use the chat for image generation with DALL-E 3 image generation engine. Was wondering if we can get this api to interact with that image generation also
npx tsx d:\code\python\binggpt\bing-chat-main\demos\demo.ts
windows 11
✖ What are today’s top stories in the United States?
Error: unexpected HTTP error createConversation 403: Forbidden
at (d:\code\python\binggpt\bing-chat-main\src\bing-chat.ts:317:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at BingChat.sendMessage (d:\code\python\binggpt\bing-chat-main\src\bing-chat.ts:65:28)
at async oraPromise (file:///d:/code/python/binggpt/bing-chat-main/node_modules/ora/index.js:397:18)
at main (d:\code\python\binggpt\bing-chat-main\demos\demo.ts:20:15)
I can log in https://www.bing.com,Can chat normally
Why would you report 403?
Unsure if this is even something that is possible, but has anyone looked into reverse engineering the _U cookie generation such that it would not have to be manually refreshed every few days? This would be super useful if a new cookie can be generated through an endpoint or node.js so that a service might be totally self sufficient.
Bing chat has Normal, Balanced and Precise modes, it would be nice to be able to set this via a parameter.
The previous issue was closed without a solution.
I get this message, no matter how recent my _u cookie is even though i have access to the new bing. Any solutions?
The idea would be to be able to send inside sendMessage
a base64 encoded image as to get also an analysis on it. There is an endpoint https://www.bing.com/images/kblob
from which through a POST I believe you can generate a blobId
, processedBlobId
.
Once the kblob is generated, a GET request is performed to assess that the upload is successful (?).
Anyone knows how to do it?
Thank you :)
When I send a message, I will see a message like the title and no response will be returned. If I send BING's current cookie again, it works, but soon after I get the same error. It seems that BING's cookie expires, is there any way to renew it automatically?
I am just trying to run the demo example with npx tsx demo.ts
but I keep getting this timeout error. I included my _U
cookie
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at BingChat.sendMessage (c:\Users\j50032330\Documents\bing-chat-main\bing-chat-main\src\bing-chat.ts:65:28)
at async oraPromise (file:///C:/Users/j50032330/Documents/bing-chat-main/bing-chat-main/node_modules/ora/index.js:397:18)
at main (c:\Users\j50032330\Documents\bing-chat-main\bing-chat-main\demos\demo.ts:20:15) {
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:8522:28)
at node:internal/deps/undici/undici:8480:50
at Immediate._onImmediate (node:internal/deps/undici/undici:8509:37)
at process.processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
I have access to Bing AI Chat but I have no _U cookie. Did the naming system change?
I am always getting blank response. Is anyone else facing this? I am based out of India. Is that the reason? Connecting to VPN results in error anyway.
The newest version of Bing chat is able to respond to prompts with a DALL-E generated image, so I'm wondering if the api can get return the generated image. Currently the response to a prompt like draw me a cat with a large top hat
is
I'm sorry but I'm not able to draw pictures as I am a text-based conversational agent. However, I can suggest some websites where you can find images of cats with top hats. Would you like me to do that?
Hi, is it possible to utilize the Bing specific features like reading pdfs or URLs through this wrapper? I'm guessing for URLs you can simply have it open a text link but what about reading a file?
When trying to run any of the demos I get this error:
(base) raschidjfr@MacBook-Pro-de-Raschid bing-chat % npx tsx demos/demo
✖ What are today’s top stories in the United States?
Error: unexpected HTTP error createConversation 503: Service Unavailable
at <anonymous> (/Users/raschidjfr/Documents/git/bing-chat/src/bing-chat.ts:317:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at BingChat.sendMessage (/Users/raschidjfr/Documents/git/bing-chat/src/bing-chat.ts:65:28)
at async oraPromise (file:///Users/raschidjfr/Documents/git/bing-chat/node_modules/ora/index.js:397:18)
at main (/Users/raschidjfr/Documents/git/bing-chat/demos/demo.ts:20:15)
The error is traced back to this block. Removing the cookie from the headers seems to fix the problem:
return fetch('https://www.bing.com/turing/conversation/create', {
headers: {
accept: 'application/json',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'application/json',
'sec-ch-ua':
'"Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"',
'sec-ch-ua-arch': '"x86"',
'sec-ch-ua-bitness': '"64"',
'sec-ch-ua-full-version': '"109.0.1518.78"',
'sec-ch-ua-full-version-list':
'"Not_A Brand";v="99.0.0.0", "Microsoft Edge";v="109.0.1518.78", "Chromium";v="109.0.5414.120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-model': '',
'sec-ch-ua-platform': '"macOS"',
'sec-ch-ua-platform-version': '"12.6.0"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-edge-shopping-flag': '1',
'x-ms-client-request-id': requestId,
'x-ms-useragent':
'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/MacIntel',
// cookie <- Removing this line fixes the problem
},
referrer: 'https://www.bing.com/search',
referrerPolicy: 'origin-when-cross-origin',
body: null,
method: 'GET',
mode: 'cors',
credentials: 'include'
})
Hi there- is anyone willing to share whether you can get the bing AI API set up to use it as an OpenAI compatible API?
May be able to use LiteLLM but I'm having trouble figuring it out. They just released a server to host the liteLLM API so could be used (I think) either locally or online via proxy server?
Would be grateful if someone could explain or provide a brief tutorial since I'm struggling to figure it out... Thank you!
Sometimes multiple rounds of dialogue will be interrupted.
For me, the websocket closes mid-generation and I never get a response. When I enable partial responses, I can see that the script just exits mid-response. I did some digging and saw the socket just closes for whatever reason.
Anyone else have that issue?
I need to caption my images using this API
I got the below error while trying to test it at WSL 2 (Ubuntu under Windows), thanks
$ ls
demos docs license main.js media node_modules package-lock.json package.json pnpm-lock.yaml readme.md src tsconfig.json tsup.config.ts typedoc.json
$ cd demos
$ ls
demo-conversation.ts demo-on-progress.ts demo.ts
$ npx tsc demo-conversation.ts
../src/bing-chat.ts:1:8 - error TS1192: Module '"node:crypto"' has no default export.
1 import crypto from 'node:crypto'
~~~~~~
../src/bing-chat.ts:3:8 - error TS1259: Module '"/home/hajsf/bing-chat/node_modules/@types/ws/index"' can only be default-imported using the 'esModuleInterop' flag
3 import WebSocket from 'ws'
~~~~~~~~~
../node_modules/@types/ws/index.d.ts:398:1
398 export = WebSocket;
~~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
Found 2 errors in the same file, starting at: ../src/bing-chat.ts:1
Starting this morning, I've ran into an issue where you can't create a chat without the MUID. It throws a 404. I have my own update to fix that, but I wanted to see if other people have been having that issue.
The MUID comes from Microsoft for ad tracking: https://learn.microsoft.com/en-us/clarity/setup-and-installation/cookie-list
The format looks like a 32 digit hex uppercase / GUID, but you aren't able to spoof it - I tried. I wonder if you can use a blank MR or MR=true and it hits the same middleware and generates a new MUID. I don't know enough about the Microsoft cookies.
Once the MUID and _U are added to the cookie, it works like always.
const fetchOptions = { ...otherStuff, cookie: `MUID=<32-digit-hex>; _U=<user-token>; `}
Is it possible to get the URL from the Bing response? Thank you
I need to caption my images using this API?
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:6571:19)
at successSteps (node:internal/deps/undici/undici:6545:27)
at node:internal/deps/undici/undici:1211:60
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
This error is coming when i send message to api, and thing is it works in windows, but when i try in host it sends above error
i am getting this error while importing the bing-chat into the component
ERROR in node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /home/ankush/bingchat/node_modules/webpack/lib/NormalModule.js:838:25
at Hook.eval [as callAsync] (eval at create (/home/ankush/bingchat/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/ankush/bingchat/node_modules/tapable/lib/Hook.js:18:14)
at Object.processResource (/home/ankush/bingchat/node_modules/webpack/lib/NormalModule.js:835:8)
at processResource (/home/ankush/bingchat/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/home/ankush/bingchat/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/home/ankush/bingchat/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/home/ankush/bingchat/node_modules/webpack/lib/NormalModule.js:825:3)
at NormalModule.build (/home/ankush/bingchat/node_modules/webpack/lib/NormalModule.js:969:15)
at /home/ankush/bingchat/node_modules/webpack/lib/Compilation.js:1377:12
webpack compiled with 1 error and 1 warning
For example, using the prompt Can you explain how Silicon Valley Bank collapsed?
Here's what the official Bing Chat interface generated:
And here's what the reverse engineered API (this repo) generates:
Does anyone have any ideas on why this quality discrepancy is happening? My hypothesis is that the Bing Chat UI is using a newer model. I looked through the network tab whilst interacting with the Bing Chat UI and there doesn't seem to be any difference in the requests.
Any ideas?
Directly using one of the examples, line for line. These are the errors I get. Sometimes I will get a proper request but that is very rare. The errors I get will either be The websocket error one or a Failed fetch: Type Error.
Below is two attempts at running the demo, I was not having this issue the other day.
Hi! I find it cannot handle responses from new bing now. It could work several hours ago, but now it cannot. I think something is changed in the responses of current new bing.
Error log:
file:///app/node_modules/bing-chat/build/index.js:148
const msg = update.arguments[0].messages[0];
^
TypeError: Cannot read properties of undefined (reading '0')
at WebSocket.<anonymous> (file:///app/node_modules/bing-chat/build/index.js:148:55)
at WebSocket.emit (node:events:512:28)
at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1184:20)
at Receiver.emit (node:events:512:28)
at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:541:14)
at Receiver.getData (/app/node_modules/ws/lib/receiver.js:459:17)
at Receiver.startLoop (/app/node_modules/ws/lib/receiver.js:158:22)
at Receiver._write (/app/node_modules/ws/lib/receiver.js:84:10)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
Error: WebSocket error: Error: Unexpected server response: 200
at WebSocket. (file:///home/container/node_modules/bing-chat/build/index.js:83:20)
at WebSocket.emit (node:events:513:28)
at emitErrorAndClose (/home/container/node_modules/ws/lib/websocket.js:1008:13)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
I use your library when I call to get the answer and only get null text results
I've created a wrapper API for this package to use as an endpoint hosted on AWS Lambda, however sometimes it starts returning empty text responses. Redeploying the wrapper to another locale Lambda function works, but that too can start returning empty responses after a point. Not sure what is causing this activity.
To keep conversation context, I tried both:
Neither method worked. The answer always comes with an empty string.
Normal messages without specifying conversationId work as expected.
I am wondering if this is supported at all, since it's not included in the README.md? Thanks.
It will take 30 to 60 seconds to receive a response. Is that normal speed? Is there a way to get a response faster?
i want to add this library on my express but it is not working on server. It works very well on local machine but not working on server side when i host it on any platform
app.post('/chat-wsb-client', async (req, res) => {
try {
const chatClient = new BingChat({
cookie: process.env.UNITRIX,
})
const prompt = req?.body?.chat || 'Hi, How are you?'
const result = await chatClient.sendMessage(prompt, {
variant: 'Precise',
})
res.send({ response: result?.text, cid: result?.conversationId })
} catch (error) {
res.send({ error, msg: 'runtime error' })
}
})
It seems to no longer work, I've tried adding the _U cookie and also tried adding all cookies but it doesn't return any results.
Hi! I find it cannot handle responses from new bing now. It could work several hours ago, but now it cannot. I think something is changed in the responses of current new bing.
Error log:
Error: unexpected HTTP error createConversation 404: Not Found
Hello, first of all, thank you for your reverse engineering work on newbing. I have packaged it as a simple backend API that can post questions and related configurations directly for asking and continuous conversation. If I want to open source it on gitee, what kind of identification should I use? I used bing-chat in the dependencies.
The second question is, if I ask questions in creative mode and it is slightly complex, I may not be able to get a response most of the time. Could you please tell me if your project sets the limit for return time or if it is a limitation from Microsoft's side? I hope this can be resolved.
I am a developer from China. Please let me know if there are any errors in my translation.
I don't really know JavaScript or typescript in this case, so I'm going just to put a link to my work.
Unfortunately this should be done server side, since it requires the same client id, the app or desktop needs and I don't think would be safe to share it in plain text.
Anyway, I though I should share my work with this repo :)
https://github.com/nitanmarcel/sydney-telegram/blob/main/bot_oauth.py
Hi All,
Has anyone faced the following error while running bing-chat (bing-chat-rnz) code from a server located in the United States? I am getting the following error.
WebSocket error: Error: Unexpected server response: 200
Hi, I just found out this repo and I can't make it work, I got the cookie from edge by visiting https://www.bing.com
and in dev tools - applications - cookies for https://www.bing.com get the _U cookie, but when I run the example :
const res = await api.sendMessage('Write a 500 word essay on frogs.', {
// change the variant to 'Precise'
variant: 'Creative'
})
// print the full text at the end
console.log(res)
it just finished up quickly with
{
author: 'bot',
id: '04119b41-7338-48b4-84dd-9b0e2d543964',
conversationId: undefined,
clientId: undefined,
conversationSignature: undefined,
invocationId: '2',
text: ''
}
Is there anything I missing ?
TIA
In fact, I have changed cookies many times and the latest one.
It seems that Microsoft have done any API update and now they require CAPTCHA, any solution? thanks!
"result": {
"value": "CaptchaChallenge",
"message": "User needs to solve CAPTCHA to continue.",
"error": "User needs to solve CAPTCHA to continue.",
"serviceVersion": "20230803.43"
}
delete
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.