Documentation
¶
Index ¶
Constants ¶
const OpenAIBackend = "https://api.openai.com/v1"
OpenAIBackend is the default URI endpoint for the OpenAI API.
Variables ¶
var ( // ModelGPT35Turbo represents the gpt-3.5-turbo model used by ChatGPT ModelGPT35Turbo = types.Model{"gpt-3.5-turbo", 4096, types.ModelTypeChat} // ModelGPT35Turbo represents the gpt-3.5-turbo-0301 model, a March 1st 2023 // snapshot of gpt-3.5-turbo ModelGPT35Turbo0301 = types.Model{"gpt-3.5-turbo-0301", 4096, types.ModelTypeChat} // ModelGPT4 represents the gpt-4 model ModelGPT4 = types.Model{"gpt-4", 8192, types.ModelTypeChat} // ModelGPT40314 represents the gpt-4-0314 model, a March 14th 2023 snapshot // of the gpt-4 model. ModelGPT40314 = types.Model{"gpt-4-0314", 8192, types.ModelTypeChat} // ModelGPT432K represents the gpt-4-32k model, which is the same as gpt-4, // but with 4x the context length. ModelGPT432K = types.Model{"gpt-4-32k", 32768, types.ModelTypeChat} // ModelGPT432K0314 represents the gpt-4-32k-0314 model, a March 14th 2023 // snapshot of the gpt-4-32k model ModelGPT432K0314 = types.Model{"gpt-4-32k-0314", 32768, types.ModelTypeChat} // ModelGPT4o represents the gpt-4o model ModelGPT4o = types.Model{"gpt-4o", 128000, types.ModelTypeChat} // ModelGPT4o20240513 represents the gpt-4o-2024-05-13 model ModelGPT4o20240513 = types.Model{"gpt-4o-2024-05-13", 128000, types.ModelTypeChat} // ModelGPT4Turbo represents the gpt-4-turbo model ModelGPT4Turbo = types.Model{"gpt-4-turbo", 128000, types.ModelTypeChat} // ModelGPT4Turbo20240409 represents the gpt-4-turbo-2024-04-09 model ModelGPT4Turbo20240409 = types.Model{"gpt-4-turbo-2024-04-09", 128000, types.ModelTypeChat} // SupportedModels is a list of all language models supported by this // backend implementation. SupportedModels = []types.Model{ ModelGPT35Turbo, ModelGPT35Turbo0301, ModelGPT4, ModelGPT40314, ModelGPT432K, ModelGPT432K0314, ModelGPT4Turbo, ModelGPT4Turbo20240409, ModelGPT4o, ModelGPT4o20240513, } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *requests.HTTPClient // contains filtered or unexported fields }
Client is a structure used to continuously generate IaC code via OpenAPI
func NewClient ¶
func NewClient(opts *NewClientOptions) *Client
NewClient creates a new instance of the Client struct, with the provided input options. The OpenAI API backend is not yet contacted at this point.
func (*Client) Chat ¶
func (client *Client) Chat(model types.Model) types.Conversation
Chat initiates a conversation with an OpenAI chat model. A conversation maintains context, allowing to send further instructions to modify the output from previous requests, just like using the ChatGPT website.
func (*Client) Complete ¶
func (client *Client) Complete( ctx context.Context, model types.Model, prompt string, ) (res types.Response, err error)
Complete sends a request to OpenAI's Completions API using the provided model and prompt, and returns the response
func (*Client) DefaultModel ¶
DefaultModel returns the default model used by this backend.
func (*Client) ListModels ¶
ListModels returns a list of all the models supported by this backend implementation.
type Conversation ¶
type Conversation struct {
// contains filtered or unexported fields
}
Conversation is a struct used to converse with an OpenAI chat model. It maintains all messages sent/received in order to maintain context just like using ChatGPT.
func (*Conversation) Send ¶
func (conv *Conversation) Send(ctx context.Context, prompt string, msgs ...types.Message) ( res types.Response, err error, )
Send sends the provided message to the API and returns a Response object. To maintain context, all previous messages (whether from you to the API or vice-versa) are sent as well, allowing you to ask the API to modify the code it already generated.
type NewClientOptions ¶
type NewClientOptions struct { // APIKey is the OpenAI API key to use for requests. This is required. ApiKey string // URL is the OpenAI API URL to userequests. Optional, defaults to OpenAIBackend. URL string // APIVersion is the version of the OpenAI API to use. Optional. APIVersion string }
NewClientOptions is a struct containing all the parameters accepted by the NewClient constructor.