3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Bing の AIチャットを Node.js で試す(Node.js v18以上)

Posted at

はじめに

Bing AIチャットの順番待ち登録が済んでいる事が大前提となっています。

やっておくと楽な行為

Cookie に関する操作があるので、Edgeアドオン『Cookie Editor』を使って Cookie を閲覧すると作業が楽になります。

導入部分

npm install bing-chat dotenv
package.json
{
+  "type": "module",
  "name": "bing-chat-qiita-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "bing-chat": "^0.2.1",
    "dotenv": "^16.0.3"
  }
}
.env
BING_COOKIE="Cookie「_U」 の Value をここに設置してください。"

コード

main.js
import dotenv from 'dotenv'
import { BingChat } from 'bing-chat'

dotenv.config();

(async () => {
  const api = new BingChat({
    cookie: process.env.BING_COOKIE
  });

  const res = await api.sendMessage('こんにちは');
  console.log(res.text);
})();
output
こんにちは、Bingです。どうぞよろしくお願いします。😊

注意

非公式ライブラリを用いての実装の為、Bing Chat 自体の仕様変更により動作不能になる恐れがある事をご了承ください。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?