MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / list

Method list

backend/app/operators/retrieval/chunk.py:137–184  ·  view source on GitHub ↗
(
        self,
        limit: int,
        order: SortOrderEnum,
        after_id: Optional[str] = None,
        before_id: Optional[str] = None,
        prefix_filters: Optional[Dict] = None,
        equal_filters: Optional[Dict] = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

135 await collection_ops.redis.pop(collection)
136
137 async def list(
138 self,
139 limit: int,
140 order: SortOrderEnum,
141 after_id: Optional[str] = None,
142 before_id: Optional[str] = None,
143 prefix_filters: Optional[Dict] = None,
144 equal_filters: Optional[Dict] = None,
145 **kwargs,
146 ) -> (List[ModelEntity], bool):
147 # check kwargs contains all the primary key fields except the id field
148 kwargs = self._check_kwargs(object_id_required=False, **kwargs)
149 collection = await collection_ops.get(collection_id=kwargs["collection_id"])
150 table_name = Collection.get_chunk_table_name(collection_id=collection.collection_id)
151
152 after = None
153 if after_id:
154 after_kwargs = {**kwargs, self.entity_class.id_field_name(): after_id}
155 after = await self.get(**after_kwargs)
156
157 before = None
158 if before_id:
159 before_kwargs = {**kwargs, self.entity_class.id_field_name(): before_id}
160 before = await self.get(**before_kwargs)
161
162 # update equal_filters with kwargs
163 if not equal_filters:
164 equal_filters = {}
165 equal_filters.update({k: v for k, v in kwargs.items()})
166
167 async with self.postgres_pool.get_db_connection() as conn:
168 object_dicts, has_more = await postgres_ops.list_objects(
169 conn=conn,
170 table_name=table_name,
171 order=order,
172 sort_field="created_timestamp",
173 object_id_name=self.entity_class.id_field_name(),
174 limit=limit,
175 after_id=getattr(after, self.entity_class.id_field_name()) if after else None,
176 after_value=getattr(after, "created_timestamp") if after else None,
177 before_id=getattr(before, self.entity_class.id_field_name()) if before else None,
178 before_value=getattr(before, "created_timestamp") if before else None,
179 offset=None,
180 prefix_filters=prefix_filters,
181 equal_filters=equal_filters,
182 )
183 entities = [self.entity_class.build(object_dict) for object_dict in object_dicts]
184 return entities, has_more
185
186 async def _get_entity(self, conn, **kwargs) -> Optional[ModelEntity]:
187 collection = await collection_ops.get(collection_id=kwargs["collection_id"])

Callers 13

ui_listMethod · 0.45
ui_listMethod · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45
api_listFunction · 0.45

Calls 7

_check_kwargsMethod · 0.80
get_chunk_table_nameMethod · 0.80
get_db_connectionMethod · 0.80
getMethod · 0.45
id_field_nameMethod · 0.45
updateMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected