dto.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package ali
  2. import "github.com/QuantumNous/new-api/dto"
  3. type AliMessage struct {
  4. Content any `json:"content"`
  5. Role string `json:"role"`
  6. }
  7. type AliMediaContent struct {
  8. Image string `json:"image,omitempty"`
  9. Text string `json:"text,omitempty"`
  10. }
  11. type AliInput struct {
  12. Prompt string `json:"prompt,omitempty"`
  13. //History []AliMessage `json:"history,omitempty"`
  14. Messages []AliMessage `json:"messages"`
  15. }
  16. type AliParameters struct {
  17. TopP float64 `json:"top_p,omitempty"`
  18. TopK int `json:"top_k,omitempty"`
  19. Seed uint64 `json:"seed,omitempty"`
  20. EnableSearch bool `json:"enable_search,omitempty"`
  21. IncrementalOutput bool `json:"incremental_output,omitempty"`
  22. }
  23. type AliChatRequest struct {
  24. Model string `json:"model"`
  25. Input AliInput `json:"input,omitempty"`
  26. Parameters AliParameters `json:"parameters,omitempty"`
  27. }
  28. type AliEmbeddingRequest struct {
  29. Model string `json:"model"`
  30. Input struct {
  31. Texts []string `json:"texts"`
  32. } `json:"input"`
  33. Parameters *struct {
  34. TextType string `json:"text_type,omitempty"`
  35. } `json:"parameters,omitempty"`
  36. }
  37. type AliEmbedding struct {
  38. Embedding []float64 `json:"embedding"`
  39. TextIndex int `json:"text_index"`
  40. }
  41. type AliEmbeddingResponse struct {
  42. Output struct {
  43. Embeddings []AliEmbedding `json:"embeddings"`
  44. } `json:"output"`
  45. Usage AliUsage `json:"usage"`
  46. AliError
  47. }
  48. type AliError struct {
  49. Code string `json:"code"`
  50. Message string `json:"message"`
  51. RequestId string `json:"request_id"`
  52. }
  53. type AliUsage struct {
  54. InputTokens int `json:"input_tokens"`
  55. OutputTokens int `json:"output_tokens"`
  56. TotalTokens int `json:"total_tokens"`
  57. }
  58. type TaskResult struct {
  59. B64Image string `json:"b64_image,omitempty"`
  60. Url string `json:"url,omitempty"`
  61. Code string `json:"code,omitempty"`
  62. Message string `json:"message,omitempty"`
  63. }
  64. type AliOutput struct {
  65. TaskId string `json:"task_id,omitempty"`
  66. TaskStatus string `json:"task_status,omitempty"`
  67. Text string `json:"text"`
  68. FinishReason string `json:"finish_reason"`
  69. Message string `json:"message,omitempty"`
  70. Code string `json:"code,omitempty"`
  71. Results []TaskResult `json:"results,omitempty"`
  72. Choices []map[string]any `json:"choices,omitempty"`
  73. }
  74. type AliResponse struct {
  75. Output AliOutput `json:"output"`
  76. Usage AliUsage `json:"usage"`
  77. AliError
  78. }
  79. type AliImageRequest struct {
  80. Model string `json:"model"`
  81. Input any `json:"input"`
  82. Parameters any `json:"parameters,omitempty"`
  83. ResponseFormat string `json:"response_format,omitempty"`
  84. }
  85. type AliImageParameters struct {
  86. Size string `json:"size,omitempty"`
  87. N int `json:"n,omitempty"`
  88. Steps string `json:"steps,omitempty"`
  89. Scale string `json:"scale,omitempty"`
  90. Watermark *bool `json:"watermark,omitempty"`
  91. }
  92. type AliImageInput struct {
  93. Prompt string `json:"prompt,omitempty"`
  94. NegativePrompt string `json:"negative_prompt,omitempty"`
  95. Messages []AliMessage `json:"messages,omitempty"`
  96. }
  97. type WanImageInput struct {
  98. Prompt string `json:"prompt"` // 必需:文本提示词,描述生成图像中期望包含的元素和视觉特点
  99. Images []string `json:"images"` // 必需:图像URL数组,长度不超过2,支持HTTP/HTTPS URL或Base64编码
  100. NegativePrompt string `json:"negative_prompt,omitempty"` // 可选:反向提示词,描述不希望在画面中看到的内容
  101. }
  102. type WanImageParameters struct {
  103. N int `json:"n,omitempty"` // 生成图片数量,取值范围1-4,默认4
  104. Watermark *bool `json:"watermark,omitempty"` // 是否添加水印标识,默认false
  105. Seed int `json:"seed,omitempty"` // 随机数种子,取值范围[0, 2147483647]
  106. Strength float64 `json:"strength,omitempty"` // 修改幅度 0.0-1.0,默认0.5(部分模型支持)
  107. }
  108. type AliRerankParameters struct {
  109. TopN *int `json:"top_n,omitempty"`
  110. ReturnDocuments *bool `json:"return_documents,omitempty"`
  111. }
  112. type AliRerankInput struct {
  113. Query string `json:"query"`
  114. Documents []any `json:"documents"`
  115. }
  116. type AliRerankRequest struct {
  117. Model string `json:"model"`
  118. Input AliRerankInput `json:"input"`
  119. Parameters AliRerankParameters `json:"parameters,omitempty"`
  120. }
  121. type AliRerankResponse struct {
  122. Output struct {
  123. Results []dto.RerankResponseResult `json:"results"`
  124. } `json:"output"`
  125. Usage AliUsage `json:"usage"`
  126. RequestId string `json:"request_id"`
  127. AliError
  128. }