Add OpenAI Mock Server (#31)

* add constants for completions, refactor usage, add test server

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* append v1 endpoint to test

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* add makefile for easy targets

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* lint files & add linter

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* disable real API tests in short mode

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
This commit is contained in:
Oleg
2022-08-11 05:29:23 -04:00
committed by GitHub
parent 8b463ceb2b
commit d63df93c65
12 changed files with 619 additions and 61 deletions

6
api.go
View File

@@ -15,7 +15,7 @@ func newTransport() *http.Client {
}
}
// Client is OpenAI GPT-3 API client
// Client is OpenAI GPT-3 API client.
type Client struct {
BaseURL string
HTTPClient *http.Client
@@ -23,7 +23,7 @@ type Client struct {
idOrg string
}
// NewClient creates new OpenAI API client
// NewClient creates new OpenAI API client.
func NewClient(authToken string) *Client {
return &Client{
BaseURL: apiURLv1,
@@ -33,7 +33,7 @@ func NewClient(authToken string) *Client {
}
}
// NewOrgClient creates new OpenAI API client for specified Organization ID
// NewOrgClient creates new OpenAI API client for specified Organization ID.
func NewOrgClient(authToken, org string) *Client {
return &Client{
BaseURL: apiURLv1,