Documentation
¶
Index ¶
- Constants
- Variables
- func GetModel(model string) string
- type Client
- func (c *Client) Completion(ctx context.Context, content string) (*Response, error)
- func (c *Client) CreateChatCompletion(ctx context.Context, content string) (resp openai.ChatCompletionResponse, err error)
- func (c *Client) CreateCompletion(ctx context.Context, content string) (resp openai.CompletionResponse, err error)
- type Option
- func WithBaseURL(val string) Option
- func WithMaxTokens(val int) Option
- func WithModel(val string) Option
- func WithModelName(val string) Option
- func WithOrgID(val string) Option
- func WithProvider(val string) Option
- func WithProxyURL(val string) Option
- func WithSocksURL(val string) Option
- func WithTemperature(val float32) Option
- func WithTimeout(val time.Duration) Option
- func WithToken(val string) Option
- type Response
Constants ¶
const ( OPENAI = "openai" AZURE = "azure" )
Variables ¶
var DefaultModel = openai.GPT3Dot5Turbo
DefaultModel is the default OpenAI model to use if one is not provided.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a struct that represents an OpenAI client.
func (*Client) Completion ¶
Completion is a method on the Client struct that takes a context.Context and a string argument and returns a string and an error.
func (*Client) CreateChatCompletion ¶
func (c *Client) CreateChatCompletion( ctx context.Context, content string, ) (resp openai.ChatCompletionResponse, err error)
CreateChatCompletion is an API call to create a completion for a chat message.
func (*Client) CreateCompletion ¶
func (c *Client) CreateCompletion( ctx context.Context, content string, ) (resp openai.CompletionResponse, err error)
CreateCompletion is an API call to create a completion. This is the main endpoint of the API. It returns new text, as well as, if requested, the probabilities over each alternative token at each position.
If using a fine-tuned model, simply provide the model's ID in the CompletionRequest object, and the server will use the model's parameters to generate the completion.
type Option ¶ added in v0.0.5
type Option interface {
// contains filtered or unexported methods
}
Option is an interface that specifies instrumentation configuration options.
func WithBaseURL ¶ added in v0.1.2
WithBaseURL returns a new Option that sets the base URL for the client configuration. It takes a string value representing the base URL to use for requests. It returns an optionFunc that sets the baseURL field of the configuration to the provided
func WithMaxTokens ¶ added in v0.1.4
WithMaxTokens returns a new Option that sets the max tokens for the client configuration. The maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length.
func WithModel ¶ added in v0.0.5
WithModel is a function that returns an Option, which sets the model field of the config struct.
func WithModelName ¶ added in v0.1.8
WithModelName sets the `modelName` variable to the provided `val` parameter. This function returns an `Option` object.
func WithOrgID ¶ added in v0.0.5
WithOrgID is a function that returns an Option, which sets the orgID field of the config struct.
func WithProvider ¶ added in v0.1.8
WithProvider sets the `provider` variable based on the value of the `val` parameter. If `val` is not set to `OPENAI` or `AZURE`, it will be set to the default value `defaultProvider`. This function returns an `Option` object.
func WithProxyURL ¶ added in v0.0.5
WithProxyURL is a function that returns an Option, which sets the proxyURL field of the config struct.
func WithSocksURL ¶ added in v0.0.9
WithSocksURL is a function that returns an Option, which sets the socksURL field of the config struct.
func WithTemperature ¶ added in v0.1.7
WithTemperature returns a new Option that sets the temperature for the client configuration. What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
func WithTimeout ¶ added in v0.1.2
WithTimeout returns a new Option that sets the timeout for the client configuration. It takes a time.Duration value representing the timeout duration. It returns an optionFunc that sets the timeout field of the configuration to the provided value.