types.go 870 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 PullResponse struct {
  26. Response string `json:"response"`
  27. }
  28. type GenerateRequest struct {
  29. Model string `json:"model"`
  30. Prompt string `json:"prompt"`
  31. }
  32. type GenerateResponse struct {
  33. Response string `json:"response"`
  34. }
  35. type TokenResponse struct {
  36. Choices []TokenResponseChoice `json:"choices"`
  37. }
  38. type TokenResponseChoice struct {
  39. Text string `json:"text"`
  40. }