2020from chromadb .errors import InvalidCollectionException
2121from tree_sitter import Point
2222
23- import vectorcode .subcommands .query .types as vectorcode_query_types
2423from vectorcode .chunking import Chunk , TreeSitterChunker
2524from vectorcode .cli_utils import Config , LockManager , expand_path
2625from vectorcode .common import get_embedding_function
3433 VectoriseStats ,
3534)
3635from vectorcode .database .utils import get_collection_id , hash_file
36+ from vectorcode .subcommands .query import types
3737from vectorcode .subcommands .vectorise import get_uuid
3838
3939_logger = logging .getLogger (name = __name__ )
4040
4141
4242def __convert_chroma_query_results (
4343 chroma_result : QueryResult , queries : list [str ]
44- ) -> list [vectorcode_query_types .QueryResult ]:
44+ ) -> list [types .QueryResult ]:
4545 """Convert chromadb query result to in-house query results"""
4646 assert chroma_result ["documents" ] is not None
4747 assert chroma_result ["distances" ] is not None
4848 assert chroma_result ["metadatas" ] is not None
4949 assert chroma_result ["ids" ] is not None
5050
51- chroma_results_list : list [vectorcode_query_types .QueryResult ] = []
51+ chroma_results_list : list [types .QueryResult ] = []
5252 for q_i in range (len (queries )):
5353 q = queries [q_i ]
5454 documents = chroma_result ["documents" ][q_i ]
@@ -64,7 +64,7 @@ def __convert_chroma_query_results(
6464 if meta .get ("path" ):
6565 chunk .path = str (meta ["path" ])
6666 chroma_results_list .append (
67- vectorcode_query_types .QueryResult (
67+ types .QueryResult (
6868 chunk = chunk ,
6969 path = str (meta .get ("path" , "" )),
7070 query = (q ,),
@@ -391,11 +391,12 @@ async def list_collections(self):
391391 result : list [CollectionInfo ] = []
392392 for col_name in await client .list_collections ():
393393 col = await client .get_collection (col_name )
394- col_counts = await self .list (col_name )
394+ project_root = str (col .metadata .get ("path" ))
395+ col_counts = await self .list (project_root )
395396 result .append (
396397 CollectionInfo (
397398 id = col_name ,
398- path = str ( col . metadata . get ( "path" )) ,
399+ path = project_root ,
399400 embedding_function = col .metadata .get (
400401 "embedding_function" ,
401402 Config ().embedding_function , # fallback to default
@@ -413,9 +414,7 @@ async def list(self, collection_path, what=None) -> CollectionContent:
413414 Otherwise, this method may populate only one of them to save waiting time.
414415 """
415416 content = CollectionContent ()
416- collection = await self ._create_or_get_collection (
417- get_collection_id (collection_path )
418- )
417+ collection = await self ._create_or_get_collection ((collection_path ))
419418 raw_content = await collection .get (
420419 include = [
421420 IncludeEnum .metadatas ,
0 commit comments