mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
community[patch]: Add missing async_astra_db_client param to AstraDBChatMessageHistory (#17742)
This commit is contained in:
parent
c524bf31f5
commit
3d91be94b1
@ -11,7 +11,7 @@ from langchain_community.utilities.astradb import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from astrapy.db import AstraDB
|
from astrapy.db import AstraDB, AsyncAstraDB
|
||||||
|
|
||||||
from langchain_core.chat_history import BaseChatMessageHistory
|
from langchain_core.chat_history import BaseChatMessageHistory
|
||||||
from langchain_core.messages import (
|
from langchain_core.messages import (
|
||||||
@ -24,6 +24,19 @@ DEFAULT_COLLECTION_NAME = "langchain_message_store"
|
|||||||
|
|
||||||
|
|
||||||
class AstraDBChatMessageHistory(BaseChatMessageHistory):
|
class AstraDBChatMessageHistory(BaseChatMessageHistory):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
session_id: str,
|
||||||
|
collection_name: str = DEFAULT_COLLECTION_NAME,
|
||||||
|
token: Optional[str] = None,
|
||||||
|
api_endpoint: Optional[str] = None,
|
||||||
|
astra_db_client: Optional[AstraDB] = None,
|
||||||
|
async_astra_db_client: Optional[AsyncAstraDB] = None,
|
||||||
|
namespace: Optional[str] = None,
|
||||||
|
setup_mode: SetupMode = SetupMode.SYNC,
|
||||||
|
pre_delete_collection: bool = False,
|
||||||
|
) -> None:
|
||||||
"""Chat message history that stores history in Astra DB.
|
"""Chat message history that stores history in Astra DB.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -35,27 +48,22 @@ class AstraDBChatMessageHistory(BaseChatMessageHistory):
|
|||||||
such as "https://<DB-ID>-us-east1.apps.astra.datastax.com".
|
such as "https://<DB-ID>-us-east1.apps.astra.datastax.com".
|
||||||
astra_db_client: *alternative to token+api_endpoint*,
|
astra_db_client: *alternative to token+api_endpoint*,
|
||||||
you can pass an already-created 'astrapy.db.AstraDB' instance.
|
you can pass an already-created 'astrapy.db.AstraDB' instance.
|
||||||
|
async_astra_db_client: *alternative to token+api_endpoint*,
|
||||||
|
you can pass an already-created 'astrapy.db.AsyncAstraDB' instance.
|
||||||
namespace: namespace (aka keyspace) where the
|
namespace: namespace (aka keyspace) where the
|
||||||
collection is created. Defaults to the database's "default namespace".
|
collection is created. Defaults to the database's "default namespace".
|
||||||
|
setup_mode: mode used to create the Astra DB collection (SYNC, ASYNC or
|
||||||
|
OFF).
|
||||||
|
pre_delete_collection: whether to delete the collection
|
||||||
|
before creating it. If False and the collection already exists,
|
||||||
|
the collection will be used as is.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
*,
|
|
||||||
session_id: str,
|
|
||||||
collection_name: str = DEFAULT_COLLECTION_NAME,
|
|
||||||
token: Optional[str] = None,
|
|
||||||
api_endpoint: Optional[str] = None,
|
|
||||||
astra_db_client: Optional[AstraDB] = None,
|
|
||||||
namespace: Optional[str] = None,
|
|
||||||
setup_mode: SetupMode = SetupMode.SYNC,
|
|
||||||
pre_delete_collection: bool = False,
|
|
||||||
) -> None:
|
|
||||||
self.astra_env = _AstraDBCollectionEnvironment(
|
self.astra_env = _AstraDBCollectionEnvironment(
|
||||||
collection_name=collection_name,
|
collection_name=collection_name,
|
||||||
token=token,
|
token=token,
|
||||||
api_endpoint=api_endpoint,
|
api_endpoint=api_endpoint,
|
||||||
astra_db_client=astra_db_client,
|
astra_db_client=astra_db_client,
|
||||||
|
async_astra_db_client=async_astra_db_client,
|
||||||
namespace=namespace,
|
namespace=namespace,
|
||||||
setup_mode=setup_mode,
|
setup_mode=setup_mode,
|
||||||
pre_delete_collection=pre_delete_collection,
|
pre_delete_collection=pre_delete_collection,
|
||||||
|
Loading…
Reference in New Issue
Block a user