MCPcopy
hub / github.com/langroid/langroid / vecdb

Function vecdb

tests/main/test_doc_chat_agent.py:102–157  ·  view source on GitHub ↗
(test_settings: Settings, request)

Source from the content-addressed store, hash-verified

100
101@pytest.fixture(scope="function")
102def vecdb(test_settings: Settings, request) -> VectorStore:
103 set_global(test_settings)
104 # Unique suffix per pytest-xdist worker so parallel workers don't collide
105 # on the same Qdrant collection in the shared local container (PR #1030).
106 worker = os.environ.get("PYTEST_XDIST_WORKER", "main")
107 if request.param == "qdrant_local":
108 qd_dir = ":memory:"
109 qd_cfg = QdrantDBConfig(
110 cloud=False,
111 collection_name="test-" + embed_cfg.model_type,
112 storage_path=qd_dir,
113 embedding=embed_cfg,
114 )
115 qd = QdrantDB(qd_cfg)
116 yield qd
117 return
118
119 if request.param == "qdrant_cloud":
120 qd_dir = ".qdrant/cloud/test-" + embed_cfg.model_type
121 qd_cfg_cloud = QdrantDBConfig(
122 cloud=True,
123 collection_name=f"test-{embed_cfg.model_type}-{worker}",
124 storage_path=qd_dir,
125 embedding=embed_cfg,
126 )
127 qd_cloud = QdrantDB(qd_cfg_cloud)
128 yield qd_cloud
129 return
130
131 if request.param == "chroma":
132 cd_dir = ".chroma/" + embed_cfg.model_type
133 rmdir(cd_dir)
134 cd_cfg = ChromaDBConfig(
135 collection_name="test-" + embed_cfg.model_type,
136 storage_path=cd_dir,
137 embedding=embed_cfg,
138 )
139 cd = ChromaDB(cd_cfg)
140 yield cd
141 rmdir(cd_dir)
142 return
143
144 if request.param == "lancedb":
145 ldb_dir = ".lancedb/data/" + embed_cfg.model_type
146 rmdir(ldb_dir)
147 ldb_cfg = LanceDBConfig(
148 cloud=False,
149 collection_name="test-" + embed_cfg.model_type,
150 storage_path=ldb_dir,
151 embedding=embed_cfg,
152 document_class=MyDoc, # IMPORTANT, to ensure table has full schema!
153 )
154 ldb = LanceDB(ldb_cfg)
155 yield ldb
156 rmdir(ldb_dir)
157 return
158
159

Callers

nothing calls this directly

Calls 9

set_globalFunction · 0.90
QdrantDBConfigClass · 0.90
QdrantDBClass · 0.90
rmdirFunction · 0.90
ChromaDBConfigClass · 0.90
ChromaDBClass · 0.90
LanceDBConfigClass · 0.90
LanceDBClass · 0.90
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…