@@ -62,38 +62,52 @@ def example_search_tool_basic():
6262def example_search_modes ():
6363 """Comparing semantic vs local search modes.
6464
65- The search parameter controls which backend search_tools() uses:
65+ Search config can be set at the constructor level or overridden per call:
66+ - Constructor: StackOneToolSet(search={"method": "semantic"})
67+ - Per-call: toolset.search_tools(query, search="local")
68+
69+ The search method controls which backend search_tools() uses:
6670 - "semantic": cloud-based semantic vector search (higher accuracy for natural language)
6771 - "local": local BM25+TF-IDF hybrid search (no network call to semantic API)
6872 - "auto" (default): tries semantic first, falls back to local on failure
6973 """
7074 print ("Example 2: Semantic vs local search modes\n " )
7175
72- toolset = StackOneToolSet ()
7376 query = "manage employee time off"
7477
75- # Semantic search — uses StackOne's semantic search API
76- print ('search="semantic": cloud-based semantic vector search' )
78+ # Constructor-level config — semantic search as the default for this toolset
79+ print ('Constructor config: StackOneToolSet(search={"method": "semantic"})' )
80+ toolset_semantic = StackOneToolSet (search = {"method" : "semantic" })
7781 try :
78- tools_semantic = toolset .search_tools (query , account_ids = _account_ids , top_k = 5 , search = "semantic" )
82+ tools_semantic = toolset_semantic .search_tools (query , account_ids = _account_ids , top_k = 5 )
7983 print (f" Found { len (tools_semantic )} tools:" )
8084 for tool in tools_semantic :
8185 print (f" - { tool .name } " )
8286 except Exception as e :
8387 print (f" Semantic search unavailable: { e } " )
8488 print ()
8589
86- # Local search — BM25+TF-IDF, no semantic API call
87- print ('search="local": local BM25+TF-IDF hybrid search' )
88- tools_local = toolset .search_tools (query , account_ids = _account_ids , top_k = 5 , search = "local" )
90+ # Constructor-level config — local search (no network call to semantic API)
91+ print ('Constructor config: StackOneToolSet(search={"method": "local"})' )
92+ toolset_local = StackOneToolSet (search = {"method" : "local" })
93+ tools_local = toolset_local .search_tools (query , account_ids = _account_ids , top_k = 5 )
8994 print (f" Found { len (tools_local )} tools:" )
9095 for tool in tools_local :
9196 print (f" - { tool .name } " )
9297 print ()
9398
99+ # Per-call override — constructor defaults can be overridden on each call
100+ print ("Per-call override: constructor uses semantic, but this call uses local" )
101+ tools_override = toolset_semantic .search_tools (query , account_ids = _account_ids , top_k = 5 , search = "local" )
102+ print (f" Found { len (tools_override )} tools:" )
103+ for tool in tools_override :
104+ print (f" - { tool .name } " )
105+ print ()
106+
94107 # Auto (default) — tries semantic, falls back to local
95- print ('search="auto" (default): semantic with local fallback' )
96- tools_auto = toolset .search_tools (query , account_ids = _account_ids , top_k = 5 , search = "auto" )
108+ print ('Default: StackOneToolSet() uses search="auto" (semantic with local fallback)' )
109+ toolset_auto = StackOneToolSet ()
110+ tools_auto = toolset_auto .search_tools (query , account_ids = _account_ids , top_k = 5 )
97111 print (f" Found { len (tools_auto )} tools:" )
98112 for tool in tools_auto :
99113 print (f" - { tool .name } " )
0 commit comments