chatgpt

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatAPI

type ChatAPI struct {
	Key    string
	Proxy  string
	Client *http.Client
}

func NewChatAPI

func NewChatAPI(key, proxyUrl string) *ChatAPI

func (*ChatAPI) Ask

func (obj *ChatAPI) Ask(question string) string

func (*ChatAPI) CreateChatCompletion

func (obj *ChatAPI) CreateChatCompletion(param CreateChatCompletionStructParam) (*CreateChatCompletionStruct, error)

CreateChatCompletion 创建一个会话

func (*ChatAPI) CreateImage

func (obj *ChatAPI) CreateImage(param CreateImageStructParam) (*CreateImageStruct, error)

CreateImage 生成一张图片

func (*ChatAPI) ListModels

func (obj *ChatAPI) ListModels() (*ListModelsStruct, error)

ListModels 列出所有模型

type CreateChatCompletionStruct

type CreateChatCompletionStruct struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int    `json:"created"`
	Model   string `json:"model"`
	Usage   struct {
		PromptTokens     int `json:"prompt_tokens"`
		CompletionTokens int `json:"completion_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage"`
	Choices []struct {
		Message struct {
			Role    string `json:"role"`
			Content string `json:"content"`
		} `json:"message"`
		FinishReason string `json:"finish_reason"`
		Index        int    `json:"index"`
	} `json:"choices"`
}

type CreateChatCompletionStructParam

type CreateChatCompletionStructParam struct {
	Model    string `json:"model"`
	Messages []struct {
		Role    string `json:"role"`
		Content string `json:"content"`
	} `json:"messages"`
}

type CreateImageStruct

type CreateImageStruct struct {
	Created int `json:"created"`
	Data    []struct {
		URL string `json:"url"`
	} `json:"data"`
}

type CreateImageStructParam

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

type ListModelsStruct

type ListModelsStruct struct {
	Object string `json:"object"`
	Data   []struct {
		ID         string `json:"id"`
		Object     string `json:"object"`
		Created    int    `json:"created"`
		OwnedBy    string `json:"owned_by"`
		Permission []struct {
			ID                 string      `json:"id"`
			Object             string      `json:"object"`
			Created            int         `json:"created"`
			AllowCreateEngine  bool        `json:"allow_create_engine"`
			AllowSampling      bool        `json:"allow_sampling"`
			AllowLogprobs      bool        `json:"allow_logprobs"`
			AllowSearchIndices bool        `json:"allow_search_indices"`
			AllowView          bool        `json:"allow_view"`
			AllowFineTuning    bool        `json:"allow_fine_tuning"`
			Organization       string      `json:"organization"`
			Group              interface{} `json:"group"`
			IsBlocking         bool        `json:"is_blocking"`
		} `json:"permission"`
		Root   string      `json:"root"`
		Parent interface{} `json:"parent"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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