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

Method create

backend/app/operators/retrieval/record.py:66–113  ·  view source on GitHub ↗
(
        self,
        create_dict: Dict,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

64
65class RecordModelOperator(PostgresModelOperator):
66 async def create(
67 self,
68 create_dict: Dict,
69 **kwargs,
70 ) -> ModelEntity:
71 # handle kwargs
72 self._check_kwargs(object_id_required=None, **kwargs)
73 collection_id = kwargs["collection_id"]
74
75 type = RecordType(create_dict["type"])
76 title = create_dict["title"]
77 content = create_dict["content"]
78 text_splitter = TextSplitter(**create_dict["text_splitter"])
79 metadata = create_dict["metadata"]
80
81 # validate collection
82 collection = await collection_ops.get(collection_id=collection_id)
83
84 # split content into chunks
85 chunk_text_list, num_tokens_list, embeddings, db_content = await process_content(
86 collection=collection,
87 type=type,
88 title=title,
89 content=create_dict.get("content"),
90 file_id=create_dict.get("file_id"),
91 url=create_dict.get("url"),
92 text_splitter=text_splitter,
93 max_num_chunks=collection.rest_capacity(),
94 )
95
96 # create record
97 new_record_id = Record.generate_random_id()
98 await db_record.create_record_and_chunks(
99 record_id=new_record_id,
100 collection=collection,
101 chunk_text_list=chunk_text_list,
102 chunk_embedding_list=embeddings,
103 chunk_num_tokens_list=num_tokens_list,
104 title=title,
105 type=type,
106 content=db_content,
107 metadata=metadata,
108 )
109
110 # get the created record
111 record = await self.get(collection_id=collection_id, record_id=new_record_id)
112
113 return record
114
115 async def update(
116 self,

Callers

nothing calls this directly

Calls 7

RecordTypeClass · 0.90
TextSplitterClass · 0.90
process_contentFunction · 0.85
_check_kwargsMethod · 0.80
rest_capacityMethod · 0.80
getMethod · 0.45
generate_random_idMethod · 0.45

Tested by

no test coverage detected