dto.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 AliOutput struct {
  54. Text string `json:"text"`
  55. FinishReason string `json:"finish_reason"`
  56. }
  57. type AliChatResponse struct {
  58. Output AliOutput `json:"output"`
  59. Usage AliUsage `json:"usage"`
  60. AliError
  61. }