Skip to content

Commit 42c2faa

Browse files
authored
fix: update broken authenticated tool helper (#599)
* fix: update broken authenticated tool helper * fix: Update invalid auth config argument reference in helpers * fix: Incorrect code example for `get_auth_config` `auth_request_function_call`'s args values are dictionaries, meaning it will never be an instance of AuthConfig by default
1 parent df6f1d1 commit 42c2faa

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

docs/tools/authentication.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ from google.genai import types
249249

250250
def get_auth_request_function_call(event: Event) -> types.FunctionCall:
251251
# Get the special auth request function call from the event
252-
if not event.content or event.content.parts:
252+
if not event.content or not event.content.parts:
253253
return
254254
for part in event.content.parts:
255255
if (
@@ -264,9 +264,11 @@ def get_auth_request_function_call(event: Event) -> types.FunctionCall:
264264

265265
def get_auth_config(auth_request_function_call: types.FunctionCall) -> AuthConfig:
266266
# Extracts the AuthConfig object from the arguments of the auth request function call
267-
if not auth_request_function_call.args or not (auth_config := auth_request_function_call.args.get('auth_config')):
267+
if not auth_request_function_call.args or not (auth_config := auth_request_function_call.args.get('authConfig')):
268268
raise ValueError(f'Cannot get auth config from function call: {auth_request_function_call}')
269-
if not isinstance(auth_config, AuthConfig):
269+
if isinstance(auth_config, dict):
270+
auth_config = AuthConfig.model_validate(auth_config)
271+
elif not isinstance(auth_config, AuthConfig):
270272
raise ValueError(f'Cannot get auth config {auth_config} is not an instance of AuthConfig.')
271273
return auth_config
272274
```

llms-full.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78740,7 +78740,7 @@ from google.genai import types
7874078740

7874178741
def get_auth_request_function_call(event: Event) -> types.FunctionCall:
7874278742
# Get the special auth request function call from the event
78743-
if not event.content or event.content.parts:
78743+
if not event.content or not event.content.parts:
7874478744
return
7874578745
for part in event.content.parts:
7874678746
if (
@@ -78755,9 +78755,11 @@ def get_auth_request_function_call(event: Event) -> types.FunctionCall:
7875578755

7875678756
def get_auth_config(auth_request_function_call: types.FunctionCall) -> AuthConfig:
7875778757
# Extracts the AuthConfig object from the arguments of the auth request function call
78758-
if not auth_request_function_call.args or not (auth_config := auth_request_function_call.args.get('auth_config')):
78758+
if not auth_request_function_call.args or not (auth_config := auth_request_function_call.args.get('authConfig')):
7875978759
raise ValueError(f'Cannot get auth config from function call: {auth_request_function_call}')
78760-
if not isinstance(auth_config, AuthConfig):
78760+
if isinstance(auth_config, dict):
78761+
auth_config = AuthConfig.model_validate(auth_config)
78762+
elif not isinstance(auth_config, AuthConfig):
7876178763
raise ValueError(f'Cannot get auth config {auth_config} is not an instance of AuthConfig.')
7876278764
return auth_config
7876378765

0 commit comments

Comments
 (0)