@@ -15,7 +15,14 @@ class QueryInput(BaseModel):
15
15
16
16
17
17
class VectorSearchTool (BaseTool ):
18
- def __init__ (self , endpoint_name : str , index_name : str , tool_name : str , columns : list [str ], num_results : int = 5 ):
18
+ def __init__ (
19
+ self ,
20
+ endpoint_name : str ,
21
+ index_name : str ,
22
+ tool_name : str ,
23
+ columns : list [str ],
24
+ num_results : int = 5 ,
25
+ ):
19
26
self .endpoint_name = endpoint_name
20
27
self .index_name = index_name
21
28
self .tool_name = tool_name
@@ -46,17 +53,20 @@ def execute(self, **kwargs):
46
53
return [TextContent (type = "text" , text = json .dumps (docs , indent = 2 ))]
47
54
48
55
49
- def get_table_columns (workspace_client : WorkspaceClient , full_table_name : str ) -> list [str ]:
56
+ def get_table_columns (
57
+ workspace_client : WorkspaceClient , full_table_name : str
58
+ ) -> list [str ]:
50
59
table_info = workspace_client .tables .get (full_table_name )
51
60
return [
52
- col .name
53
- for col in table_info .columns
54
- if col .name != CONTENT_VECTOR_COLUMN_NAME
61
+ col .name for col in table_info .columns if col .name != CONTENT_VECTOR_COLUMN_NAME
55
62
]
56
63
57
64
58
65
def _list_vector_search_tools (
59
- workspace_client : WorkspaceClient , catalog_name : str , schema_name : str , vector_search_num_results : int
66
+ workspace_client : WorkspaceClient ,
67
+ catalog_name : str ,
68
+ schema_name : str ,
69
+ vector_search_num_results : int ,
60
70
) -> list [VectorSearchTool ]:
61
71
tools = []
62
72
for table in workspace_client .tables .list (
@@ -71,12 +81,18 @@ def _list_vector_search_tools(
71
81
72
82
columns = get_table_columns (workspace_client , index_name )
73
83
74
- tools .append (VectorSearchTool (endpoint , index_name , tool_name , columns , vector_search_num_results ))
84
+ tools .append (
85
+ VectorSearchTool (
86
+ endpoint , index_name , tool_name , columns , vector_search_num_results
87
+ )
88
+ )
75
89
76
90
return tools
77
91
78
92
79
93
def list_vector_search_tools (settings : CliSettings ) -> list [VectorSearchTool ]:
80
94
workspace_client = WorkspaceClient ()
81
95
catalog_name , schema_name = settings .schema_full_name .split ("." )
82
- return _list_vector_search_tools (workspace_client , catalog_name , schema_name , settings .vector_search_num_results )
96
+ return _list_vector_search_tools (
97
+ workspace_client , catalog_name , schema_name , settings .vector_search_num_results
98
+ )
0 commit comments