dto.go 2.6 KB

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