Skip to content

New bing chat api with golang. Use your cookie to make conversation.

License

Notifications You must be signed in to change notification settings

NoahAmethyst/bingchat-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bing Chat

WARN Due to the use of robot check in bingChat, the api is temporarily unuseful.

Requirements

Export Bingchat Cookie

  • Install Cookie-Editor in your browser.
  • Export bing.com cookies with json

Warn

This project currently support parallel sessions (multi sessions) and context

Please make sure that websocket be closed at the end of conversation

Use

go get github.com/NoahAmethyst/bingchat-api

Example

You can see example codes in chat_test.go which include conversation with context and multi conversations

Test

import (
"fmt"
bingchat_api "github.com/NoahAmethyst/bingchat-api"
"os"
"strings"
"testing"
"time"
)

func Test_Conversation(t *testing.T) {
    chat, err := bingchat_api.NewBingChat(os.Getenv("COOKIE"), bingchat_api.ConversationBalanceStyle, 2*time.Minute)
    if err != nil {
        panic(err)
    }

    defer func() {
        chat.Close()
        t.Logf("%+v", chat.CheckAlive())
    }()
	
    message, err := chat.SendMessage("how is the weather today in Seattle")
    if err != nil {
        panic(err)
    }
	
    var respBuilder strings.Builder
    for {
        msg, ok := <-message.Notify
        if !ok {
            fmt.Println()
            break
        }
        respBuilder.WriteString(msg)
    }

    t.Logf("%s", respBuilder.String())

}

About

New bing chat api with golang. Use your cookie to make conversation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages