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:
15
engines.go
15
engines.go
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Engine struct represents engine from OpenAPI API
|
||||
// Engine struct represents engine from OpenAPI API.
|
||||
type Engine struct {
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
@@ -14,12 +14,13 @@ type Engine struct {
|
||||
Ready bool `json:"ready"`
|
||||
}
|
||||
|
||||
// EnginesList is a list of engines
|
||||
// EnginesList is a list of engines.
|
||||
type EnginesList struct {
|
||||
Engines []Engine `json:"data"`
|
||||
}
|
||||
|
||||
// ListEngines Lists the currently available engines, and provides basic information about each option such as the owner and availability.
|
||||
// ListEngines Lists the currently available engines, and provides basic
|
||||
// information about each option such as the owner and availability.
|
||||
func (c *Client) ListEngines(ctx context.Context) (engines EnginesList, err error) {
|
||||
req, err := http.NewRequest("GET", c.fullURL("/engines"), nil)
|
||||
if err != nil {
|
||||
@@ -31,8 +32,12 @@ func (c *Client) ListEngines(ctx context.Context) (engines EnginesList, err erro
|
||||
return
|
||||
}
|
||||
|
||||
// GetEngine Retrieves an engine instance, providing basic information about the engine such as the owner and availability.
|
||||
func (c *Client) GetEngine(ctx context.Context, engineID string) (engine Engine, err error) {
|
||||
// GetEngine Retrieves an engine instance, providing basic information about
|
||||
// the engine such as the owner and availability.
|
||||
func (c *Client) GetEngine(
|
||||
ctx context.Context,
|
||||
engineID string,
|
||||
) (engine Engine, err error) {
|
||||
urlSuffix := fmt.Sprintf("/engines/%s", engineID)
|
||||
req, err := http.NewRequest("GET", c.fullURL(urlSuffix), nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user