response.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package eta_llm_http
  2. import "encoding/json"
  3. type BaseResponse struct {
  4. Ret int `json:"ret"`
  5. Msg string `json:"msg"`
  6. Success bool `json:"success"`
  7. Data json.RawMessage `json:"data"`
  8. }
  9. type SteamResponse struct {
  10. Data ChunkResponse `json:"data"`
  11. }
  12. // ChunkResponse 定义流式响应的结构体
  13. type ChunkResponse struct {
  14. ID string `json:"id"`
  15. Object string `json:"object"`
  16. Model string `json:"model"`
  17. Created int64 `json:"created"`
  18. Status *string `json:"status"`
  19. MessageType int `json:"message_type"`
  20. MessageID *string `json:"message_id"`
  21. IsRef bool `json:"is_ref"`
  22. Docs []string `json:"docs"`
  23. Choices []Choice `json:"choices"`
  24. }
  25. // Choice 定义选择的结构体
  26. type Choice struct {
  27. Delta Delta `json:"delta"`
  28. Role string `json:"role"`
  29. }
  30. // Delta 定义增量的结构体
  31. type Delta struct {
  32. Content string `json:"content"`
  33. ToolCalls []ToolCall `json:"tool_calls"`
  34. }
  35. // ToolCall 定义工具调用的结构体
  36. type ToolCall struct {
  37. ID string `json:"id"`
  38. Type string `json:"type"`
  39. Function Function `json:"function"`
  40. }
  41. // Function 定义函数的结构体
  42. type Function struct {
  43. Name string `json:"name"`
  44. Arguments json.RawMessage `json:"arguments"`
  45. }
  46. type SearchDocsResponse struct {
  47. PageContent string `json:"page_content"`
  48. Metadata Metadata `json:"metadata"`
  49. Type string `json:"type"`
  50. Id string `json:"id"`
  51. Score float32 `json:"score"`
  52. }
  53. type Metadata struct {
  54. Source string `json:"source"`
  55. Id string `json:"id"`
  56. }