chatgpt

package
v0.0.0-...-75ed8df Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatGPT

type ChatGPT struct {
	ApiKey         string
	GptModel       string
	ChatUrl        string
	CreateImageUrl string
	EditUrl        string
}

func NewChatGPT

func NewChatGPT() *ChatGPT

func (*ChatGPT) CreateChatRequest

func (c *ChatGPT) CreateChatRequest(message string) ChatRequest

func (*ChatGPT) CreateEditRequest

func (c *ChatGPT) CreateEditRequest(instruction, message string) EditRequest

func (*ChatGPT) CreateImage

func (c *ChatGPT) CreateImage(message string) (*CreateImageResponse, error)

func (*ChatGPT) CreateImageRequest

func (c *ChatGPT) CreateImageRequest(message string) CreateImageRequest

func (*ChatGPT) CreateRequest

func (c *ChatGPT) CreateRequest() *resty.Request

func (*ChatGPT) Edit

func (c *ChatGPT) Edit(instruction, message string) (*ChatResponse, error)

func (*ChatGPT) InitApi

func (c *ChatGPT) InitApi()

func (*ChatGPT) Talk

func (c *ChatGPT) Talk(message string) (*ChatResponse, error)

type ChatMessage

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

type ChatRequest

type ChatRequest struct {
	Model            string        `json:"model"`
	Messages         []ChatMessage `json:"messages"`
	Temperature      *int          `json:"temperature,omitempty"`
	TopP             *int          `json:"top_p,omitempty"`
	N                *int          `json:"n,omitempty"`
	Stream           *bool         `json:"stream,omitempty"`
	Stop             *string       `json:"stop,omitempty"`
	MaxTokens        *int          `json:"max_tokens,omitempty"`
	PresencePenalty  *float32      `json:"presence_penalty,omitempty"`
	FrequencyPenalty *float32      `json:"frequency_penalty,omitempty"`
	User             *string       `json:"user,omitempty"`
}

type ChatResponse

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

type Choice

type Choice struct {
	Index        int         `json:"index"`
	Message      ChatMessage `json:"message"`
	FinishReason *string     `json:"finish_reason,omitempty"`
}

type CreateImageRequest

type CreateImageRequest struct {
	Prompt string `json:"prompt"`
	N      int    `json:"n"`
	Size   string `json:"size"`
}

type CreateImageResponse

type CreateImageResponse struct {
	Created int64        `json:"created"`
	Data    []UrlReponse `json:"data"`
}

type EditRequest

type EditRequest struct {
	Model       string `json:"model"`
	Input       string `json:"input"`
	Instruction string `json:"instruction"`
	N           *int   `json:"n,omitempty"`
	Temperature *int   `json:"temperature,omitempty"`
	TopP        *int   `json:"top_p,omitempty"`
}

type UrlReponse

type UrlReponse struct {
	Url string `json:"url"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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