types.go 805 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package api
  2. import (
  3. "fmt"
  4. "net/http"
  5. "strings"
  6. )
  7. type Error struct {
  8. Code int32 `json:"code"`
  9. Message string `json:"message"`
  10. }
  11. func (e Error) Error() string {
  12. if e.Message == "" {
  13. return fmt.Sprintf("%d %v", e.Code, strings.ToLower(http.StatusText(int(e.Code))))
  14. }
  15. return e.Message
  16. }
  17. type PullRequest struct {
  18. Model string `json:"model"`
  19. }
  20. type PullProgress struct {
  21. Total int `json:"total"`
  22. Completed int `json:"completed"`
  23. Percent float64 `json:"percent"`
  24. }
  25. type GenerateRequest struct {
  26. Model string `json:"model"`
  27. Prompt string `json:"prompt"`
  28. }
  29. type GenerateResponse struct {
  30. Response string `json:"response"`
  31. }
  32. type TokenResponse struct {
  33. Choices []TokenResponseChoice `json:"choices"`
  34. }
  35. type TokenResponseChoice struct {
  36. Text string `json:"text"`
  37. }