Add optional arguments to FalkorDBGraph constructor (#13459)

**Description:** Add optional arguments to FalkorDBGraph constructor
**Tag maintainer:** baskaryan 
**Twitter handle:** @g_korland
This commit is contained in:
Guy Korland 2023-11-17 04:15:40 +02:00 committed by GitHub
parent e3a5cd7969
commit 7f8fd70ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, List from typing import Any, Dict, List, Optional
from langchain.graphs.graph_document import GraphDocument from langchain.graphs.graph_document import GraphDocument
from langchain.graphs.graph_store import GraphStore from langchain.graphs.graph_store import GraphStore
@ -48,7 +48,13 @@ class FalkorDBGraph(GraphStore):
""" """
def __init__( def __init__(
self, database: str, host: str = "localhost", port: int = 6379 self,
database: str,
host: str = "localhost",
port: int = 6379,
username: Optional[str] = None,
password: Optional[str] = None,
ssl: bool = False,
) -> None: ) -> None:
"""Create a new FalkorDB graph wrapper instance.""" """Create a new FalkorDB graph wrapper instance."""
try: try:
@ -60,7 +66,9 @@ class FalkorDBGraph(GraphStore):
"Please install it with `pip install redis`." "Please install it with `pip install redis`."
) )
self._driver = redis.Redis(host=host, port=port) self._driver = redis.Redis(
host=host, port=port, username=username, password=password, ssl=ssl
)
self._graph = Graph(self._driver, database) self._graph = Graph(self._driver, database)
self.schema: str = "" self.schema: str = ""
self.structured_schema: Dict[str, Any] = {} self.structured_schema: Dict[str, Any] = {}