imitate

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: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToString

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

func CreateChatCompletions

func CreateChatCompletions(c *gin.Context)

func GetImageSource

func GetImageSource(wg *sync.WaitGroup, url string, prompt string, token string, idx int, imgSource []string)

func HandleRequestError

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

func NewChatGPTRequest

func NewChatGPTRequest() chatgpt.CreateConversationRequest

Types

type APIRequest

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

type ApiMessage

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

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"`
}

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 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 CitaMeta

type CitaMeta struct {
	URL   string `json:"url"`
	Title string `json:"title"`
}

type Citation

type Citation struct {
	Metadata CitaMeta `json:"metadata"`
	StartIx  int      `json:"start_ix"`
	EndIx    int      `json:"end_ix"`
}

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, uuid string, 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 Message

type Message struct {
	ID         string          `json:"id"`
	Author     chatgpt.Author  `json:"author"`
	CreateTime float64         `json:"create_time"`
	UpdateTime interface{}     `json:"update_time"`
	Content    chatgpt.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_"`
	Citations     []Citation     `json:"citations,omitempty"`
	MessageType   string         `json:"message_type"`
	FinishDetails *FinishDetails `json:"finish_details"`
	ModelSlug     string         `json:"model_slug"`
}

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