dto.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package ali
  2. import "one-api/dto"
  3. type AliMessage struct {
  4. Content string `json:"content"`
  5. Role string `json:"role"`
  6. }
  7. type AliInput struct {
  8. Prompt string `json:"prompt,omitempty"`
  9. //History []AliMessage `json:"history,omitempty"`
  10. Messages []AliMessage `json:"messages"`
  11. }
  12. type AliParameters struct {
  13. TopP float64 `json:"top_p,omitempty"`
  14. TopK int `json:"top_k,omitempty"`
  15. Seed uint64 `json:"seed,omitempty"`
  16. EnableSearch bool `json:"enable_search,omitempty"`
  17. IncrementalOutput bool `json:"incremental_output,omitempty"`
  18. }
  19. type AliChatRequest struct {
  20. Model string `json:"model"`
  21. Input AliInput `json:"input,omitempty"`
  22. Parameters AliParameters `json:"parameters,omitempty"`
  23. }
  24. type AliEmbeddingRequest struct {
  25. Model string `json:"model"`
  26. Input struct {
  27. Texts []string `json:"texts"`
  28. } `json:"input"`
  29. Parameters *struct {
  30. TextType string `json:"text_type,omitempty"`
  31. } `json:"parameters,omitempty"`
  32. }
  33. type AliEmbedding struct {
  34. Embedding []float64 `json:"embedding"`
  35. TextIndex int `json:"text_index"`
  36. }
  37. type AliEmbeddingResponse struct {
  38. Output struct {
  39. Embeddings []AliEmbedding `json:"embeddings"`
  40. } `json:"output"`
  41. Usage AliUsage `json:"usage"`
  42. AliError
  43. }
  44. type AliError struct {
  45. Code string `json:"code"`
  46. Message string `json:"message"`
  47. RequestId string `json:"request_id"`
  48. }
  49. type AliUsage struct {
  50. InputTokens int `json:"input_tokens"`
  51. OutputTokens int `json:"output_tokens"`
  52. TotalTokens int `json:"total_tokens"`
  53. }
  54. type TaskResult struct {
  55. B64Image string `json:"b64_image,omitempty"`
  56. Url string `json:"url,omitempty"`
  57. Code string `json:"code,omitempty"`
  58. Message string `json:"message,omitempty"`
  59. }
  60. type AliOutput struct {
  61. TaskId string `json:"task_id,omitempty"`
  62. TaskStatus string `json:"task_status,omitempty"`
  63. Text string `json:"text"`
  64. FinishReason string `json:"finish_reason"`
  65. Message string `json:"message,omitempty"`
  66. Code string `json:"code,omitempty"`
  67. Results []TaskResult `json:"results,omitempty"`
  68. }
  69. type AliResponse struct {
  70. Output AliOutput `json:"output"`
  71. Usage AliUsage `json:"usage"`
  72. AliError
  73. }
  74. type AliImageRequest struct {
  75. Model string `json:"model"`
  76. Input struct {
  77. Prompt string `json:"prompt"`
  78. NegativePrompt string `json:"negative_prompt,omitempty"`
  79. } `json:"input"`
  80. Parameters struct {
  81. Size string `json:"size,omitempty"`
  82. N int `json:"n,omitempty"`
  83. Steps string `json:"steps,omitempty"`
  84. Scale string `json:"scale,omitempty"`
  85. } `json:"parameters,omitempty"`
  86. ResponseFormat string `json:"response_format,omitempty"`
  87. }
  88. type AliRerankParameters struct {
  89. TopN *int `json:"top_n,omitempty"`
  90. ReturnDocuments *bool `json:"return_documents,omitempty"`
  91. }
  92. type AliRerankInput struct {
  93. Query string `json:"query"`
  94. Documents []any `json:"documents"`
  95. }
  96. type AliRerankRequest struct {
  97. Model string `json:"model"`
  98. Input AliRerankInput `json:"input"`
  99. Parameters AliRerankParameters `json:"parameters,omitempty"`
  100. }
  101. type AliRerankResponse struct {
  102. Output struct {
  103. Results []dto.RerankResponseResult `json:"results"`
  104. } `json:"output"`
  105. Usage AliUsage `json:"usage"`
  106. RequestId string `json:"request_id"`
  107. AliError
  108. }