dto.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package ali
  2. import "one-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 AliRerankParameters struct {
  98. TopN *int `json:"top_n,omitempty"`
  99. ReturnDocuments *bool `json:"return_documents,omitempty"`
  100. }
  101. type AliRerankInput struct {
  102. Query string `json:"query"`
  103. Documents []any `json:"documents"`
  104. }
  105. type AliRerankRequest struct {
  106. Model string `json:"model"`
  107. Input AliRerankInput `json:"input"`
  108. Parameters AliRerankParameters `json:"parameters,omitempty"`
  109. }
  110. type AliRerankResponse struct {
  111. Output struct {
  112. Results []dto.RerankResponseResult `json:"results"`
  113. } `json:"output"`
  114. Usage AliUsage `json:"usage"`
  115. RequestId string `json:"request_id"`
  116. AliError
  117. }