Documentation
¶
Index ¶
- Constants
- Variables
- type AudioTranslationRequest
- type AudioTranslationResponse
- type Chat
- type ChatClient
- type ChatResponse
- type Choice
- type Client
- type GptClient
- type ImageCreateRequest
- type ImageCreateResponse
- type Message
- type ModelMeta
- type ModelResponse
- type Option
- type Permission
- type RespErr
- type ResponseErr
- type Text2Cmd
- type UrlMeta
- type Usage
Constants ¶
View Source
const ( GPT_KEY = "GPT_KEY" // 以环境变量来存放gpt的key GPT_URL = "https://api.openai.com/v1/chat/completions" // POST&GET:和gpt进行聊天 MODEL_URL = "https://api.openai.com/v1/models" // GET:请求模型列表 IMG_CREATE_URL = "https://api.openai.com/v1/images/generations" // POST:图片生成 AUDIO_TRANSLATION_URL = "https://api.openai.com/v1/audio/transcriptions" // POST:音频asr AUDIO_TRANSCRIPTION_URL = "https://api.openai.com/v1/audio/transcriptions" // POST:音频转录 )
Variables ¶
View Source
var (
ErrWithEmptyContent = errors.New("聊天内容为空")
)
Functions ¶
This section is empty.
Types ¶
type AudioTranslationRequest ¶ added in v0.3.0
type AudioTranslationResponse ¶ added in v0.3.0
type AudioTranslationResponse struct {
Text string `json:"text"`
}
type ChatClient ¶
func NewChatClient ¶
func NewChatClient(ctx context.Context) (*ChatClient, error)
func (*ChatClient) Send ¶
func (c *ChatClient) Send(src interface{}) (err error)
func (*ChatClient) WithPrompt ¶
func (c *ChatClient) WithPrompt(messages []string) *ChatClient
type ChatResponse ¶
type ImageCreateRequest ¶ added in v0.2.0
type ImageCreateRequest struct { Prompt string `json:"prompt"` Num int `json:"n"` Size string `json:"size"` }
图片生成
type ImageCreateResponse ¶ added in v0.2.0
图片生成
type ModelResponse ¶
type Option ¶
type Option func(client *Client)
func WithClientTimeoutSec ¶
func WithContentType ¶ added in v0.3.0
func WithMethod ¶
func WithPrompt ¶
type Permission ¶
type Permission struct { AllowCreateEngine bool `json:"allow_create_engine"` AllowFineTuning bool `json:"allow_fine_tuning"` AllowLogprobs bool `json:"allow_logprobs"` AllowSampling bool `json:"allow_sampling"` AllowSearchIndices bool `json:"allow_search_indices"` AllowView bool `json:"allow_view"` Created int `json:"created"` Group interface{} `json:"group"` ID string `json:"id"` IsBlocking bool `json:"is_blocking"` Object string `json:"object"` Organization string `json:"organization"` }
type RespErr ¶ added in v0.3.0
type RespErr struct { Message string `json:"message"` Type string `json:"type"` Param interface{} `json:"param"` Code interface{} `json:"code"` }
返回错误信息
type Text2Cmd ¶
type Text2Cmd struct { Model string `json:"model"` Prompt string `json:"prompt"` Temperature int `json:"temperature"` MaxTokens int `json:"max_tokens"` TopP float64 `json:"top_p"` FrequencyPenalty float64 `json:"frequency_penalty"` PresencePenalty float64 `json:"presence_penalty"` Stop []string `json:"stop"` }
Click to show internal directories.
Click to hide internal directories.