Giter Site home page Giter Site logo

bingchat-api's Introduction

Bing Chat API

Deployment

Deploy natively

  git clone https://github.com/tuhinpal/bingchat-api.git
  cd bingchat-api
  npm run build
  npm start

Deploy with Docker

  git clone https://github.com/tuhinpal/bingchat-api.git
  cd bingchat-api
  docker build -t bingchat-api .
  docker run -it -d -p 8080:8080 bingchat-api

Or, You can fork this repository and connect it to any provider which supports Docker/NodeJS.

Post Deploy

This api need your cookie to generate conversation. So, you should have beta access. After deployment login to that bing account and open developer console. Then paste the code (replace your serverUrl).

const cookie = document.cookie;
const serverUrl = "http://localhost:8080";

fetch(`${serverUrl}/set-cookie`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ cookie }),
})
  .then((res) => res.json())
  .then((res) => console.log(res))
  .catch((err) => console.log(err));

API Reference

Create a conversation

  POST /create-conversation

Generate

  GET /generate
Query Parameter Type Description
conversationId string Required. Get it after /create-conversation
clientId string Required. Get it after /create-conversation
conversationSignature string Required. Get it after /create-conversation
text string Required. Text prompt

Note: It uses EventSource stream to send content upon generation.

Client library

Use the client library to implement these with ease.

npm install bing-chatai-client
import { createConversation, Generate } from "bing-chatai-client";

const conversation = await createConversation("http://localhost:8080");

console.log(conversation);

const gen = new Generate(conversation.conversationUrl);

gen.generate("Hello bing what is an ai?");

gen.onMessage((data) => {
  console.log(data);
});

gen.onFinished((message) => {
  console.info(message);
});

gen.onError((message) => {
  console.error(message);
});

Author

Feedback

If you have any feedback, please reach me out at me[at]thetuhin.com.

Contributing

Contributions are always welcome!

License and Leagal

This project is licensed under MIT. This project is made as a proof of concept and doesnot meant to harm microsoft.

bingchat-api's People

Contributors

tuhinpal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.