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.
 
 

51 lines
1.6 KiB

  1. package gogpt
  2. import (
  3. "context"
  4. "net/http"
  5. )
  6. // Model struct represents an OpenAPI model.
  7. type Model struct {
  8. CreatedAt int64 `json:"created"`
  9. ID string `json:"id"`
  10. Object string `json:"object"`
  11. OwnedBy string `json:"owned_by"`
  12. Permission []Permission `json:"permission"`
  13. Root string `json:"root"`
  14. Parent string `json:"parent"`
  15. }
  16. // Permission struct represents an OpenAPI permission.
  17. type Permission struct {
  18. CreatedAt int64 `json:"created"`
  19. ID string `json:"id"`
  20. Object string `json:"object"`
  21. AllowCreateEngine bool `json:"allow_create_engine"`
  22. AllowSampling bool `json:"allow_sampling"`
  23. AllowLogprobs bool `json:"allow_logprobs"`
  24. AllowSearchIndices bool `json:"allow_search_indices"`
  25. AllowView bool `json:"allow_view"`
  26. AllowFineTuning bool `json:"allow_fine_tuning"`
  27. Organization string `json:"organization"`
  28. Group interface{} `json:"group"`
  29. IsBlocking bool `json:"is_blocking"`
  30. }
  31. // ModelsList is a list of models, including those that belong to the user or organization.
  32. type ModelsList struct {
  33. Models []Model `json:"data"`
  34. }
  35. // ListModels Lists the currently available models,
  36. // and provides basic information about each model such as the model id and parent.
  37. func (c *Client) ListModels(ctx context.Context) (models ModelsList, err error) {
  38. req, err := c.requestBuilder.build(ctx, http.MethodGet, c.fullURL("/models"), nil)
  39. if err != nil {
  40. return
  41. }
  42. err = c.sendRequest(req, &models)
  43. return
  44. }