field.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from pymilvus import FieldSchema, DataType
  2. # milvus 向量数据库
  3. fields = [
  4. # 主键 ID
  5. FieldSchema(
  6. name="id",
  7. dtype=DataType.INT64,
  8. is_primary=True,
  9. auto_id=True,
  10. description="自增id",
  11. ),
  12. # 文档 id 字段
  13. FieldSchema(
  14. name="doc_id", dtype=DataType.VARCHAR, max_length=64, description="文档id"
  15. ),
  16. FieldSchema(name="chunk_id", dtype=DataType.INT64, description="文档分块id"),
  17. # 三种向量字段
  18. FieldSchema(
  19. name="vector_text",
  20. dtype=DataType.FLOAT_VECTOR,
  21. dim=2560,
  22. description="chunk文本 embedding",
  23. ),
  24. FieldSchema(
  25. name="vector_summary",
  26. dtype=DataType.FLOAT_VECTOR,
  27. dim=2560,
  28. description="总结 embedding",
  29. ),
  30. FieldSchema(
  31. name="vector_questions",
  32. dtype=DataType.FLOAT_VECTOR,
  33. dim=2560,
  34. description="衍生问题 embedding",
  35. ),
  36. ]
  37. # pattern fields
  38. mode_fields = [
  39. FieldSchema(
  40. name="id",
  41. dtype=DataType.INT64,
  42. is_primary=True,
  43. auto_id=True,
  44. description="自增id",
  45. ),
  46. # 文档 id 字段
  47. FieldSchema(
  48. name="mode_id", dtype=DataType.VARCHAR, max_length=64, description="模式id"
  49. ),
  50. FieldSchema(
  51. name="mode_vector",
  52. dtype=DataType.FLOAT_VECTOR,
  53. dim=2560,
  54. description="chunk文本 embedding",
  55. ),
  56. ]
  57. __all__ = ["fields", "mode_fields"]