modulepackage
0.0.0-20230508142603-f684a9379652
Repository: https://github.com/databingo/edgegpt-go.git
Documentation: pkg.go.dev
# README
🪄 EdgeGPT-Go
Feature:
- GRPC interface
- Library interface
- Sync/Async request
- CLI interface
- Refresh session
How to use it:
Getting authentication (Required)
- Install and open Microsoft Edge browser
- Install Cookie-Editor extension
- Go to New Bing login and getting access
- Open the extension
- Click "Export" on the bottom right, then "Export as JSON" (This saves your cookies to clipboard)
- Create folder
cookies
- Paste your cookies into a file
1.json
If you have several accounts - repeat for each of them and save to the cookies
folder
Use as a chat cli app
docker run -it -v ./cookies:/app/cookies ghcr.io/Databingo/edgegpt-chat
Or download binary in release page
Use as a library
go get github.com/Databingo/EdgeGPT-Go
package main
import (
"github.com/Databingo/EdgeGPT-Go"
"log"
)
func main() {
s := EdgeGPT.NewStorage()
gpt, err := s.GetOrSet("any-key")
if err != nil {
log.Fatalln(err)
}
// send ask async
mw, err := gpt.AskAsync("Hi, you're alive?")
if err != nil {
log.Fatalln(err)
}
go mw.Worker() // start worker
for range mw.Chan {
// update answer
log.Println(mw.Answer.GetAnswer())
log.Println(mw.Answer.GetType())
log.Println(mw.Answer.GetSuggestions())
log.Println(mw.Answer.GetMaxUnit())
log.Println(mw.Answer.GetUserUnit())
}
// send sync ask
as, err := gpt.AskSync("Show an example of sockets in golang gorilla")
if err != nil {
log.Fatalln(err)
}
log.Println(as.Answer.GetAnswer())
}
Use as a docker microservice
docker run -v ./cookies:/app/cookies -p 8080:8080 ghcr.io/Databingo/edgegpt-grpc:latest
Use as a docker-compose
version: "3"
services:
gpt:
image: ghcr.io/Databingo/edgegpt-grpc:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- ./cookies:/app/cookies
Available environment
Name | Default | Description |
---|---|---|
CONVERSATION_ENDPOINT | https://edgeservices.bing.com/edgesvc/turing/conversation/create | Endpoint for getting conversation |
LOG_LEVEL | INFO | Log level. Avalible:
|
Example service
Work progress...
FAQ:
Change protoc
If you change protoc file, use protoc --go_out=. --go-grpc_out=. proto/gpt.proto
Stopped after 10 redirects
If you use this library in China set environment:
CONVERSATION_ENDPOINT=https://edge.churchless.tech/edgesvc/turing/conversation/create
Example:
docker run -e CONVERSATION_ENDPOINT=https://edge.churchless.tech/edgesvc/turing/conversation/create -v ./cookies:/app/cookies -p 8080:8080 ghcr.io/Databingo/edgegpt-grpc:latest
Or docker-compose:
version: "3"
services:
gpt:
image: ghcr.io/Databingo/edgegpt-grpc:latest
restart: unless-stopped
environment:
- CONVERSATION_ENDPOINT=https://edge.churchless.tech/edgesvc/turing/conversation/create
ports:
- "8080:8080"
volumes:
- ./cookies:/app/cookies
# Functions
NewGPT create new service.
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
Storage for GPT sessions.