Add CreateCompletionWithFineTunedModel function (#10)

* add fine-tuned completion function

* add explanatory comment
This commit is contained in:
sauceman40
2021-09-01 03:07:53 -07:00
committed by GitHub
parent 7c56bd3034
commit e6b0494d90

View File

@@ -73,3 +73,24 @@ func (c *Client) CreateCompletion(ctx context.Context, engineID string, request
err = c.sendRequest(req, &response) err = c.sendRequest(req, &response)
return return
} }
// CreateCompletionWithFineTunedModel - API call to create a completion with a fine tuned model
// See https://beta.openai.com/docs/guides/fine-tuning/use-a-fine-tuned-model
// In this case, the model is specified in the CompletionRequest object.
func (c *Client) CreateCompletionWithFineTunedModel(ctx context.Context, request CompletionRequest) (response CompletionResponse, err error) {
var reqBytes []byte
reqBytes, err = json.Marshal(request)
if err != nil {
return
}
urlSuffix := "/completions"
req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes))
if err != nil {
return
}
req = req.WithContext(ctx)
err = c.sendRequest(req, &response)
return
}