Skip to content

Commit 1ab171c

Browse files
authored
[ENHANCEMENT] docs: Add howto update record vectors (#5052)
<!-- Thanks for your contribution! As part of our Community Growers initiative 🌱, we're donating Justdiggit bunds in your name to reforest sub-Saharan Africa. To claim your Community Growers certificate, please contact David Berenstein in our Slack community or fill in this form https://tally.so/r/n9XrxK once your PR has been merged. --> # Description This PR adds how to update record vectors in how-to guides. Since the fields cannot be updated, the how-to guides skip them for now. **How Has This Been Tested** (Please describe the tests that you ran to verify your changes.) - [ ] `sphinx-autobuild` (read [Developer Documentation](https://docs.argilla.io/en/latest/community/developer_docs.html#building-the-documentation) for more details) **Checklist** - [ ] I added relevant documentation - [ ] I followed the style guidelines of this project - [ ] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the `CHANGELOG.md` file (See https://keepachangelog.com/)
1 parent fa52a6e commit 1ab171c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

argilla/docs/how_to_guides/record.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ updated_data = [
436436
dataset.records.log(records=updated_data)
437437
```
438438

439-
!!! note "Update the metadata"
439+
=== "Update the metadata"
440440
The `metadata` of `Record` object is a python dictionary. So to update the metadata of a record, you can iterate over the records and update the metadata by key or using `metadata.update`. After that, you should update the records in the dataset.
441441

442442
```python
@@ -452,6 +452,22 @@ dataset.records.log(records=updated_data)
452452
dataset.records.log(records=updated_records)
453453
```
454454

455+
=== "Update vectors"
456+
When a new vector field is added to the dataset settings, or some value for the existing record vectors must updated, you can iterate over the records and update the vectors in the same way as the metadata.
457+
458+
```python
459+
updated_records = []
460+
461+
for record in dataset.records():
462+
463+
record.vectors["new_vector"] = [...]
464+
record.vector["v"] = [...]
465+
466+
updated_records.append(record)
467+
468+
dataset.records.log(records=updated_records)
469+
```
470+
455471
## Delete records
456472

457473
You can delete records in a dataset calling the `delete` method on the `Dataset` object. To delete records, you need to retrieve them from the server and get a list with those that you want to delete.

0 commit comments

Comments
 (0)