dto.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Temperature *float64 `json:"temperature,omitempty"`
  13. TopP float64 `json:"top_p,omitempty"`
  14. PenaltyScore float64 `json:"penalty_score,omitempty"`
  15. Stream bool `json:"stream,omitempty"`
  16. System string `json:"system,omitempty"`
  17. DisableSearch bool `json:"disable_search,omitempty"`
  18. EnableCitation bool `json:"enable_citation,omitempty"`
  19. MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
  20. UserId string `json:"user_id,omitempty"`
  21. }
  22. type Error struct {
  23. ErrorCode int `json:"error_code"`
  24. ErrorMsg string `json:"error_msg"`
  25. }
  26. type BaiduChatResponse struct {
  27. Id string `json:"id"`
  28. Object string `json:"object"`
  29. Created int64 `json:"created"`
  30. Result string `json:"result"`
  31. IsTruncated bool `json:"is_truncated"`
  32. NeedClearHistory bool `json:"need_clear_history"`
  33. Usage dto.Usage `json:"usage"`
  34. Error
  35. }
  36. type BaiduChatStreamResponse struct {
  37. BaiduChatResponse
  38. SentenceId int `json:"sentence_id"`
  39. IsEnd bool `json:"is_end"`
  40. }
  41. type BaiduEmbeddingRequest struct {
  42. Input []string `json:"input"`
  43. }
  44. type BaiduEmbeddingData struct {
  45. Object string `json:"object"`
  46. Embedding []float64 `json:"embedding"`
  47. Index int `json:"index"`
  48. }
  49. type BaiduEmbeddingResponse struct {
  50. Id string `json:"id"`
  51. Object string `json:"object"`
  52. Created int64 `json:"created"`
  53. Data []BaiduEmbeddingData `json:"data"`
  54. Usage dto.Usage `json:"usage"`
  55. Error
  56. }
  57. type BaiduAccessToken struct {
  58. AccessToken string `json:"access_token"`
  59. Error string `json:"error,omitempty"`
  60. ErrorDescription string `json:"error_description,omitempty"`
  61. ExpiresIn int64 `json:"expires_in,omitempty"`
  62. ExpiresAt time.Time `json:"-"`
  63. }
  64. type BaiduTokenResponse struct {
  65. ExpiresIn int `json:"expires_in"`
  66. AccessToken string `json:"access_token"`
  67. }