MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / update_chunk

Function update_chunk

backend/app/database_ops/retrieval/chunk/update.py:7–35  ·  view source on GitHub ↗
(
    collection: Collection,
    chunk: Chunk,
    content: Optional[str],
    embedding: Optional[List[float]],
    num_tokens: Optional[int],
    metadata: Optional[Dict],
)

Source from the content-addressed store, hash-verified

5
6
7async 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 )

Callers

nothing calls this directly

Calls 3

update_objectFunction · 0.90
get_chunk_table_nameMethod · 0.80
get_db_connectionMethod · 0.80

Tested by

no test coverage detected