Help us shape the future of Go! Take the 2026 Go Developer Survey

gpt3

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorMaxToken = fmt.Errorf(
	`	你的会话token数量已经达到了GPT-3.5-turbo的4096 token上限, 请使用指令` + "`" + ".gpt RESET" + "`" + `或点击按钮来重置会话并重试。
请注意: 为了保护你的隐私,
***目前***我们不会保存你与ChatGPT交流的历史会话。在后续BetaGo上线OAuth鉴权后, 你可能需要同意[EULA协议]来允许我们保存你的历史会话。
`,
)
View Source
var GPTAsyncMap = make(map[string]AsyncMapValue)

GPTAsyncMap 异步map

View Source
var (
	ParsedProxyURL *url.URL
)
View Source
var TraceUserMap = make(map[string]string)

TraceUserMap 1

Functions

func ClientHandler

func ClientHandler(ctx context.Context, targetID, quoteID, authorID string, args ...string) (err error)

ClientHandler 1 ! deprecated @param targetID 目标ID @param quoteID 引用ID @param authorID 发送者ID @return err 错误信息

func ClientHandlerStream

func ClientHandlerStream(ctx context.Context, targetID, quoteID, authorID string, args ...string) (err error)

ClientHandlerStream 1

@param ctx
@param targetID
@param quoteID
@param authorID
@param args
@return err

func ClientHandlerStreamUpdate

func ClientHandlerStreamUpdate(ctx context.Context, targetID, quoteID, authorID, msgID, msg string) (err error)

ClientHandlerStreamUpdate 1

@param ctx
@param targetID
@param quoteID
@param authorID
@param args
@return err

func CreateChatCompletion

func CreateChatCompletion(ctx context.Context, msg, authorID string) (message string, err error)

CreateChatCompletion 1

@param msg
@return message
@return err

func CreateChatCompletionStream

func CreateChatCompletionStream(ctx context.Context, input, authorID string)

func ModerationCheck

func ModerationCheck(ctx context.Context, content string) (res []string)

Types

type AsyncMapValue

type AsyncMapValue struct {
	AuthorID string
	Channel  *chan string
}

type GPTClient

type GPTClient struct {
	Model      string      `json:"model"`
	Messages   []Message   `json:"messages"`
	Stream     bool        `json:"stream,omitempty"`
	AsyncChan  chan string `json:"-"`
	StopChan   chan string `json:"-"`
	StopAuthor string      `json:"-"`
}

GPTClient GPT的请求体

func (*GPTClient) GetModels

func (g *GPTClient) GetModels() (msg string, err error)

func (*GPTClient) Post

func (g *GPTClient) Post() (msg string, err error)

Post 发送请求

@receiver g

func (*GPTClient) PostWithStream

func (g *GPTClient) PostWithStream(ctx context.Context) (err error)

PostWithStream 流式请求

@receiver g
@param ctx
@return executeMsg
@return err

func (*GPTClient) SetContent

func (g *GPTClient) SetContent(s string)

SetContent 设置内容

@receiver g
@param s

type Message

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

Message 要发送的内容

Jump to

Keyboard shortcuts

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