dto.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package baidu
  2. import (
  3. "one-api/dto"
  4. "time"
  5. )
  6. type BaiduMessage struct {
  7. Role string `json:"role"`
  8. Content string `json:"content"`
  9. }
  10. type BaiduChatRequest struct {
  11. Messages []BaiduMessage `json:"messages"`
  12. Stream bool `json:"stream"`
  13. UserId string `json:"user_id,omitempty"`
  14. }
  15. type Error struct {
  16. ErrorCode int `json:"error_code"`
  17. ErrorMsg string `json:"error_msg"`
  18. }
  19. type BaiduChatResponse struct {
  20. Id string `json:"id"`
  21. Object string `json:"object"`
  22. Created int64 `json:"created"`
  23. Result string `json:"result"`
  24. IsTruncated bool `json:"is_truncated"`
  25. NeedClearHistory bool `json:"need_clear_history"`
  26. Usage dto.Usage `json:"usage"`
  27. Error
  28. }
  29. type BaiduChatStreamResponse struct {
  30. BaiduChatResponse
  31. SentenceId int `json:"sentence_id"`
  32. IsEnd bool `json:"is_end"`
  33. }
  34. type BaiduEmbeddingRequest struct {
  35. Input []string `json:"input"`
  36. }
  37. type BaiduEmbeddingData struct {
  38. Object string `json:"object"`
  39. Embedding []float64 `json:"embedding"`
  40. Index int `json:"index"`
  41. }
  42. type BaiduEmbeddingResponse struct {
  43. Id string `json:"id"`
  44. Object string `json:"object"`
  45. Created int64 `json:"created"`
  46. Data []BaiduEmbeddingData `json:"data"`
  47. Usage dto.Usage `json:"usage"`
  48. Error
  49. }
  50. type BaiduAccessToken struct {
  51. AccessToken string `json:"access_token"`
  52. Error string `json:"error,omitempty"`
  53. ErrorDescription string `json:"error_description,omitempty"`
  54. ExpiresIn int64 `json:"expires_in,omitempty"`
  55. ExpiresAt time.Time `json:"-"`
  56. }
  57. type BaiduTokenResponse struct {
  58. ExpiresIn int `json:"expires_in"`
  59. AccessToken string `json:"access_token"`
  60. }