mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 23:41:46 +00:00
community[patch]: fix public interface for embeddings module (#21650)
## Description The existing public interface for `langchain_community.emeddings` is broken. In this file, `__all__` is statically defined, but is subsequently overwritten with a dynamic expression, which type checkers like pyright do not support. pyright actually gives the following diagnostic on the line I am requesting we remove: [reportUnsupportedDunderAll](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUnsupportedDunderAll): ``` Operation on "__all__" is not supported, so exported symbol list may be incorrect ``` Currently, I get the following errors when attempting to use publicablly exported classes in `langchain_community.emeddings`: ```python import langchain_community.embeddings langchain_community.embeddings.HuggingFaceEmbeddings(...) # error: "HuggingFaceEmbeddings" is not exported from module "langchain_community.embeddings" (reportPrivateImportUsage) ``` This is solved easily by removing the dynamic expression.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Any, List, Optional, Set, Union
|
||||
from typing import Any, Dict, List, Optional, Set, Union
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
@@ -142,11 +142,12 @@ class TitanTakeoffEmbed(Embeddings):
|
||||
|
||||
def _embed(
|
||||
self, input: Union[List[str], str], consumer_group: Optional[str]
|
||||
) -> dict:
|
||||
) -> Dict[str, Any]:
|
||||
"""Embed text.
|
||||
|
||||
Args:
|
||||
input (List[str]): prompt/document or list of prompts/documents to embed
|
||||
input (Union[List[str], str]): prompt/document or list of prompts/documents
|
||||
to embed
|
||||
consumer_group (Optional[str]): what consumer group to send the embedding
|
||||
request to. If not specified and there is only one
|
||||
consumer group specified during initialization, it will be used. If there
|
||||
|
Reference in New Issue
Block a user