Documentation ¶
Index ¶
- Variables
- type CompletionFunction
- type CreateChatCompletionsChoice
- type CreateChatCompletionsRequest
- type CreateChatCompletionsResponse
- type CreateChatCompletionsUsage
- type Error
- type ErrorResponse
- type FunctionCall
- type HttpClient
- type Message
- type OpenAiClient
- func (c *OpenAiClient) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
- func (c *OpenAiClient) CreateChatCompletions(ctx context.Context, r *CreateChatCompletionsRequest) (response *CreateChatCompletionsResponse, err error)
- func (c *OpenAiClient) CreateChatCompletionsRaw(ctx context.Context, r *CreateChatCompletionsRequest) ([]byte, error)
- func (c *OpenAiClient) Get(ctx context.Context, url string, input any) (response []byte, err error)
- func (c *OpenAiClient) Post(ctx context.Context, url string, input any) (response []byte, err error)
- type OpenAiModel
- type ResponseFormat
- type StrArray
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStrArrayUnsupportedType = errors.New("unsupported type, must be string or []string")
Functions ¶
This section is empty.
Types ¶
type CompletionFunction ¶
type CreateChatCompletionsRequest ¶
type CreateChatCompletionsRequest struct { Model string `json:"model,omitempty"` Messages []Message `json:"messages,omitempty"` Functions []CompletionFunction `json:"functions,omitempty"` FunctionCall *string `json:"function_call,omitempty"` Temperature float64 `json:"temperature,omitempty"` TopP float64 `json:"top_p,omitempty"` N int `json:"n,omitempty"` Stream bool `json:"stream,omitempty"` Stop StrArray `json:"stop,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` LogitBias map[string]string `json:"logit_bias,omitempty"` User string `json:"user,omitempty"` ResponseFormat ResponseFormat `json:"response_format,omitempty"` Seed int `json:"seed,omitempty"` }
type CreateChatCompletionsResponse ¶
type CreateChatCompletionsResponse struct { ID string `json:"id,omitempty"` Object string `json:"object,omitempty"` Created int `json:"created,omitempty"` Model string `json:"model,omitempty"` Choices []CreateChatCompletionsChoice `json:"choices,omitempty"` Usage CreateChatCompletionsUsage `json:"usage,omitempty"` SystemFingerprint string `json:"system_fingerprint,omitempty"` }
type Error ¶
type Error struct { Message string `json:"message,omitempty"` Type string `json:"type,omitempty"` Param interface{} `json:"param,omitempty"` Code interface{} `json:"code,omitempty"` }
Error is the error standard response from the API
type ErrorResponse ¶
type ErrorResponse struct {
Error *Error `json:"error,omitempty"`
}
type FunctionCall ¶
type Message ¶
type Message struct { Role string `json:"role,omitempty"` Content string `json:"content,omitempty"` FunctionCall *FunctionCall `json:"function_call,omitempty"` }
type OpenAiClient ¶
type OpenAiClient struct {
// contains filtered or unexported fields
}
func NewOpenAiClient ¶
func NewOpenAiClient(apiKey, organization, model string) *OpenAiClient
NewOpenAiClient creates a new client
func (*OpenAiClient) Call ¶
func (c *OpenAiClient) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
Call makes a request
func (*OpenAiClient) CreateChatCompletions ¶
func (c *OpenAiClient) CreateChatCompletions(ctx context.Context, r *CreateChatCompletionsRequest) (response *CreateChatCompletionsResponse, err error)
func (*OpenAiClient) CreateChatCompletionsRaw ¶
func (c *OpenAiClient) CreateChatCompletionsRaw(ctx context.Context, r *CreateChatCompletionsRequest) ([]byte, error)
type OpenAiModel ¶
type OpenAiModel struct {
Client *OpenAiClient
}
func NewModel ¶
func NewModel(apiKey, organization, model string) *OpenAiModel
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type"`
}
Click to show internal directories.
Click to hide internal directories.