Update a Record
To update a new record, use the update_record
method. This method requires two primary parameters:
collection_id
: Required. The identifier of the collection where the record will be stored.record_id
: Required. The identifier of the record to be updated.content
: Optional. The textual content of the record.type
: Optional. The type of record. Supported types aretext
,web
, andfile
.url
: Optional. The URL of the webpage to be scraped.file_id
: Optional. The file ID of the file to be record.text_splitter
: Optional. A dictionary containing the text splitter configuration or aTextSplitter object
.metadata
: Optional. A dictionary containing the metadata of the record.
If the content of the record is to be updated. Please make sure the combination of content
, type
, url
, and file_id
are valid.
You should specify the type
and set value for one of the content
, url
, or file_id
parameters that matches with the type.
note
Records of file type cannot be updated. Records of web or text type can be updated with new content, or switch to a different type.
Here is an example of updating a record with new content:
import taskingai
record = taskingai.retrieval.update_record(
collection_id="YOUR_COLLECTION_ID",
record_id="YOUR_RECORD_ID",
type="text",
content="Machine learning is a subfield of artificial intelligence...",
text_splitter={"type": "token", "chunk_size": 200, "chunk_overlap": 20},
)
note
After content update, all the old text chunks associated with the record will be deleted and replaced with the new ones.
Another example of updating a record with new metadata:
import taskingai
record = taskingai.retrieval.update_record(
collection_id="YOUR_COLLECTION_ID",
record_id="YOUR_RECORD_ID",
metadata={"file_name":"machine_learning.pdf", "author": "James Brown"}
)