Skip to content

Commit 6aa6d73

Browse files
committed
revert Protocol change because Python 3.7
1 parent 0d94881 commit 6aa6d73

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

elasticsearch/helpers/vectorstore/_async/embedding_service.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import List, Optional, Protocol
18+
from abc import ABC, abstractmethod
19+
from typing import List, Optional
1920

2021
from elasticsearch import AsyncElasticsearch
2122

2223

23-
class AsyncEmbeddingService(Protocol):
24+
class AsyncEmbeddingService(ABC):
25+
@abstractmethod
2426
async def embed_documents(self, texts: List[str]) -> List[List[float]]:
2527
"""Generate embeddings for a list of documents.
2628
@@ -31,6 +33,7 @@ async def embed_documents(self, texts: List[str]) -> List[List[float]]:
3133
A list of embeddings, one for each document in the input.
3234
"""
3335

36+
@abstractmethod
3437
async def embed_query(self, query: str) -> List[float]:
3538
"""Generate an embedding for a single query text.
3639

elasticsearch/helpers/vectorstore/_async/strategies.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import Any, Dict, List, Optional, Protocol, Tuple, Union, cast
18+
from abc import ABC, abstractmethod
19+
from typing import Any, Dict, List, Optional, Tuple, Union, cast
1920

2021
from elasticsearch import AsyncElasticsearch
2122
from elasticsearch.helpers.vectorstore._async._utils import model_must_be_deployed
2223
from elasticsearch.helpers.vectorstore._utils import DistanceMetric
2324

2425

25-
class AsyncRetrievalStrategy(Protocol):
26+
class AsyncRetrievalStrategy(ABC):
27+
@abstractmethod
2628
def es_query(
2729
self,
2830
query: Optional[str],
@@ -48,6 +50,7 @@ def es_query(
4850
Dict: The Elasticsearch query body.
4951
"""
5052

53+
@abstractmethod
5154
def es_mappings_settings(
5255
self,
5356
text_field: str,

elasticsearch/helpers/vectorstore/_sync/embedding_service.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import List, Optional, Protocol
18+
from abc import ABC, abstractmethod
19+
from typing import List, Optional
1920

2021
from elasticsearch import Elasticsearch
2122

2223

23-
class EmbeddingService(Protocol):
24+
class EmbeddingService(ABC):
25+
@abstractmethod
2426
def embed_documents(self, texts: List[str]) -> List[List[float]]:
2527
"""Generate embeddings for a list of documents.
2628
@@ -31,6 +33,7 @@ def embed_documents(self, texts: List[str]) -> List[List[float]]:
3133
A list of embeddings, one for each document in the input.
3234
"""
3335

36+
@abstractmethod
3437
def embed_query(self, query: str) -> List[float]:
3538
"""Generate an embedding for a single query text.
3639

elasticsearch/helpers/vectorstore/_sync/strategies.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import Any, Dict, List, Optional, Protocol, Tuple, Union, cast
18+
from abc import ABC, abstractmethod
19+
from typing import Any, Dict, List, Optional, Tuple, Union, cast
1920

2021
from elasticsearch import Elasticsearch
2122
from elasticsearch.helpers.vectorstore._sync._utils import model_must_be_deployed
2223
from elasticsearch.helpers.vectorstore._utils import DistanceMetric
2324

2425

25-
class RetrievalStrategy(Protocol):
26+
class RetrievalStrategy(ABC):
27+
@abstractmethod
2628
def es_query(
2729
self,
2830
query: Optional[str],
@@ -48,6 +50,7 @@ def es_query(
4850
Dict: The Elasticsearch query body.
4951
"""
5052

53+
@abstractmethod
5154
def es_mappings_settings(
5255
self,
5356
text_field: str,

0 commit comments

Comments
 (0)