fix: Updated marqo integration for marqo version 1.0.0+ (#9521)

- Description: Updated marqo integration to use tensor_fields instead of
non_tensor_fields. Upgraded marqo version to 1.2.4
  - Dependencies: marqo 1.2.4

---------

Co-authored-by: Raynor Kirkson E. Chavez <raynor.chavez@192.168.254.171>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
Raynor Chavez 2023-08-22 01:43:15 +08:00 committed by GitHub
parent b2e6d01e8f
commit 973866c894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 17 deletions

View File

@ -78,7 +78,7 @@ class Marqo(VectorStore):
self._searchable_attributes = searchable_attributes self._searchable_attributes = searchable_attributes
self.page_content_builder = page_content_builder self.page_content_builder = page_content_builder
self._non_tensor_fields = ["metadata"] self.tensor_fields = ["text"]
self._document_batch_size = 1024 self._document_batch_size = 1024
@ -132,7 +132,7 @@ class Marqo(VectorStore):
for i in range(0, num_docs, self._document_batch_size): for i in range(0, num_docs, self._document_batch_size):
response = self._client.index(self._index_name).add_documents( response = self._client.index(self._index_name).add_documents(
documents[i : i + self._document_batch_size], documents[i : i + self._document_batch_size],
non_tensor_fields=self._non_tensor_fields, tensor_fields=self.tensor_fields,
**self._add_documents_settings, **self._add_documents_settings,
) )
if response["errors"]: if response["errors"]:
@ -330,17 +330,15 @@ class Marqo(VectorStore):
Dict[str, Dict[List[Dict[str, Dict[str, Any]]]]]: A bulk search results Dict[str, Dict[List[Dict[str, Dict[str, Any]]]]]: A bulk search results
object object
""" """
bulk_results = self._client.bulk_search( bulk_results = {
[ "result": [
{ self._client.index(self._index_name).search(
"index": self._index_name, q=query, searchable_attributes=self._searchable_attributes, limit=k
"q": query, )
"searchableAttributes": self._searchable_attributes,
"limit": k,
}
for query in queries for query in queries
] ]
) }
return bulk_results return bulk_results
@classmethod @classmethod

View File

@ -4407,19 +4407,21 @@ files = [
[[package]] [[package]]
name = "marqo" name = "marqo"
version = "0.11.0" version = "1.2.4"
description = "Tensor search for humans" description = "Tensor search for humans"
category = "main" category = "main"
optional = true optional = true
python-versions = ">=3" python-versions = ">=3"
files = [ files = [
{file = "marqo-0.11.0-py3-none-any.whl", hash = "sha256:e1a5409beeb02dcec725566cfbc5fd88a84ce65ca7bce08a1120f8082badeab4"}, {file = "marqo-1.2.4-py3-none-any.whl", hash = "sha256:aaf59ca35214febaa893e102828a50ab9e53fe57201cd43714ab7c0515166068"},
{file = "marqo-0.11.0.tar.gz", hash = "sha256:808e691cf06f5f7d67d422dc7f5f6fcc53b9acc6a4bc000abbcae8a817fd765d"}, {file = "marqo-1.2.4.tar.gz", hash = "sha256:3fe0eb8e1ed73883fd8e6001582d18dab6e149d79e41b92a1403b2ff52d18c43"},
] ]
[package.dependencies] [package.dependencies]
pydantic = "*" packaging = "*"
pydantic = "<2.0.0"
requests = "*" requests = "*"
typing-extensions = ">=4.5.0"
urllib3 = "*" urllib3 = "*"
[[package]] [[package]]
@ -10487,4 +10489,4 @@ text-helpers = ["chardet"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.8.1,<4.0" python-versions = ">=3.8.1,<4.0"
content-hash = "a5e3458dd0cabcefd83caec6eb33b6fb593c2c347ca1d33c1f182341e852a9c8" content-hash = "0247674f3f274fd2249ceb02c23a468f911a7c482796ea67252b203d1ab938ae"

View File

@ -37,7 +37,7 @@ pinecone-text = {version = "^0.4.2", optional = true}
pymongo = {version = "^4.3.3", optional = true} pymongo = {version = "^4.3.3", optional = true}
clickhouse-connect = {version="^0.5.14", optional=true} clickhouse-connect = {version="^0.5.14", optional=true}
weaviate-client = {version = "^3", optional = true} weaviate-client = {version = "^3", optional = true}
marqo = {version = "^0.11.0", optional=true} marqo = {version = "^1.2.4", optional=true}
google-api-python-client = {version = "2.70.0", optional = true} google-api-python-client = {version = "2.70.0", optional = true}
google-auth = {version = "^2.18.1", optional = true} google-auth = {version = "^2.18.1", optional = true}
wolframalpha = {version = "5.0.0", optional = true} wolframalpha = {version = "5.0.0", optional = true}

View File

@ -158,6 +158,7 @@ def test_marqo_multimodal() -> None:
"mainline/examples/ImageSearchGuide/data/image2.jpg", "mainline/examples/ImageSearchGuide/data/image2.jpg",
}, },
], ],
tensor_fields=["caption", "image"],
) )
def get_content(res: Dict[str, str]) -> str: def get_content(res: Dict[str, str]) -> str: