mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-07-19 13:26:32 -04:00
d718f3b6d0
Since it seems like #6111 will be blocked for a bit, I've forked @tyree731's fork and implemented the requested changes. This change adds support to the base Embeddings class for two methods, aembed_query and aembed_documents, those two methods supporting async equivalents of embed_query and embed_documents respectively. This ever so slightly rounds out async support within langchain, with an initial implementation of this functionality being implemented for openai. Implements https://github.com/hwchase17/langchain/issues/6109 --------- Co-authored-by: Stephen Tyree <tyree731@gmail.com>
24 lines
667 B
Python
24 lines
667 B
Python
"""Interface for embedding models."""
|
|
from abc import ABC, abstractmethod
|
|
from typing import List
|
|
|
|
|
|
class Embeddings(ABC):
|
|
"""Interface for embedding models."""
|
|
|
|
@abstractmethod
|
|
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
|
"""Embed search docs."""
|
|
|
|
@abstractmethod
|
|
def embed_query(self, text: str) -> List[float]:
|
|
"""Embed query text."""
|
|
|
|
async def aembed_documents(self, texts: List[str]) -> List[List[float]]:
|
|
"""Embed search docs."""
|
|
raise NotImplementedError
|
|
|
|
async def aembed_query(self, text: str) -> List[float]:
|
|
"""Embed query text."""
|
|
raise NotImplementedError
|