* Support Retrieve model API (#340) * Test for GetModel error cases. (#340) * Reduce the cognitive complexity of TestClientReturnsRequestBuilderErrors (#340)
This commit is contained in:
committed by
GitHub
parent
1394329e44
commit
6830e00406
14
models.go
14
models.go
@@ -2,6 +2,7 @@ package openai
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -48,3 +49,16 @@ func (c *Client) ListModels(ctx context.Context) (models ModelsList, err error)
|
||||
err = c.sendRequest(req, &models)
|
||||
return
|
||||
}
|
||||
|
||||
// GetModel Retrieves a model instance, providing basic information about
|
||||
// the model such as the owner and permissioning.
|
||||
func (c *Client) GetModel(ctx context.Context, modelID string) (model Model, err error) {
|
||||
urlSuffix := fmt.Sprintf("/models/%s", modelID)
|
||||
req, err := c.requestBuilder.Build(ctx, http.MethodGet, c.fullURL(urlSuffix), nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = c.sendRequest(req, &model)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user