@@ -44,7 +44,8 @@ def __init__(
4444 async def aload_tool (
4545 self ,
4646 tool_name : str ,
47- auth_tokens : dict [str , Callable [[], str ]] = {},
47+ auth_token_getters : dict [str , Callable [[], str ]] = {},
48+ auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
4849 auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
4950 bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
5051 strict : bool = True ,
@@ -54,9 +55,10 @@ async def aload_tool(
5455
5556 Args:
5657 tool_name: The name of the tool to load.
57- auth_tokens: An optional mapping of authentication source names to
58- functions that retrieve ID tokens.
59- auth_headers: Deprecated. Use `auth_tokens` instead.
58+ auth_token_getters: An optional mapping of authentication source
59+ names to functions that retrieve ID tokens.
60+ auth_tokens: Deprecated. Use `auth_token_getters` instead.
61+ auth_headers: Deprecated. Use `auth_token_getters` instead.
6062 bound_params: An optional mapping of parameter names to their
6163 bound values.
6264 strict: If True, raises a ValueError if any of the given bound
@@ -67,17 +69,30 @@ async def aload_tool(
6769 A tool loaded from the Toolbox.
6870 """
6971 if auth_headers :
70- if auth_tokens :
72+ if auth_token_getters :
7173 warn (
72- "Both `auth_tokens ` and `auth_headers` are provided. `auth_headers` is deprecated, and `auth_tokens ` will be used." ,
74+ "Both `auth_token_getters ` and `auth_headers` are provided. `auth_headers` is deprecated, and `auth_token_getters ` will be used." ,
7375 DeprecationWarning ,
7476 )
7577 else :
7678 warn (
77- "Argument `auth_headers` is deprecated. Use `auth_tokens ` instead." ,
79+ "Argument `auth_headers` is deprecated. Use `auth_token_getters ` instead." ,
7880 DeprecationWarning ,
7981 )
80- auth_tokens = auth_headers
82+ auth_token_getters = auth_headers
83+
84+ if auth_tokens :
85+ if auth_token_getters :
86+ warn (
87+ "Both `auth_token_getters` and `auth_tokens` are provided. `auth_tokens` is deprecated, and `auth_token_getters` will be used." ,
88+ DeprecationWarning ,
89+ )
90+ else :
91+ warn (
92+ "Argument `auth_tokens` is deprecated. Use `auth_token_getters` instead." ,
93+ DeprecationWarning ,
94+ )
95+ auth_token_getters = auth_tokens
8196
8297 url = f"{ self .__url } /api/tool/{ tool_name } "
8398 manifest : ManifestSchema = await _load_manifest (url , self .__session )
@@ -87,15 +102,16 @@ async def aload_tool(
87102 manifest .tools [tool_name ],
88103 self .__url ,
89104 self .__session ,
90- auth_tokens ,
105+ auth_token_getters ,
91106 bound_params ,
92107 strict ,
93108 )
94109
95110 async def aload_toolset (
96111 self ,
97112 toolset_name : Optional [str ] = None ,
98- auth_tokens : dict [str , Callable [[], str ]] = {},
113+ auth_token_getters : dict [str , Callable [[], str ]] = {},
114+ auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
99115 auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
100116 bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
101117 strict : bool = True ,
@@ -107,9 +123,10 @@ async def aload_toolset(
107123 Args:
108124 toolset_name: The name of the toolset to load. If not provided,
109125 all tools are loaded.
110- auth_tokens: An optional mapping of authentication source names to
111- functions that retrieve ID tokens.
112- auth_headers: Deprecated. Use `auth_tokens` instead.
126+ auth_token_getters: An optional mapping of authentication source
127+ names to functions that retrieve ID tokens.
128+ auth_tokens: Deprecated. Use `auth_token_getters` instead.
129+ auth_headers: Deprecated. Use `auth_token_getters` instead.
113130 bound_params: An optional mapping of parameter names to their
114131 bound values.
115132 strict: If True, raises a ValueError if any of the given bound
@@ -120,17 +137,30 @@ async def aload_toolset(
120137 A list of all tools loaded from the Toolbox.
121138 """
122139 if auth_headers :
123- if auth_tokens :
140+ if auth_token_getters :
141+ warn (
142+ "Both `auth_token_getters` and `auth_headers` are provided. `auth_headers` is deprecated, and `auth_token_getters` will be used." ,
143+ DeprecationWarning ,
144+ )
145+ else :
146+ warn (
147+ "Argument `auth_headers` is deprecated. Use `auth_token_getters` instead." ,
148+ DeprecationWarning ,
149+ )
150+ auth_token_getters = auth_headers
151+
152+ if auth_tokens :
153+ if auth_token_getters :
124154 warn (
125- "Both `auth_tokens ` and `auth_headers ` are provided. `auth_headers ` is deprecated, and `auth_tokens ` will be used." ,
155+ "Both `auth_token_getters ` and `auth_tokens ` are provided. `auth_tokens ` is deprecated, and `auth_token_getters ` will be used." ,
126156 DeprecationWarning ,
127157 )
128158 else :
129159 warn (
130- "Argument `auth_headers ` is deprecated. Use `auth_tokens ` instead." ,
160+ "Argument `auth_tokens ` is deprecated. Use `auth_token_getters ` instead." ,
131161 DeprecationWarning ,
132162 )
133- auth_tokens = auth_headers
163+ auth_token_getters = auth_tokens
134164
135165 url = f"{ self .__url } /api/toolset/{ toolset_name or '' } "
136166 manifest : ManifestSchema = await _load_manifest (url , self .__session )
@@ -143,7 +173,7 @@ async def aload_toolset(
143173 tool_schema ,
144174 self .__url ,
145175 self .__session ,
146- auth_tokens ,
176+ auth_token_getters ,
147177 bound_params ,
148178 strict ,
149179 )
@@ -153,7 +183,8 @@ async def aload_toolset(
153183 def load_tool (
154184 self ,
155185 tool_name : str ,
156- auth_tokens : dict [str , Callable [[], str ]] = {},
186+ auth_token_getters : dict [str , Callable [[], str ]] = {},
187+ auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
157188 auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
158189 bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
159190 strict : bool = True ,
@@ -163,7 +194,8 @@ def load_tool(
163194 def load_toolset (
164195 self ,
165196 toolset_name : Optional [str ] = None ,
166- auth_tokens : dict [str , Callable [[], str ]] = {},
197+ auth_token_getters : dict [str , Callable [[], str ]] = {},
198+ auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
167199 auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
168200 bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
169201 strict : bool = True ,
0 commit comments