Documentation ¶
Overview ¶
Package chat contains a client for Open AI's ChatGPT APIs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // CreateCompletionsEndpoint allows overriding the default API endpoint. // Set this field before using the client. CreateCompletionEndpoint string // contains filtered or unexported fields }
Client is a client to communicate with Open AI's ChatGPT APIs.
func NewClient ¶
NewClient creates a new default client that uses the given session and defaults to the given model.
func (*Client) CreateCompletion ¶
func (c *Client) CreateCompletion(ctx context.Context, p *CreateCompletionParams) (*CreateCompletionResponse, error)
type CreateCompletionParams ¶
type CreateCompletionParams struct { Model string `json:"model,omitempty"` Messages []*Message `json:"messages,omitempty"` Stop []string `json:"stop,omitempty"` Stream bool `json:"stream,omitempty"` N int `json:"n,omitempty"` TopP float64 `json:"top_p,omitempty"` Temperature float64 `json:"temperature,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` User string `json:"user,omitempty"` }
type CreateCompletionStreamingResponse ¶ added in v1.0.3
type CreateCompletionStreamingResponse struct { ID string `json:"id,omitempty"` Object string `json:"object,omitempty"` CreatedAt int64 `json:"created_at,omitempty"` Choices []*StreamingChoice `json:"choices,omitempty"` }
type StreamingChoice ¶ added in v1.0.3
type StreamingClient ¶ added in v1.0.3
type StreamingClient struct { // CreateCompletionsEndpoint allows overriding the default API endpoint. // Set this field before using the client. CreateCompletionEndpoint string // contains filtered or unexported fields }
StreamingClient is a client to communicate with Open AI's ChatGPT APIs.
func NewStreamingClient ¶ added in v1.0.3
func NewStreamingClient(session *openai.Session, model string) *StreamingClient
NewStreamingClient creates a new default streaming client that uses the given session and defaults to the given model.
func (*StreamingClient) CreateCompletion ¶ added in v1.0.3
func (c *StreamingClient) CreateCompletion(ctx context.Context, p *CreateCompletionParams, fn func(r *CreateCompletionStreamingResponse)) error
Click to show internal directories.
Click to hide internal directories.