Skip to content

Commit

Permalink
Update vector creation snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliaElv committed Jul 25, 2024
1 parent e61abb0 commit c2f2e6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions argilla/docs/how_to_guides/migrate_from_legacy_datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ Here are a set of example functions to convert the records for single-label and
user_id = users_by_name.get(data["annotation_agent"], current_user).id
responses.append(rg.Response(question_name="label", value=annotation, user_id=user_id))

vectors = (data.get("vectors") or {})
return rg.Record(
id=data["id"],
fields=data["inputs"],
# The inputs field should be a dictionary with the same keys as the `fields` in the settings
metadata=data["metadata"],
# The metadata field should be a dictionary with the same keys as the `metadata` in the settings
vectors=[rg.Vector(name=name, values=value) for name, value in vectors.items()],
vectors=data.get("vectors") or {},
suggestions=suggestions,
responses=responses,
)
Expand All @@ -163,14 +162,13 @@ Here are a set of example functions to convert the records for single-label and
user_id = users_by_name.get(data["annotation_agent"], current_user).id
responses.append(rg.Response(question_name="label", value=annotation, user_id=user_id))

vectors = data.get("vectors") or {}
return rg.Record(
id=data["id"],
fields=data["inputs"],
# The inputs field should be a dictionary with the same keys as the `fields` in the settings
metadata=data["metadata"],
# The metadata field should be a dictionary with the same keys as the `metadata` in the settings
vectors=[rg.Vector(name=name, values=value) for name, value in vectors.items()],
vectors=data.get("vectors") or {},
suggestions=suggestions,
responses=responses,
)
Expand All @@ -193,14 +191,13 @@ Here are a set of example functions to convert the records for single-label and
user_id = users_by_name.get(data["annotation_agent"], current_user).id
responses.append(rg.Response(question_name="spans", value=annotation, user_id=user_id))

vectors = data.get("vectors") or {}
return rg.Record(
id=data["id"],
fields={"text": data["text"]},
# The inputs field should be a dictionary with the same keys as the `fields` in the settings
metadata=data["metadata"],
# The metadata field should be a dictionary with the same keys as the `metadata` in the settings
vectors=[rg.Vector(name=name, values=value) for name, value in vectors.items()],
vectors=data.get("vectors") or {},
# The vectors field should be a dictionary with the same keys as the `vectors` in the settings
suggestions=suggestions,
responses=responses,
Expand All @@ -227,14 +224,13 @@ Here are a set of example functions to convert the records for single-label and
user_id = users_by_name.get(data["annotation_agent"], current_user).id
responses.append(rg.Response(question_name="text_generation", value=annotation, user_id=user_id))

vectors = (data.get("vectors") or {})
return rg.Record(
id=data["id"],
fields={"text": data["text"]},
# The inputs field should be a dictionary with the same keys as the `fields` in the settings
metadata=data["metadata"],
# The metadata field should be a dictionary with the same keys as the `metadata` in the settings
vectors=[rg.Vector(name=name, values=value) for name, value in vectors.items()],
vectors=data.get("vectors") or {},
# The vectors field should be a dictionary with the same keys as the `vectors` in the settings
suggestions=suggestions,
responses=responses,
Expand Down
6 changes: 3 additions & 3 deletions argilla/docs/how_to_guides/record.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ You can associate vectors, like text embeddings, to your records. They can be us
"question": "Do you need oxygen to breathe?",
"answer": "Yes"
},
vectors=[
rg.Vector("my_vector", [0.1, 0.2, 0.3])
],
vectors={
"my_vector": [0.1, 0.2, 0.3]
},
),
rg.Record(
fields={
Expand Down

0 comments on commit c2f2e6d

Please sign in to comment.