Add CreateCompletionWithFineTunedModel function (#10)
* add fine-tuned completion function * add explanatory comment
This commit is contained in:
@@ -73,3 +73,24 @@ func (c *Client) CreateCompletion(ctx context.Context, engineID string, request
|
||||
err = c.sendRequest(req, &response)
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user