api

package
v0.0.0-...-43b39ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatGPTApiPrefix    = "/chatgpt"
	ImitateApiPrefix    = "/imitate/v1"
	ChatGPTApiUrlPrefix = "https://chat.openai.com"

	PlatformApiPrefix    = "/platform"
	PlatformApiUrlPrefix = "https://api.openai.com"

	AuthorizationHeader                = "Authorization"
	XAuthorizationHeader               = "X-Authorization"
	ContentType                        = "application/x-www-form-urlencoded"
	DefaultUserAgent                   = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
	Auth0Url                           = "https://auth0.openai.com"
	LoginUsernameUrl                   = Auth0Url + "/u/login/identifier?state="
	LoginPasswordUrl                   = Auth0Url + "/u/login/password?state="
	ParseUserInfoErrorMessage          = "failed to parse user login info"
	GetAuthorizedUrlErrorMessage       = "failed to get authorized url"
	EmailInvalidErrorMessage           = "email is not valid"
	EmailOrPasswordInvalidErrorMessage = "email or password is not correct"
	GetAccessTokenErrorMessage         = "failed to get access token"

	EmailKey                       = "email"
	AccountDeactivatedErrorMessage = "account %s is deactivated"

	ReadyHint = "service go-chatgpt-api is ready"

	Language = "en-US"

	ClientProfileMessage = "ClientProfile: %s is used"
)

Variables

View Source
var (
	Client              tls_client.HttpClient
	ArkoseClient        tls_client.HttpClient
	PUID                string
	OAIDID              string
	ProxyUrl            string
	IMITATE_accessToken string
	ConnPool            = map[string][]*ConnInfo{}
	ClientProfile       profiles.ClientProfile
	UserAgent           string
)

Functions

func GetAccessToken

func GetAccessToken(c *gin.Context) string

func GetArkoseToken

func GetArkoseToken(api_version int, dx string) (string, error)

func GetIDs

func GetIDs(accessToken string) (string, string)

func NewHttpClient

func NewHttpClient() tls_client.HttpClient

func Proxy

func Proxy(c *gin.Context)

func RefreshAccessToken

func RefreshAccessToken(refreshToken string) string

func ReturnMessage

func ReturnMessage(msg string) gin.H

Types

type AuthLogin

type AuthLogin interface {
	GetAuthorizedUrl(csrfToken string) (string, int, error)
	GetState(authorizedUrl string) (string, int, error)
	CheckUsername(state string, username string) (int, error)
	CheckPassword(state string, username string, password string) (string, int, error)
	GetAccessToken(code string) (string, int, error)
	GetAccessTokenFromHeader(c *gin.Context) (string, int, error)
}

type ConnInfo

type ConnInfo struct {
	Conn   *websocket.Conn
	Uuid   string
	Expire time.Time
	Ticker *time.Ticker
	Lock   bool
}

type LoginInfo

type LoginInfo struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL