Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Search custom fields with multiple type of values #5559

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
743c945
feat: add support to new fields of type image
jfcalvo Jul 19, 2024
ecf4ec3
chore: update CHANGELOG.md
jfcalvo Jul 19, 2024
40ce2f9
Merge branch 'feat/image-field' into feat/add-image-field-support
jfcalvo Jul 24, 2024
ff4a913
improvement: validate that records values with associated image field…
jfcalvo Jul 26, 2024
047e8b0
chore: update CHANGELOG.md
jfcalvo Jul 26, 2024
183813f
chore: improve import
jfcalvo Jul 26, 2024
558f016
Merge branch 'feat/image-field' into feat/add-image-field-support
jfcalvo Jul 31, 2024
1eecbeb
📝 Html sandbox
damianpumar Jul 31, 2024
9b83316
[FEATURE] `argilla server`: Add support to image fields on search eng…
frascuchon Jul 31, 2024
76ed6ab
feat: add length validation for record image field values
jfcalvo Jul 31, 2024
b96e876
🚑 Poc
damianpumar Jul 31, 2024
65a0cfc
Merge branch 'feat/image-field' into feat/add-image-field-support
jfcalvo Aug 1, 2024
719cf01
✨ Other example
damianpumar Aug 1, 2024
47e21f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2024
251c34c
🐛 Other example
damianpumar Aug 1, 2024
4b5ebf3
feat: Add new ImageFieldSettings
frascuchon Aug 2, 2024
d3ed033
feat: Define new ImageField and a Abstract Field class
frascuchon Aug 2, 2024
d8286e9
refactor: Using generic Field instead of TextField
frascuchon Aug 2, 2024
d507a95
tests: Add some basic unit tests
frascuchon Aug 2, 2024
bcdebd1
tests: Add some image fields to tests
frascuchon Aug 2, 2024
c5f7c55
ci: Using proper server version
frascuchon Aug 2, 2024
7c5a8f8
chore: remove type alias
frascuchon Aug 2, 2024
47781e7
feat: add MIME type validation for records using image fields values …
jfcalvo Aug 2, 2024
21bbd51
Merge branch 'feat/add-image-field-support' into feat/argilla/add-sup…
jfcalvo Aug 2, 2024
7e5136d
[FEATURE] `argilla`: add support to create image fields (#5372)
frascuchon Aug 6, 2024
a919626
Update argilla-server/src/argilla_server/search_engine/commons.py
burtenshaw Aug 8, 2024
d97a8f2
Merge branch 'develop' into feat/add-image-field-support
burtenshaw Aug 8, 2024
e775766
chore: update changelog
burtenshaw Aug 8, 2024
9730793
fix: merged error self >> cls
burtenshaw Aug 8, 2024
7afcb27
fix: merged error self >> cls
burtenshaw Aug 8, 2024
a510ff1
Merge branch 'feat/add-image-field-support' of https://github.com/arg…
burtenshaw Aug 8, 2024
e4b66be
fix: merge mistake - suggestions at self not record
burtenshaw Aug 8, 2024
fd0b1d6
fix: merge mistake: more uncaught refactoring to class methods
burtenshaw Aug 8, 2024
9226b52
🌅 Image field (#5389)
damianpumar Aug 8, 2024
988862b
[FEATURE] [SERVER] chat field support server (#5377)
burtenshaw Aug 8, 2024
fbfae98
Merge branch 'feat/add-image-field-support' into feat/chat-field-support
burtenshaw Aug 8, 2024
af0b40e
[FEATURE] [SDK] chat field support sdk (#5378)
burtenshaw Aug 9, 2024
1733f8a
💬 Chat field frontend (#5388)
damianpumar Aug 9, 2024
8c37f13
✨ POC interactive chat
damianpumar Aug 20, 2024
9b841fb
feat: extend interactive chat with delete, edit, regenerate
burtenshaw Aug 21, 2024
a7117e9
feat: custom field support on server
burtenshaw Aug 21, 2024
fcb663e
feat: custom field support on SDK
burtenshaw Aug 21, 2024
28ef8c3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2024
7ea14dd
Revert "feat: extend interactive chat with delete, edit, regenerate"
damianpumar Aug 21, 2024
2b9e9a6
⚡️ Get fieldText from record
damianpumar Aug 21, 2024
09d18e7
✨ Fix
damianpumar Aug 14, 2024
a73c69f
🚑 TBD, implement type: 'customField'
damianpumar Aug 21, 2024
23dabf7
Merge branch 'feat/interactive-chat' into feat/custom-field-support
burtenshaw Aug 21, 2024
4d54ed8
docs: update sdk docstrings
burtenshaw Aug 22, 2024
3bf3af2
feat: implement custom field as object in sdk and server
burtenshaw Aug 22, 2024
418699c
test: skip tests
burtenshaw Aug 22, 2024
9810450
test: update assertions in tests
burtenshaw Aug 22, 2024
f53e720
✨ Inject record dynamically
damianpumar Aug 22, 2024
ff1c9b3
Merge branch 'feat/interactive-chat' into feat/custom-field-support
burtenshaw Aug 22, 2024
c8d7c47
✨ Fix merging and improve code
damianpumar Aug 23, 2024
c7088c3
✨ Add chat type
damianpumar Aug 23, 2024
b10d97f
feat: sdk load template from file
burtenshaw Aug 23, 2024
5e44ed3
fix: resize iframe in frontend
burtenshaw Aug 23, 2024
64cf3fc
fix: detect chat type on frontend
burtenshaw Aug 23, 2024
10bbaa2
demo: include interactive chat example
burtenshaw Aug 23, 2024
ab7b6b3
Merge branch 'feat/custom-field-support' of https://github.com/argill…
burtenshaw Aug 23, 2024
6680573
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 23, 2024
03e84e3
fix: errors from merge with duplicate ischattype f
burtenshaw Aug 23, 2024
128caaa
🐛 Fix double closing tag
damianpumar Aug 23, 2024
f3a551b
demo: update demo notebook
burtenshaw Aug 26, 2024
af2ecb4
Update argilla-server/CHANGELOG.md
burtenshaw Sep 2, 2024
411a06f
fix: remove logging in Field
burtenshaw Sep 2, 2024
a83758c
Merge branch 'feat/chat-field-support' into feat/custom-field-support
frascuchon Sep 3, 2024
d18c1d1
Merge branch 'develop' into feat/custom-field-support
frascuchon Sep 23, 2024
0f04492
Add extra validation to align fields and values
frascuchon Sep 23, 2024
8d446c8
chore: update tests
frascuchon Sep 23, 2024
cc622ab
fix: Allow other values than str for custom field values
frascuchon Sep 23, 2024
b019e72
add missing tests
frascuchon Sep 23, 2024
b9cbf16
fix: wrong merged changes
frascuchon Sep 23, 2024
e48cc26
remove unnecessary fields overload
frascuchon Sep 23, 2024
f02c1af
chore: Review field value definition
frascuchon Sep 23, 2024
8bb119e
chore: Revert filter change
frascuchon Sep 23, 2024
a286d94
chore remove extra imports
frascuchon Sep 23, 2024
909462e
Merge branch 'develop' into feat/custom-field-support
frascuchon Sep 23, 2024
74e1615
fix: Set fields as optional for record upsert schema
frascuchon Sep 23, 2024
f5c18e3
fix linter errors
frascuchon Sep 23, 2024
27cdeb0
fix field.type usage
frascuchon Sep 23, 2024
99533f6
fix: missing black variable
frascuchon Sep 23, 2024
7703b1d
[ENHANCEMENT] `argilla-server`: add search support for custom fields …
frascuchon Sep 23, 2024
6f73220
[ENHANCEMENT] add custom field mode support (#5526)
burtenshaw Sep 24, 2024
9911f93
test: add tests for custom field
burtenshaw Sep 26, 2024
4da1a4d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
5161486
Merge branch 'develop' into feat/custom-field-support
frascuchon Sep 26, 2024
dd07ac3
chore: reorder params in custom field resource
burtenshaw Sep 26, 2024
ee17b51
︷ Custom field with handlebars (#5462)
damianpumar Sep 26, 2024
bfe8888
✨ Inject SDK record into custom field
damianpumar Sep 27, 2024
e4a95f6
💄 Fix
damianpumar Sep 27, 2024
754f9f8
✨ Fix custom field
damianpumar Sep 27, 2024
9890dbb
Merge branch 'develop' into feat/custom-field-support
frascuchon Sep 30, 2024
7628ac2
📝 Rename record_object to record
damianpumar Sep 30, 2024
d601cdf
📝 Added the json helper for handlebars
damianpumar Sep 30, 2024
3cfbea2
✨ Support dark theme
damianpumar Sep 30, 2024
6e978e7
Show preview for custom field in dataset settings (#5549)
leiyre Oct 1, 2024
a2000dd
Merge branch 'develop' into feat/custom-field-support
jfcalvo Oct 1, 2024
185564e
format stringified json
frascuchon Oct 1, 2024
f3a6693
Merge branch 'develop' into feat/custom-field-support
frascuchon Oct 1, 2024
76097d8
feat: :zap: Add stringify in pre tag
damianpumar Oct 2, 2024
49a760c
remove unused styles and include scroll auto for pre
leiyre Oct 2, 2024
e1ca83b
fix: Search custom fields with multiple type of values
frascuchon Oct 2, 2024
978f850
Merge branch 'develop' into feat/custom-field-support
frascuchon Oct 2, 2024
b3c291d
Merge branch 'feat/custom-field-support' into bugfix/search-on-custom…
frascuchon Oct 2, 2024
960dece
Merge branch 'releases/2.3.0' into bugfix/search-on-custom-with-multi…
frascuchon Oct 2, 2024
52669e2
Merge branch 'releases/2.3.0' into bugfix/search-on-custom-with-multi…
frascuchon Oct 2, 2024
1e940c0
fix wrong merge
frascuchon Oct 2, 2024
95550e3
Merge branch 'releases/2.3.0' into bugfix/search-on-custom-with-multi…
frascuchon Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions argilla-server/src/argilla_server/search_engine/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def es_mapping_for_field(field: Field) -> dict:
elif field.is_custom:
return {
es_field_for_record_field(field.name): {
"type": "object",
"dynamic": True,
"properties": {},
"type": "text",
}
}
elif field.is_image:
Expand Down Expand Up @@ -532,17 +530,19 @@ def _inverse_vector(vector_value: List[float]) -> List[float]:
return [vector_value[i] * -1 for i in range(0, len(vector_value))]

def _map_record_to_es_document(self, record: Record) -> Dict[str, Any]:
dataset = record.dataset

document = {
"id": str(record.id),
"external_id": record.external_id,
"fields": record.fields,
"fields": self._map_record_fields_to_es(record.fields, dataset.fields),
"status": record.status,
"inserted_at": record.inserted_at,
"updated_at": record.updated_at,
}

if record.metadata_:
document["metadata"] = self._map_record_metadata_to_es(record.metadata_, record.dataset.metadata_properties)
document["metadata"] = self._map_record_metadata_to_es(record.metadata_, dataset.metadata_properties)
if record.responses:
document["responses"] = self._map_record_responses_to_es(record.responses)
if record.suggestions:
Expand Down Expand Up @@ -662,7 +662,7 @@ def _build_text_query(dataset: Dataset, text: Optional[Union[TextQuery, str]] =
if field is None:
raise Exception(f"Field {text.field} not found in dataset {dataset.id}")

if field.is_chat or field.is_custom:
if field.is_chat:
field_name = f"{text.field}.*"
else:
field_name = text.field
Expand Down Expand Up @@ -833,6 +833,18 @@ def _map_record_response_to_es(response: Response) -> Dict[str, Any]:
},
}

@classmethod
def _map_record_fields_to_es(cls, fields: dict, dataset_fields: List[Field]) -> dict:
for field in dataset_fields:
if field.is_image:
fields[field.name] = None
elif field.is_custom:
fields[field.name] = str(fields.get(field.name, ""))
else:
fields[field.name] = fields.get(field.name, "")

return fields

async def __terms_aggregation(self, index_name: str, field_name: str, query: dict, size: int) -> List[dict]:
aggregation_name = "terms_agg"

Expand Down
42 changes: 38 additions & 4 deletions argilla-server/tests/unit/search_engine/test_commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
VectorSettingsFactory,
ImageFieldFactory,
ChatFieldFactory,
CustomFieldFactory,
)


Expand Down Expand Up @@ -623,6 +624,34 @@ async def test_search_for_chat_field(self, search_engine: BaseElasticAndOpenSear
assert len(result.items) == 2
assert result.total == 2

async def test_search_for_custom_field(self, search_engine: BaseElasticAndOpenSearchEngine, opensearch: OpenSearch):
custom_field = await CustomFieldFactory.create(name="field")

dataset = await DatasetFactory.create(fields=[custom_field])

records = await RecordFactory.create_batch(
size=2,
dataset=dataset,
fields={
custom_field.name: {
"a": "This is a value",
"b": 100,
}
},
)

await refresh_dataset(dataset)
await refresh_records(records)

await search_engine.create_index(dataset)
await search_engine.index_records(dataset, records)

for query in ["value", 100]:
result = await search_engine.search(dataset, query=TextQuery(q=query, field=custom_field.name))

assert len(result.items) == 2
assert result.total == 2

@pytest.mark.parametrize(
"statuses, expected_items",
[
Expand Down Expand Up @@ -1064,11 +1093,16 @@ async def test_index_records_with_metadata(
async def test_index_records_with_vectors(
self, search_engine: BaseElasticAndOpenSearchEngine, opensearch: OpenSearch
):
dataset = await DatasetFactory.create()
text_fields = await TextFieldFactory.create_batch(size=5, dataset=dataset)
vectors_settings = await VectorSettingsFactory.create_batch(size=5, dataset=dataset, dimensions=5)
text_fields = await TextFieldFactory.create_batch(size=5)
vectors_settings = await VectorSettingsFactory.create_batch(size=5, dimensions=5)

dataset = await DatasetFactory.create(fields=text_fields, vectors_settings=vectors_settings, questions=[])

records = await RecordFactory.create_batch(
size=5, fields={field.name: f"This is the value for {field.name}" for field in text_fields}, responses=[]
size=5,
fields={field.name: f"This is the value for {field.name}" for field in text_fields},
dataset=dataset,
responses=[],
)

for record in records:
Expand Down
Loading