chatgpt2api

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToString

func ConvertToString(chatgptResponse *ChatGPTResponse, previous_text *StringStruct, role bool) string

func EnginesHandler

func EnginesHandler(c *gin.Context)

func GETengines

func GETengines() (interface{}, int, error)

func HandleRequestError

func HandleRequestError(c *gin.Context, response *http.Response) bool

HandleRequestError Returns whether an error was handled

func Nightmare

func Nightmare(c *gin.Context, httpProxy string)

func OptionsHandler

func OptionsHandler(c *gin.Context)

func POSTConversation

func POSTConversation(message ChatGPTRequest, accessToken, httpProxy string) (*http.Response, error)

func PUidHandler

func PUidHandler(c *gin.Context)

Types

type APIRequest

type APIRequest struct {
	Messages  []apiMessage `json:"messages"`
	Stream    bool         `json:"stream"`
	Model     string       `json:"model"`
	PluginIDs []string     `json:"plugin_ids"`
}

type AccessToken

type AccessToken struct {
	// contains filtered or unexported fields
}
var AccessTokens AccessToken

func NewAccessToken

func NewAccessToken(tokens []string) AccessToken

func (*AccessToken) GetToken

func (a *AccessToken) GetToken() string

type Author

type Author struct {
	Role     string                 `json:"role"`
	Name     interface{}            `json:"name"`
	Metadata map[string]interface{} `json:"metadata"`
}

type ChatCompletion

type ChatCompletion struct {
	ID      string   `json:"id"`
	Object  string   `json:"object"`
	Created int64    `json:"created"`
	Model   string   `json:"model"`
	Usage   usage    `json:"usage"`
	Choices []Choice `json:"choices"`
}

func NewChatCompletion

func NewChatCompletion(full_test string) ChatCompletion

type ChatCompletionChunk

type ChatCompletionChunk struct {
	ID      string    `json:"id"`
	Object  string    `json:"object"`
	Created int64     `json:"created"`
	Model   string    `json:"model"`
	Choices []Choices `json:"choices"`
}

func NewChatCompletionChunk

func NewChatCompletionChunk(text string) ChatCompletionChunk

func StopChunk

func StopChunk(reason string) ChatCompletionChunk

func (*ChatCompletionChunk) String

func (chunk *ChatCompletionChunk) String() string

type ChatGPTRequest

type ChatGPTRequest struct {
	Action                     string           `json:"action"`
	Messages                   []chatgptMessage `json:"messages"`
	ParentMessageID            string           `json:"parent_message_id,omitempty"`
	ConversationID             string           `json:"conversation_id,omitempty"`
	Model                      string           `json:"model"`
	HistoryAndTrainingDisabled bool             `json:"history_and_training_disabled"`
	ArkoseToken                string           `json:"arkose_token,omitempty"`
	PluginIDs                  []string         `json:"plugin_ids,omitempty"`
}

func ConvertAPIRequest

func ConvertAPIRequest(apiRequest APIRequest) ChatGPTRequest

func NewChatGPTRequest

func NewChatGPTRequest() ChatGPTRequest

func (*ChatGPTRequest) AddMessage

func (c *ChatGPTRequest) AddMessage(role string, content string)

type ChatGPTResponse

type ChatGPTResponse struct {
	Message        Message     `json:"message"`
	ConversationID string      `json:"conversation_id"`
	Error          interface{} `json:"error"`
}

type Choice

type Choice struct {
	Index        int         `json:"index"`
	Message      Msg         `json:"message"`
	FinishReason interface{} `json:"finish_reason"`
}

type Choices

type Choices struct {
	Delta        Delta       `json:"delta"`
	Index        int         `json:"index"`
	FinishReason interface{} `json:"finish_reason"`
}

type Content

type Content struct {
	ContentType string   `json:"content_type"`
	Parts       []string `json:"parts"`
}

type ContinueInfo

type ContinueInfo struct {
	ConversationID string `json:"conversation_id"`
	ParentID       string `json:"parent_id"`
}

func Handler

func Handler(c *gin.Context, response *http.Response, token string, translated_request ChatGPTRequest, stream bool) (string, *ContinueInfo)

type Delta

type Delta struct {
	Content string `json:"content,omitempty"`
	Role    string `json:"role,omitempty"`
}

type FinishDetails

type FinishDetails struct {
	Type string `json:"type"`
	Stop string `json:"stop"`
}

type GenericResponseLine

type GenericResponseLine struct {
	Line  string `json:"line"`
	Error string `json:"error"`
}

type Message

type Message struct {
	ID         string      `json:"id"`
	Author     Author      `json:"author"`
	CreateTime float64     `json:"create_time"`
	UpdateTime interface{} `json:"update_time"`
	Content    Content     `json:"content"`
	EndTurn    interface{} `json:"end_turn"`
	Weight     float64     `json:"weight"`
	Metadata   Metadata    `json:"metadata"`
	Recipient  string      `json:"recipient"`
}

type Metadata

type Metadata struct {
	Timestamp     string         `json:"timestamp_"`
	MessageType   string         `json:"message_type"`
	FinishDetails *FinishDetails `json:"finish_details"`
	ModelSlug     string         `json:"model_slug"`
	Recipient     string         `json:"recipient"`
}

type Msg

type Msg struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type StringStruct

type StringStruct struct {
	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

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