@@ -44,7 +44,8 @@ def __init__(
44
44
async def aload_tool (
45
45
self ,
46
46
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 ,
48
49
auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
49
50
bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
50
51
strict : bool = True ,
@@ -54,9 +55,10 @@ async def aload_tool(
54
55
55
56
Args:
56
57
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.
60
62
bound_params: An optional mapping of parameter names to their
61
63
bound values.
62
64
strict: If True, raises a ValueError if any of the given bound
@@ -67,17 +69,30 @@ async def aload_tool(
67
69
A tool loaded from the Toolbox.
68
70
"""
69
71
if auth_headers :
70
- if auth_tokens :
72
+ if auth_token_getters :
71
73
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." ,
73
75
DeprecationWarning ,
74
76
)
75
77
else :
76
78
warn (
77
- "Argument `auth_headers` is deprecated. Use `auth_tokens ` instead." ,
79
+ "Argument `auth_headers` is deprecated. Use `auth_token_getters ` instead." ,
78
80
DeprecationWarning ,
79
81
)
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
81
96
82
97
url = f"{ self .__url } /api/tool/{ tool_name } "
83
98
manifest : ManifestSchema = await _load_manifest (url , self .__session )
@@ -87,15 +102,16 @@ async def aload_tool(
87
102
manifest .tools [tool_name ],
88
103
self .__url ,
89
104
self .__session ,
90
- auth_tokens ,
105
+ auth_token_getters ,
91
106
bound_params ,
92
107
strict ,
93
108
)
94
109
95
110
async def aload_toolset (
96
111
self ,
97
112
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 ,
99
115
auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
100
116
bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
101
117
strict : bool = True ,
@@ -107,9 +123,10 @@ async def aload_toolset(
107
123
Args:
108
124
toolset_name: The name of the toolset to load. If not provided,
109
125
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.
113
130
bound_params: An optional mapping of parameter names to their
114
131
bound values.
115
132
strict: If True, raises a ValueError if any of the given bound
@@ -120,17 +137,30 @@ async def aload_toolset(
120
137
A list of all tools loaded from the Toolbox.
121
138
"""
122
139
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 :
124
154
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." ,
126
156
DeprecationWarning ,
127
157
)
128
158
else :
129
159
warn (
130
- "Argument `auth_headers ` is deprecated. Use `auth_tokens ` instead." ,
160
+ "Argument `auth_tokens ` is deprecated. Use `auth_token_getters ` instead." ,
131
161
DeprecationWarning ,
132
162
)
133
- auth_tokens = auth_headers
163
+ auth_token_getters = auth_tokens
134
164
135
165
url = f"{ self .__url } /api/toolset/{ toolset_name or '' } "
136
166
manifest : ManifestSchema = await _load_manifest (url , self .__session )
@@ -143,7 +173,7 @@ async def aload_toolset(
143
173
tool_schema ,
144
174
self .__url ,
145
175
self .__session ,
146
- auth_tokens ,
176
+ auth_token_getters ,
147
177
bound_params ,
148
178
strict ,
149
179
)
@@ -153,7 +183,8 @@ async def aload_toolset(
153
183
def load_tool (
154
184
self ,
155
185
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 ,
157
188
auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
158
189
bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
159
190
strict : bool = True ,
@@ -163,7 +194,8 @@ def load_tool(
163
194
def load_toolset (
164
195
self ,
165
196
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 ,
167
199
auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
168
200
bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
169
201
strict : bool = True ,
0 commit comments