@@ -26,30 +26,58 @@ def list(ctx):
2626 client = ctx .obj ["client" ]
2727 console = Console ()
2828 memory_banks_list_response = client .memory_banks .list ()
29- headers = []
30- if memory_banks_list_response and len (memory_banks_list_response ) > 0 :
31- headers = sorted (memory_banks_list_response [0 ].__dict__ .keys ())
3229
3330 if memory_banks_list_response :
3431 table = Table ()
35- for header in headers :
36- table .add_column (header )
32+ # Add our specific columns
33+ table .add_column ("identifier" )
34+ table .add_column ("provider_id" )
35+ table .add_column ("provider_resource_id" )
36+ table .add_column ("memory_bank_type" )
37+ table .add_column ("params" )
3738
3839 for item in memory_banks_list_response :
39- table .add_row (* [str (getattr (item , header )) for header in headers ])
40+ # Create a dict of all attributes
41+ item_dict = item .__dict__
42+
43+ # Extract our main columns
44+ identifier = str (item_dict .pop ("identifier" , "" ))
45+ provider_id = str (item_dict .pop ("provider_id" , "" ))
46+ provider_resource_id = str (item_dict .pop ("provider_resource_id" , "" ))
47+ memory_bank_type = str (item_dict .pop ("memory_bank_type" , "" ))
48+ # Convert remaining attributes to YAML string for params column
49+ params = yaml .dump (item_dict , default_flow_style = False )
50+
51+ table .add_row (identifier , provider_id , provider_resource_id , memory_bank_type , params )
52+
4053 console .print (table )
4154
4255
4356@memory_banks .command ()
44- @click .option ( "-- memory-bank-id" , required = True , help = "Id of the memory bank " )
57+ @click .argument ( " memory-bank-id" )
4558@click .option ("--type" , type = click .Choice (["vector" , "keyvalue" , "keyword" , "graph" ]), required = True )
4659@click .option ("--provider-id" , help = "Provider ID for the memory bank" , default = None )
4760@click .option ("--provider-memory-bank-id" , help = "Provider's memory bank ID" , default = None )
48- @click .option ("--chunk-size" , type = int , help = "Chunk size in tokens (for vector type)" , default = 512 )
49- @click .option ("--embedding-model" , type = str , help = "Embedding model (for vector type)" , default = "all-MiniLM-L6-v2" )
50- @click .option ("--overlap-size" , type = int , help = "Overlap size in tokens (for vector type)" , default = 64 )
61+ @click .option (
62+ "--chunk-size" ,
63+ type = int ,
64+ help = "Chunk size in tokens (for vector type)" ,
65+ default = 512 ,
66+ )
67+ @click .option (
68+ "--embedding-model" ,
69+ type = str ,
70+ help = "Embedding model (for vector type)" ,
71+ default = "all-MiniLM-L6-v2" ,
72+ )
73+ @click .option (
74+ "--overlap-size" ,
75+ type = int ,
76+ help = "Overlap size in tokens (for vector type)" ,
77+ default = 64 ,
78+ )
5179@click .pass_context
52- def create (
80+ def register (
5381 ctx ,
5482 memory_bank_id : str ,
5583 type : str ,
@@ -65,18 +93,24 @@ def create(
6593 config = None
6694 if type == "vector" :
6795 config = {
68- "type " : "vector" ,
96+ "memory_bank_type " : "vector" ,
6997 "chunk_size_in_tokens" : chunk_size ,
7098 "embedding_model" : embedding_model ,
7199 }
72100 if overlap_size :
73101 config ["overlap_size_in_tokens" ] = overlap_size
74102 elif type == "keyvalue" :
75- config = {"type " : "keyvalue" }
103+ config = {"memory_bank_type " : "keyvalue" }
76104 elif type == "keyword" :
77- config = {"type " : "keyword" }
105+ config = {"memory_bank_type " : "keyword" }
78106 elif type == "graph" :
79- config = {"type" : "graph" }
107+ config = {"memory_bank_type" : "graph" }
108+
109+ from rich import print as rprint
110+ from rich .pretty import pprint
111+
112+ rprint ("\n [bold blue]Memory Bank Configuration:[/bold blue]" )
113+ pprint (config , expand_all = True )
80114
81115 response = client .memory_banks .register (
82116 memory_bank_id = memory_bank_id ,
@@ -88,6 +122,17 @@ def create(
88122 click .echo (yaml .dump (response .dict ()))
89123
90124
125+ @memory_banks .command ()
126+ @click .argument ("memory-bank-id" )
127+ @click .pass_context
128+ def unregister (ctx , memory_bank_id : str ):
129+ """Delete a memory bank"""
130+ client = ctx .obj ["client" ]
131+ client .memory_banks .unregister (memory_bank_id = memory_bank_id )
132+ click .echo (f"Memory bank '{ memory_bank_id } ' deleted successfully" )
133+
134+
91135# Register subcommands
92136memory_banks .add_command (list )
93- memory_banks .add_command (create )
137+ memory_banks .add_command (register )
138+ memory_banks .add_command (unregister )
0 commit comments