Documentation
¶
Index ¶
- Constants
- func AzureOpenAIAuthenticate(req *http.Request, apikey string)
- func AzureOpenAIBaseURL(domain, deployment string) string
- func AzureOpenAIServicePath(apiver string) func(string, ...any) string
- func IsResultError(err error) bool
- func NewRetryer(retryAfter time.Duration, maxRetries int, logger log.Logger) *ret.Retryer
- type BodyMarshaler
- type Client
- func (c *Client) CreateChatCompletion(ctx context.Context, req *completions.ChatCompletionRequest) (*completions.ChatCompletionResponse, error)
- func (c *Client) CreateFile(ctx context.Context, req *files.CreateRequest) (*files.FileObject, error)
- func (c *Client) CreateResponse(ctx context.Context, req *responses.CreateRequest) (*responses.CreateResponse, error)
- func (c *Client) CreateTextEmbeddings(ctx context.Context, req *embeddings.TextEmbeddingsRequest) (*embeddings.TextEmbeddingsResponse, error)
- func (c *Client) DoPost(ctx context.Context, url string, source, result any) error
- type DetailError
- type ResultError
Constants ¶
View Source
const ( OpenAIBaseURL = "https://api.openai.com/v1" RoleDeveloper = "developer" RoleSystem = "system" RoleUser = "user" RoleAssistant = "assistant" RoleTool = "tool" )
Variables ¶
This section is empty.
Functions ¶
func AzureOpenAIAuthenticate ¶ added in v1.1.8
func AzureOpenAIBaseURL ¶ added in v1.1.8
func AzureOpenAIServicePath ¶ added in v1.1.8
func IsResultError ¶ added in v1.1.2
Types ¶
type BodyMarshaler ¶ added in v1.1.8
BodyMarshaler is the interface implemented by types that can marshal themselves for http request.
type Client ¶ added in v1.1.4
type Client struct {
BaseURL string
APIKey string
Transport http.RoundTripper
Timeout time.Duration
Retryer *ret.Retryer
Authenticate func(req *http.Request, apikey string) // custom authenticate function
ServicePath func(format string, args ...any) string // custom service path function
}
func NewAzureClient ¶ added in v1.1.8
func (*Client) CreateChatCompletion ¶ added in v1.1.4
func (c *Client) CreateChatCompletion(ctx context.Context, req *completions.ChatCompletionRequest) (*completions.ChatCompletionResponse, error)
func (*Client) CreateFile ¶ added in v1.1.8
func (c *Client) CreateFile(ctx context.Context, req *files.CreateRequest) (*files.FileObject, error)
https://developers.openai.com/api/reference/resources/files/methods/create
func (*Client) CreateResponse ¶ added in v1.1.8
func (c *Client) CreateResponse(ctx context.Context, req *responses.CreateRequest) (*responses.CreateResponse, error)
https://developers.openai.com/api/reference/resources/responses/methods/create
func (*Client) CreateTextEmbeddings ¶ added in v1.1.4
func (c *Client) CreateTextEmbeddings(ctx context.Context, req *embeddings.TextEmbeddingsRequest) (*embeddings.TextEmbeddingsResponse, error)
https://platform.openai.com/docs/api-reference/embeddings/create
type DetailError ¶
type DetailError struct {
Type string `json:"type,omitempty"`
Code any `json:"code,omitempty"`
Param any `json:"param,omitempty"`
Message string `json:"message,omitempty"`
}
func (*DetailError) Error ¶
func (de *DetailError) Error() string
type ResultError ¶
type ResultError struct {
Method string `json:"-"` // http request method
URL *url.URL `json:"-"` // http request URL
StatusCode int `json:"-"` // http status code
Status string `json:"-"` // http status
Detail *DetailError `json:"error,omitempty"`
}
func AsResultError ¶ added in v1.1.2
func AsResultError(err error) (re *ResultError, ok bool)
func (*ResultError) Error ¶
func (re *ResultError) Error() string
Click to show internal directories.
Click to hide internal directories.