Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Synced from GitLab - Deploy your own Serverless Discord bot integration to quickly interface with Bing's AI (a.k.a Sydney) using their reverse engineered API

License

Notifications You must be signed in to change notification settings

jarylc/cf-workers-bingai-sydney-discord-bot

Repository files navigation

cf-workers-bingai-sydney-discord-bot

Logo

Description

Example

Serverless Discord bot in webhook mode to quickly interface with BingAI a.k.a Sydney's using a reversed engineered API.

This is much slower than ChatGPT variants as there is no way to disable streaming mode (words generate one at a time) and I have to capture when the stream ends.

Note: This is mainly for personal use, if you would like to add features, do fork the repository. Do perform PRs back if you would be so kind!

Prerequisites

Getting Started

Wrangler

  1. Sign in to https://www.bing.com/ on the browser
  2. Clone this repository
  3. Run npm ci or yarn install
  4. Replace {DISCORD_TOKEN} and {DISCORD_APPLICATION_ID} in the following DISCORD_TOKEN={DISCORD_TOKEN} DISCORD_APPLICATION_ID={DISCORD_APPLICATION_ID} npx node src/register.js and run it to register the bot commands
  5. Run npx wrangler secret put DISCORD_APPLICATION_ID and set the Discord app's ID
  6. Run npx wrangler secret put DISCORD_PUBLIC_KEY and set the Discord app's public key
  7. Run npx wrangler secret put DISCORD_TOKEN and set the Discord bot's token
  8. Run npx wrangler secret put BING_COOKIE and set your latest Bing cookie request header on https://edgeservices.bing.com/edgesvc/turing/conversation/create
  9. Add space-delimited user IDs to whitelist in DISCORD_USERID_WHITELIST in wrangler.toml
  10. (Optional) To enable context, run npx wrangler kv:namespace create session and replace the ID of BINGAI_SYDNEY_DISCORD_BOT_KV wrangler.toml, else remove kv_namespaces block entirely from wrangler.toml
  11. (Optional) Choose your BING_CONVERSATION_STYLE by commenting and uncommenting accordingly in wrangler.toml
  12. (Optional) Update BING_BEHAVIOR in wrangler.toml with your desired behavior / system message
  13. Run npx wrangler publish to deploy to Cloudflare Workers
  14. Set the Interactions Endpoint URL of your Discord application to the URL of the deployed worker

(On cookie expiry, roughly 2 weeks) Renewing BING_COOKIE

  1. Sign in to https://www.bing.com/ on the browser
  2. Run npx wrangler secret put BING_COOKIE and set your latest Bing cookie request header on https://edgeservices.bing.com/edgesvc/turing/conversation/create

About

Synced from GitLab - Deploy your own Serverless Discord bot integration to quickly interface with Bing's AI (a.k.a Sydney) using their reverse engineered API

Topics

Resources

License

Stars

Watchers

Forks