chat.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package dify
  2. type ChatReq struct {
  3. Query string `json:"query"`
  4. ConversationId string `json:"conversation_id"`
  5. User string `json:"user"`
  6. ResponseMode string `json:"response_mode"`
  7. Files []File `json:"files"`
  8. Inputs interface{} `json:"inputs"`
  9. }
  10. type File struct {
  11. Type string `json:"type"`
  12. TransferMethod string `json:"transfer_method"`
  13. Url string `json:"url"`
  14. }
  15. type ChatResp struct {
  16. Event string `json:"event"`
  17. ConversationId string `json:"conversation_id"`
  18. MessageId string `json:"message_id,omitempty,optional"`
  19. Id string `json:"id,omitempty,optional"`
  20. CreatedAt uint64 `json:"created_at"`
  21. TaskId string `json:"task_id"`
  22. Metadata Meta `json:"Metadata,omitempty,optional"`
  23. Answer string `json:"answer,optional"`
  24. }
  25. type Meta struct {
  26. Usage Usage `json:"usage"`
  27. }
  28. type Usage struct {
  29. PromptTokens uint64 `json:"prompt_tokens"`
  30. CompletionTokens uint64 `json:"completion_tokens"`
  31. TotalTokens uint64 `json:"total_tokens"`
  32. }
  33. type Metadata struct {
  34. }
  35. // GetChatUrl 请求地址
  36. func GetChatUrl() string {
  37. return "/chat-messages"
  38. }
  39. func GetBaseUrl() string {
  40. return "https://dify.gkscrm.com/v1"
  41. }
  42. func GetToken() string {
  43. return "app-NhSN24G0AQV804gWtPfDnFZx"
  44. }