Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultModel is the default model used for chat completions. DefaultModel = strings.Clone(openai.GPT3Dot5Turbo) // ErrMissingAPIKey is returned, if the OPENAI_API_KEY environment variable is not set. ErrMissingAPIKey = fmt.Errorf("%s env variable is not set", envKeyOpenAIApi) )
Functions ¶
This section is empty.
Types ¶
type OpenAIClient ¶
OpenAIClient is a client for the OpenAI API.
func CreateClient ¶
CreateClient creates a new OpenAI client with the given config and output writer.
func (*OpenAIClient) CreateCompletion ¶
func (c *OpenAIClient) CreateCompletion(ctx context.Context, chatID string, prompt []string, modifier string, input []string) (string, error)
CreateCompletion creates a completion for the given prompt and modifier. If chatID is provided, the chat is reused and the completion is added to the chat with this ID. If no chatID is provided, only the modifier and prompt are used to create the completion. The completion is printed to the out writer of the client and returned as a string.
Click to show internal directories.
Click to hide internal directories.