dto.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package ali
  2. type AliMessage struct {
  3. User string `json:"user"`
  4. Bot string `json:"bot"`
  5. }
  6. type AliInput struct {
  7. Prompt string `json:"prompt"`
  8. History []AliMessage `json:"history"`
  9. }
  10. type AliParameters struct {
  11. TopP float64 `json:"top_p,omitempty"`
  12. TopK int `json:"top_k,omitempty"`
  13. Seed uint64 `json:"seed,omitempty"`
  14. EnableSearch bool `json:"enable_search,omitempty"`
  15. }
  16. type AliChatRequest struct {
  17. Model string `json:"model"`
  18. Input AliInput `json:"input"`
  19. Parameters AliParameters `json:"parameters,omitempty"`
  20. }
  21. type AliEmbeddingRequest struct {
  22. Model string `json:"model"`
  23. Input struct {
  24. Texts []string `json:"texts"`
  25. } `json:"input"`
  26. Parameters *struct {
  27. TextType string `json:"text_type,omitempty"`
  28. } `json:"parameters,omitempty"`
  29. }
  30. type AliEmbedding struct {
  31. Embedding []float64 `json:"embedding"`
  32. TextIndex int `json:"text_index"`
  33. }
  34. type AliEmbeddingResponse struct {
  35. Output struct {
  36. Embeddings []AliEmbedding `json:"embeddings"`
  37. } `json:"output"`
  38. Usage AliUsage `json:"usage"`
  39. AliError
  40. }
  41. type AliError struct {
  42. Code string `json:"code"`
  43. Message string `json:"message"`
  44. RequestId string `json:"request_id"`
  45. }
  46. type AliUsage struct {
  47. InputTokens int `json:"input_tokens"`
  48. OutputTokens int `json:"output_tokens"`
  49. TotalTokens int `json:"total_tokens"`
  50. }
  51. type AliOutput struct {
  52. Text string `json:"text"`
  53. FinishReason string `json:"finish_reason"`
  54. }
  55. type AliChatResponse struct {
  56. Output AliOutput `json:"output"`
  57. Usage AliUsage `json:"usage"`
  58. AliError
  59. }