Files
go-openai/edits.go
GargantuaX be253c2d63 change azure engine config to modelMapper (#306)
* change azure engine config to azure modelMapper config

* Update go.mod

* Revert "Update go.mod"

This reverts commit 78d14c58f2a9ce668da43f6adbe20b60afcfe0d7.

* lint fix

* add test

* lint fix

* lint fix

* lint fix

* opt

* opt

* opt

* opt
2023-05-11 01:30:24 +04:00

43 lines
1.1 KiB
Go

package openai
import (
"context"
"fmt"
"net/http"
)
// EditsRequest represents a request structure for Edits API.
type EditsRequest struct {
Model *string `json:"model,omitempty"`
Input string `json:"input,omitempty"`
Instruction string `json:"instruction,omitempty"`
N int `json:"n,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"top_p,omitempty"`
}
// EditsChoice represents one of possible edits.
type EditsChoice struct {
Text string `json:"text"`
Index int `json:"index"`
}
// EditsResponse represents a response structure for Edits API.
type EditsResponse struct {
Object string `json:"object"`
Created int64 `json:"created"`
Usage Usage `json:"usage"`
Choices []EditsChoice `json:"choices"`
}
// Perform an API call to the Edits endpoint.
func (c *Client) Edits(ctx context.Context, request EditsRequest) (response EditsResponse, err error) {
req, err := c.requestBuilder.build(ctx, http.MethodPost, c.fullURL("/edits", fmt.Sprint(request.Model)), request)
if err != nil {
return
}
err = c.sendRequest(req, &response)
return
}