go-chatgpt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 rivejä
1.1 KiB

  1. package gogpt
  2. import (
  3. "context"
  4. "net/http"
  5. )
  6. // EditsRequest represents a request structure for Edits API.
  7. type EditsRequest struct {
  8. Model *string `json:"model,omitempty"`
  9. Input string `json:"input,omitempty"`
  10. Instruction string `json:"instruction,omitempty"`
  11. N int `json:"n,omitempty"`
  12. Temperature float32 `json:"temperature,omitempty"`
  13. TopP float32 `json:"top_p,omitempty"`
  14. }
  15. // EditsChoice represents one of possible edits.
  16. type EditsChoice struct {
  17. Text string `json:"text"`
  18. Index int `json:"index"`
  19. }
  20. // EditsResponse represents a response structure for Edits API.
  21. type EditsResponse struct {
  22. Object string `json:"object"`
  23. Created int64 `json:"created"`
  24. Usage Usage `json:"usage"`
  25. Choices []EditsChoice `json:"choices"`
  26. }
  27. // Perform an API call to the Edits endpoint.
  28. func (c *Client) Edits(ctx context.Context, request EditsRequest) (response EditsResponse, err error) {
  29. req, err := c.requestBuilder.build(ctx, http.MethodPost, c.fullURL("/edits"), request)
  30. if err != nil {
  31. return
  32. }
  33. err = c.sendRequest(req, &response)
  34. return
  35. }