chatgpt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 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 {
	BaseUrl     string
	AccessToken string
}

func New

func New(options ChatGPT) *ChatGPT

func (*ChatGPT) CreateCompletion

func (c *ChatGPT) CreateCompletion(param CompletionRequest) (res CompletionResponse, err error)

func (*ChatGPT) DeleteConversation

func (c *ChatGPT) DeleteConversation(id string) (err error)

type CompletionMessageContent

type CompletionMessageContent struct {
	ContentType string   `json:"content_type"` // 消息类型 目前只支持text
	Parts       []string `json:"parts"`        // 消息文本
}

type CompletionRequest

type CompletionRequest struct {
	Action          string                     `json:"action"`                      // 消息类型 目前只支持next
	Messages        []CompletionRequestMessage `json:"messages"`                    // 消息内容
	Model           string                     `json:"model"`                       // 消息模型 text-davinci-002-render-sha
	ParentMessageID string                     `json:"parent_message_id,omitempty"` // 父消息ID
	ConversationID  string                     `json:"conversation_id,omitempty"`   // 会话ID
}

type CompletionRequestMessage

type CompletionRequestMessage struct {
	ID      string                   `json:"id"`      // 消息ID
	Role    string                   `json:"role"`    // 消息角色 user system assistant
	Content CompletionMessageContent `json:"content"` // 消息内容
}

request

type CompletionResponse

type CompletionResponse struct {
	ConversationID string                    `json:"conversation_id"` // 会话ID
	Error          string                    `json:"error"`           // 错误信息
	Message        CompletionResponseMessage `json:"message"`         // 消息内容
}

type CompletionResponseMessage

type CompletionResponseMessage struct {
	ID         string                          `json:"id"`          // 消息ID
	Author     CompletionResponseMessageAuthor `json:"author"`      // 消息角色 user system assistant
	CreateTime float64                         `json:"create_time"` // 创建时间
	UpdateTime float64                         `json:"update_time"` // 更新时间
	Content    CompletionMessageContent        `json:"content"`     // 消息内容
	EndTurn    bool                            `json:"end_turn"`    // 是否结束会话
	Weight     float64                         `json:"weight"`      // 权重
	MetaData   map[string]interface{}          `json:"meta_data"`   // meta_data
	Recipient  string                          `json:"recipient"`   // 接收者
}

type CompletionResponseMessageAuthor

type CompletionResponseMessageAuthor struct {
	Role     string                 `json:"role"`      // 消息角色 user system assistant
	Name     string                 `json:"name"`      // 角色名称
	MetaData map[string]interface{} `json:"meta_data"` // meta_data
}

response

Jump to

Keyboard shortcuts

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