Documentation
¶
Index ¶
- Variables
- func NewHeaders(headers []string) http.Header
- type Client
- func (c *Client) Completion(ctx context.Context, content string) (*core.Response, error)
- func (c *Client) CreateChatCompletion(ctx context.Context, content string) (resp openai.ChatCompletionResponse, err error)
- func (c *Client) CreateFunctionCall(ctx context.Context, content string, f openai.FunctionDefinition) (resp openai.ChatCompletionResponse, err error)
- func (c *Client) GetSummaryPrefix(ctx context.Context, content string) (*core.Response, error)
- type DefaultHeaderTransport
- type Option
- func WithAPIVersion(apiVersion string) Option
- func WithBaseURL(val string) Option
- func WithFrequencyPenalty(val float32) Option
- func WithHeaders(headers []string) Option
- func WithMaxTokens(val int) Option
- func WithModel(val string) Option
- func WithOrgID(val string) Option
- func WithPresencePenalty(val float32) Option
- func WithProvider(val core.Platform) Option
- func WithProxyURL(val string) Option
- func WithSkipVerify(val bool) Option
- func WithSocksURL(val string) Option
- func WithTemperature(val float32) Option
- func WithTimeout(val time.Duration) Option
- func WithToken(val string) Option
- func WithTopP(val float32) Option
- type Response
- type SummaryPrefixParams
Constants ¶
This section is empty.
Variables ¶
var DefaultModel = openai.GPT3Dot5Turbo
DefaultModel is the default OpenAI model to use if one is not provided.
var SummaryPrefixFunc = openai.FunctionDefinition{ Name: "get_summary_prefix", Parameters: jsonschema.Definition{ Type: jsonschema.Object, Properties: map[string]jsonschema.Definition{ "prefix": { Type: jsonschema.String, Enum: []string{ "build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test", }, }, }, Required: []string{"prefix"}, }, }
SummaryPrefixFunc is a openai function definition.
Functions ¶
func NewHeaders ¶
NewHeaders creates a new http.Header from the given slice of headers.
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
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) CreateFunctionCall ¶
func (c *Client) CreateFunctionCall( ctx context.Context, content string, f openai.FunctionDefinition, ) (resp openai.ChatCompletionResponse, err error)
CreateChatCompletion is an API call to create a function call for a chat message.
type DefaultHeaderTransport ¶
type DefaultHeaderTransport struct { Origin http.RoundTripper Header http.Header }
DefaultHeaderTransport is an http.RoundTripper that adds the given headers to
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an interface that specifies instrumentation configuration options.
func WithAPIVersion ¶
WithAPIVersion returns a new Option that sets the apiVersion for OpenAI Model.
func WithBaseURL ¶
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 WithFrequencyPenalty ¶
WithFrequencyPenalty returns a new Option that sets the frequencyPenalty for the client configuration.
func WithHeaders ¶
WithHeaders returns a new Option that sets the headers for the http client configuration.
func WithMaxTokens ¶
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 ¶
WithModel is a function that returns an Option, which sets the model field of the config struct.
func WithOrgID ¶
WithOrgID is a function that returns an Option, which sets the orgID field of the config struct.
func WithPresencePenalty ¶
WithPresencePenalty returns a new Option that sets the presencePenalty for the client configuration.
func WithProvider ¶
WithProvider returns a new Option that sets the provider for the client configuration.
func WithProxyURL ¶
WithProxyURL is a function that returns an Option, which sets the proxyURL field of the config struct.
func WithSkipVerify ¶
WithSkipVerify returns a new Option that sets the skipVerify for the client configuration.
func WithSocksURL ¶
WithSocksURL is a function that returns an Option, which sets the socksURL field of the config struct.
func WithTemperature ¶
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 ¶
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.
type SummaryPrefixParams ¶
type SummaryPrefixParams struct {
Prefix string `json:"prefix"`
}
SummaryPrefixParams is a struct that stores configuration options for the get_summary_prefix function.
func GetSummaryPrefixArgs ¶
func GetSummaryPrefixArgs(data string) SummaryPrefixParams
GetSummaryPrefixArgs returns the SummaryPrefixParams struct corresponding to the given JSON data.