@@ -88,6 +88,7 @@ def __init__(
88
88
redis_client : Optional [Redis ] = None ,
89
89
redis_url : str = "redis://localhost:6379" ,
90
90
overwrite : bool = False ,
91
+ connection_kwargs : Dict [str , Any ] = {},
91
92
** kwargs ,
92
93
):
93
94
"""Initialize the SemanticRouter.
@@ -100,7 +101,8 @@ def __init__(
100
101
redis_client (Optional[Redis], optional): Redis client for connection. Defaults to None.
101
102
redis_url (str, optional): The redis url. Defaults to redis://localhost:6379.
102
103
overwrite (bool, optional): Whether to overwrite existing index. Defaults to False.
103
- **kwargs: Additional arguments.
104
+ connection_kwargs (Dict[str, Any]): The connection arguments
105
+ for the redis client. Defaults to empty {}.
104
106
"""
105
107
# Set vectorizer default
106
108
if vectorizer is None :
@@ -115,7 +117,7 @@ def __init__(
115
117
vectorizer = vectorizer ,
116
118
routing_config = routing_config ,
117
119
)
118
- self ._initialize_index (redis_client , redis_url , overwrite )
120
+ self ._initialize_index (redis_client , redis_url , overwrite , ** connection_kwargs )
119
121
120
122
def _initialize_index (
121
123
self ,
@@ -477,19 +479,12 @@ def clear(self) -> None:
477
479
def from_dict (
478
480
cls ,
479
481
data : Dict [str , Any ],
480
- redis_client : Optional [Redis ] = None ,
481
- redis_url : str = "redis://localhost:6379" ,
482
- overwrite : bool = False ,
483
482
** kwargs ,
484
483
) -> "SemanticRouter" :
485
484
"""Create a SemanticRouter from a dictionary.
486
485
487
486
Args:
488
487
data (Dict[str, Any]): The dictionary containing the semantic router data.
489
- redis_client (Optional[Redis]): Redis client for connection.
490
- redis_url (str, optional): The redis url. Defaults to redis://localhost:6379.
491
- overwrite (bool): Whether to overwrite existing index.
492
- **kwargs: Additional arguments.
493
488
494
489
Returns:
495
490
SemanticRouter: The semantic router instance.
@@ -531,9 +526,6 @@ def from_dict(
531
526
routes = routes ,
532
527
vectorizer = vectorizer ,
533
528
routing_config = routing_config ,
534
- redis_client = redis_client ,
535
- redis_url = redis_url ,
536
- overwrite = overwrite ,
537
529
** kwargs ,
538
530
)
539
531
@@ -563,19 +555,12 @@ def to_dict(self) -> Dict[str, Any]:
563
555
def from_yaml (
564
556
cls ,
565
557
file_path : str ,
566
- redis_client : Optional [Redis ] = None ,
567
- redis_url : str = "redis://localhost:6379" ,
568
- overwrite : bool = False ,
569
558
** kwargs ,
570
559
) -> "SemanticRouter" :
571
560
"""Create a SemanticRouter from a YAML file.
572
561
573
562
Args:
574
563
file_path (str): The path to the YAML file.
575
- redis_client (Optional[Redis]): Redis client for connection.
576
- redis_url (str, optional): The redis url. Defaults to redis://localhost:6379.
577
- overwrite (bool): Whether to overwrite existing index.
578
- **kwargs: Additional arguments.
579
564
580
565
Returns:
581
566
SemanticRouter: The semantic router instance.
@@ -601,9 +586,6 @@ def from_yaml(
601
586
yaml_data = yaml .safe_load (f )
602
587
return cls .from_dict (
603
588
yaml_data ,
604
- redis_client = redis_client ,
605
- redis_url = redis_url ,
606
- overwrite = overwrite ,
607
589
** kwargs ,
608
590
)
609
591
0 commit comments