response.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // ChunkResponse 定义流式响应的结构体
  10. type ChunkResponse struct {
  11. ID string `json:"id"`
  12. Object string `json:"object"`
  13. Model string `json:"model"`
  14. Created int64 `json:"created"`
  15. Status *string `json:"status"`
  16. MessageType int `json:"message_type"`
  17. MessageID *string `json:"message_id"`
  18. IsRef bool `json:"is_ref"`
  19. Docs []string `json:"docs"`
  20. Choices []Choice `json:"choices"`
  21. }
  22. // Choice 定义选择的结构体
  23. type Choice struct {
  24. Delta Delta `json:"delta"`
  25. Role string `json:"role"`
  26. }
  27. // Delta 定义增量的结构体
  28. type Delta struct {
  29. Content string `json:"content"`
  30. ToolCalls []ToolCall `json:"tool_calls"`
  31. }
  32. // ToolCall 定义工具调用的结构体
  33. type ToolCall struct {
  34. ID string `json:"id"`
  35. Type string `json:"type"`
  36. Function Function `json:"function"`
  37. }
  38. // Function 定义函数的结构体
  39. type Function struct {
  40. Name string `json:"name"`
  41. Arguments json.RawMessage `json:"arguments"`
  42. }
  43. type SearchDocsResponse struct {
  44. PageContent string `json:"page_content"`
  45. Metadata Metadata `json:"metadata"`
  46. Type string `json:"type"`
  47. Id string `json:"id"`
  48. Score float32 `json:"score"`
  49. }
  50. type Metadata struct {
  51. Source string `json:"source"`
  52. Id string `json:"id"`
  53. }