chatgpt

package module
v0.0.0-...-4a69026 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 11 Imported by: 1

README

chatgpt

chatgpt api

测试使用,待更新

Documentation

Index

Constants

View Source
const (
	ID            = "chatgpt"
	Comment       = "[module] chatgpt api"
	RoutePrefix   = "/chatgpt"
	DefaultEnable = false
)

Variables

View Source
var Module = module.Module{
	ID:      ID,
	Comment: Comment,

	RouteFunc:   AddRoute,
	RoutePrefix: RoutePrefix,

	FlagFunc: ServeFlag,
}

Functions

func AddRoute

func AddRoute(g *gin.Engine)

func Ask

func Ask(c *gin.Context)

func ServeFlag

func ServeFlag(serveCmd *cobra.Command)

Types

type AskChatGPT

type AskChatGPT struct {
	Model            string  `json:"model"`
	Prompt           string  `json:"prompt"`
	Temperature      float64 `json:"temperature"`
	MaxTokens        int     `json:"max_tokens"`
	TopP             int     `json:"top_p"`
	FrequencyPenalty int     `json:"frequency_penalty"`
	PresencePenalty  int     `json:"presence_penalty"`
}

type AskChatGPT35

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

type ChatGPTSay

type ChatGPTSay struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int    `json:"created"`
	Choices []struct {
		Text         string      `json:"text"`
		Index        int         `json:"index"`
		Logprobs     interface{} `json:"logprobs"`
		FinishReason string      `json:"finish_reason"`
	} `json:"choices"`
	Usage struct {
		PromptTokens     int `json:"prompt_tokens"`
		CompletionTokens int `json:"completion_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage"`
}

type NewASk

type NewASk struct {
	ASK string `json:"ask" form:"ask" validate:"required"`
	H   bool   `json:"h" form:"h"`
}

Jump to

Keyboard shortcuts

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