(
collection: Collection,
chunk: Chunk,
content: Optional[str],
embedding: Optional[List[float]],
num_tokens: Optional[int],
metadata: Optional[Dict],
)
| 5 | |
| 6 | |
| 7 | async def update_chunk( |
| 8 | collection: Collection, |
| 9 | chunk: Chunk, |
| 10 | content: Optional[str], |
| 11 | embedding: Optional[List[float]], |
| 12 | num_tokens: Optional[int], |
| 13 | metadata: Optional[Dict], |
| 14 | ) -> None: |
| 15 | # build update dict |
| 16 | update_dict = {} |
| 17 | if content is not None and embedding is not None and num_tokens is not None: |
| 18 | update_dict["content"] = content |
| 19 | update_dict["embedding"] = embedding |
| 20 | update_dict["num_tokens"] = num_tokens |
| 21 | if metadata is not None: |
| 22 | update_dict["metadata"] = metadata |
| 23 | |
| 24 | chunk_name = Collection.get_chunk_table_name(collection.collection_id) |
| 25 | |
| 26 | # 1. Update chunk in database |
| 27 | async with postgres_pool.get_db_connection() as conn: |
| 28 | if len(update_dict) > 0: |
| 29 | await update_object( |
| 30 | conn, |
| 31 | update_dict=update_dict, |
| 32 | update_time=True, |
| 33 | table_name=chunk_name, |
| 34 | equal_filters={"chunk_id": chunk.chunk_id}, |
| 35 | ) |
nothing calls this directly
no test coverage detected