Documentation ¶
Index ¶
- Constants
- func Debug() bool
- type BaseResp
- type ChatCompletionsChan
- type ChatCompletionsReq
- type Client
- func (c *Client) ChatCompletions(req ChatCompletionsReq) (CompletionsResp, *http.Response, error)
- func (c *Client) ChatCompletionsStream(req ChatCompletionsReq) (*ChatCompletionsChan, *http.Response, error)
- func (c *Client) Completions(req CompletionsReq) (CompletionsResp, *http.Response, error)
- func (c *Client) Exec(method, path string, opt, res any) (*resty.Response, error)
- func (c *Client) ListModels() ([]Model, *http.Response, error)
- func (c *Client) Pre(method, path string, opt any) (string, map[string]string, any, error)
- func (c *Client) RetrieveModel(id string) (Model, *http.Response, error)
- type ClientOptionFunc
- type CompletionsChoice
- type CompletionsMessage
- type CompletionsReq
- type CompletionsResp
- type CompletionsUsage
- type ListModelResp
- type Model
- type ModelPermission
- type Ratelimit
Constants ¶
View Source
const ( DefaultBaseURL = "https://api.openai.com/" DefaultVersion = "v1/" DefaultUserAgent = "starudream-openai-go" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChatCompletionsChan ¶ added in v0.0.2
type ChatCompletionsChan struct {
// contains filtered or unexported fields
}
type ChatCompletionsReq ¶
type ChatCompletionsReq struct { Model string `json:"model"` Messages []CompletionsMessage `json:"messages"` Temperature float64 `json:"temperature,omitempty"` TopP float64 `json:"top_p,omitempty"` N int `json:"n,omitempty"` Stream bool `json:"stream,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ChatCompletions ¶
func (c *Client) ChatCompletions(req ChatCompletionsReq) (CompletionsResp, *http.Response, error)
func (*Client) ChatCompletionsStream ¶ added in v0.0.2
func (c *Client) ChatCompletionsStream(req ChatCompletionsReq) (*ChatCompletionsChan, *http.Response, error)
func (*Client) Completions ¶
func (c *Client) Completions(req CompletionsReq) (CompletionsResp, *http.Response, error)
type ClientOptionFunc ¶
func WithBaseURL ¶
func WithBaseURL(urlStr string) ClientOptionFunc
func WithClient ¶ added in v0.0.4
func WithClient(client *resty.Client) ClientOptionFunc
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOptionFunc
type CompletionsChoice ¶
type CompletionsChoice struct { Text *string `json:"text"` Message *CompletionsMessage `json:"message"` Delta *CompletionsMessage `json:"delta"` Index int `json:"index"` FinishReason string `json:"finish_reason"` }
type CompletionsMessage ¶
func NewCompletionsMessage ¶ added in v0.0.2
func NewCompletionsMessage(role, content string) CompletionsMessage
type CompletionsReq ¶
type CompletionsReq struct { Model string `json:"model"` Prompt string `json:"prompt"` Suffix string `json:"suffix,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float64 `json:"temperature,omitempty"` TopP float64 `json:"top_p,omitempty"` N int `json:"n,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` }
type CompletionsResp ¶
type CompletionsResp struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Model string `json:"model"` Choices []*CompletionsChoice `json:"choices"` Usage *CompletionsUsage `json:"usage"` }
func (*CompletionsResp) GetMessage ¶
func (p *CompletionsResp) GetMessage() []CompletionsMessage
type CompletionsUsage ¶
type ListModelResp ¶
type ModelPermission ¶
type ModelPermission 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 any `json:"group"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.