mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-26 00:23:25 +00:00
Fix inconsistent logging_and_data_dir parameter in AwaDB (#6775)
## Description Tag maintainer: @rlancemartin, @eyurtsev ### log_and_data_dir `AwaDB.__init__()` accepts a parameter named `log_and_data_dir`. But `AwaDB.from_texts()` and `AwaDB.from_documents()` accept a parameter named `logging_and_data_dir`. This inconsistency in this parameter name can lead to confusion on the part of the caller. This PR renames `logging_and_data_dir` to `log_and_data_dir` to make all functions consistent with the constructor. ### embedding `AwaDB.__init__()` accepts a parameter named `embedding_model`. But `AwaDB.from_texts()` and `AwaDB.from_documents()` accept a parameter named `embeddings`. This inconsistency in this parameter name can lead to confusion on the part of the caller. This PR renames `embedding_model` to `embeddings` to make AwaDB's constructor consistent with the classmethod "constructors" as specified by `VectorStore` abstract base class.
This commit is contained in:
parent
3ac08c3de4
commit
cbd759aaeb
@ -27,7 +27,7 @@ class AwaDB(VectorStore):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
table_name: str = _DEFAULT_TABLE_NAME,
|
table_name: str = _DEFAULT_TABLE_NAME,
|
||||||
embedding_model: Optional[Embeddings] = None,
|
embedding: Optional[Embeddings] = None,
|
||||||
log_and_data_dir: Optional[str] = None,
|
log_and_data_dir: Optional[str] = None,
|
||||||
client: Optional[awadb.Client] = None,
|
client: Optional[awadb.Client] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -55,8 +55,8 @@ class AwaDB(VectorStore):
|
|||||||
|
|
||||||
self.awadb_client.Create(table_name)
|
self.awadb_client.Create(table_name)
|
||||||
self.table2embeddings: dict[str, Embeddings] = {}
|
self.table2embeddings: dict[str, Embeddings] = {}
|
||||||
if embedding_model is not None:
|
if embedding is not None:
|
||||||
self.table2embeddings[table_name] = embedding_model
|
self.table2embeddings[table_name] = embedding
|
||||||
self.using_table_name = table_name
|
self.using_table_name = table_name
|
||||||
|
|
||||||
def add_texts(
|
def add_texts(
|
||||||
@ -319,7 +319,7 @@ class AwaDB(VectorStore):
|
|||||||
embedding: Optional[Embeddings] = None,
|
embedding: Optional[Embeddings] = None,
|
||||||
metadatas: Optional[List[dict]] = None,
|
metadatas: Optional[List[dict]] = None,
|
||||||
table_name: str = _DEFAULT_TABLE_NAME,
|
table_name: str = _DEFAULT_TABLE_NAME,
|
||||||
logging_and_data_dir: Optional[str] = None,
|
log_and_data_dir: Optional[str] = None,
|
||||||
client: Optional[awadb.Client] = None,
|
client: Optional[awadb.Client] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> AwaDB:
|
) -> AwaDB:
|
||||||
@ -330,7 +330,7 @@ class AwaDB(VectorStore):
|
|||||||
embedding (Optional[Embeddings]): Embedding function. Defaults to None.
|
embedding (Optional[Embeddings]): Embedding function. Defaults to None.
|
||||||
metadatas (Optional[List[dict]]): List of metadatas. Defaults to None.
|
metadatas (Optional[List[dict]]): List of metadatas. Defaults to None.
|
||||||
table_name (str): Name of the table to create.
|
table_name (str): Name of the table to create.
|
||||||
logging_and_data_dir (Optional[str]): Directory of logging and persistence.
|
log_and_data_dir (Optional[str]): Directory of logging and persistence.
|
||||||
client (Optional[awadb.Client]): AwaDB client
|
client (Optional[awadb.Client]): AwaDB client
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -338,8 +338,8 @@ class AwaDB(VectorStore):
|
|||||||
"""
|
"""
|
||||||
awadb_client = cls(
|
awadb_client = cls(
|
||||||
table_name=table_name,
|
table_name=table_name,
|
||||||
embedding_model=embedding,
|
embedding=embedding,
|
||||||
log_and_data_dir=logging_and_data_dir,
|
log_and_data_dir=log_and_data_dir,
|
||||||
client=client,
|
client=client,
|
||||||
)
|
)
|
||||||
awadb_client.add_texts(texts=texts, metadatas=metadatas)
|
awadb_client.add_texts(texts=texts, metadatas=metadatas)
|
||||||
@ -351,19 +351,19 @@ class AwaDB(VectorStore):
|
|||||||
documents: List[Document],
|
documents: List[Document],
|
||||||
embedding: Optional[Embeddings] = None,
|
embedding: Optional[Embeddings] = None,
|
||||||
table_name: str = _DEFAULT_TABLE_NAME,
|
table_name: str = _DEFAULT_TABLE_NAME,
|
||||||
logging_and_data_dir: Optional[str] = None,
|
log_and_data_dir: Optional[str] = None,
|
||||||
client: Optional[awadb.Client] = None,
|
client: Optional[awadb.Client] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> AwaDB:
|
) -> AwaDB:
|
||||||
"""Create an AwaDB vectorstore from a list of documents.
|
"""Create an AwaDB vectorstore from a list of documents.
|
||||||
|
|
||||||
If a logging_and_data_dir specified, the table will be persisted there.
|
If a log_and_data_dir specified, the table will be persisted there.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
documents (List[Document]): List of documents to add to the vectorstore.
|
documents (List[Document]): List of documents to add to the vectorstore.
|
||||||
embedding (Optional[Embeddings]): Embedding function. Defaults to None.
|
embedding (Optional[Embeddings]): Embedding function. Defaults to None.
|
||||||
table_name (str): Name of the table to create.
|
table_name (str): Name of the table to create.
|
||||||
logging_and_data_dir (Optional[str]): Directory to persist the table.
|
log_and_data_dir (Optional[str]): Directory to persist the table.
|
||||||
client (Optional[awadb.Client]): AwaDB client
|
client (Optional[awadb.Client]): AwaDB client
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -376,6 +376,6 @@ class AwaDB(VectorStore):
|
|||||||
embedding=embedding,
|
embedding=embedding,
|
||||||
metadatas=metadatas,
|
metadatas=metadatas,
|
||||||
table_name=table_name,
|
table_name=table_name,
|
||||||
logging_and_data_dir=logging_and_data_dir,
|
log_and_data_dir=log_and_data_dir,
|
||||||
client=client,
|
client=client,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user