dto.go 2.3 KB

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