mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
docs: format README.md for samples
PiperOrigin-RevId: 822180731
This commit is contained in:
committed by
Copybara-Service
parent
6a5eac0bdc
commit
0bdba30263
@@ -4,37 +4,45 @@
|
||||
|
||||
This sample tests and demos the OAuth support in ADK via two tools:
|
||||
|
||||
* 1. list_calendar_events
|
||||
* 1. list_calendar_events
|
||||
|
||||
This is a customized tool that calls Google Calendar API to list calendar events.
|
||||
It pass in the client id and client secrete to ADK and then get back the access token from ADK.
|
||||
And then it uses the access token to call calendar api.
|
||||
This is a customized tool that calls Google Calendar API to list calendar
|
||||
events. It pass in the client id and client secrete to ADK and then get back
|
||||
the access token from ADK. And then it uses the access token to call
|
||||
calendar api.
|
||||
|
||||
* 2. get_calendar_events
|
||||
* 2. get_calendar_events
|
||||
|
||||
This is an google calendar tool that calls Google Calendar API to get the details of a specific calendar.
|
||||
This tool is from the ADK built-in Google Calendar ToolSet.
|
||||
Everything is wrapped and the tool user just needs to pass in the client id and client secret.
|
||||
This is an google calendar tool that calls Google Calendar API to get the
|
||||
details of a specific calendar. This tool is from the ADK built-in Google
|
||||
Calendar ToolSet. Everything is wrapped and the tool user just needs to pass
|
||||
in the client id and client secret.
|
||||
|
||||
## How to use
|
||||
|
||||
* 1. Follow https://developers.google.com/identity/protocols/oauth2#1.-obtain-oauth-2.0-credentials-from-the-dynamic_data.setvar.console_name. to get your client id and client secret.
|
||||
Be sure to choose "web" as your client type.
|
||||
* 1. Follow
|
||||
https://developers.google.com/identity/protocols/oauth2#1.-obtain-oauth-2.0-credentials-from-the-dynamic_data.setvar.console_name.
|
||||
to get your client id and client secret. Be sure to choose "web" as your
|
||||
client type.
|
||||
|
||||
* 2. Configure your `.env` file to add two variables:
|
||||
* 2. Configure your `.env` file to add two variables:
|
||||
|
||||
* OAUTH_CLIENT_ID={your client id}
|
||||
* OAUTH_CLIENT_SECRET={your client secret}
|
||||
* OAUTH_CLIENT_ID={your client id}
|
||||
* OAUTH_CLIENT_SECRET={your client secret}
|
||||
|
||||
Note: don't create a separate `.env` file , instead put it to the same `.env` file that stores your Vertex AI or Dev ML credentials
|
||||
Note: don't create a separate `.env` file , instead put it to the same
|
||||
`.env` file that stores your Vertex AI or Dev ML credentials
|
||||
|
||||
* 3. Follow https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred to add http://localhost/dev-ui/ to "Authorized redirect URIs".
|
||||
* 3. Follow
|
||||
https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred
|
||||
to add http://localhost/dev-ui/ to "Authorized redirect URIs".
|
||||
|
||||
Note: localhost here is just a hostname that you use to access the dev ui, replace it with the actual hostname you use to access the dev ui.
|
||||
Note: localhost here is just a hostname that you use to access the dev ui,
|
||||
replace it with the actual hostname you use to access the dev ui.
|
||||
|
||||
* 4. For 1st run, allow popup for localhost in Chrome.
|
||||
* 4. For 1st run, allow popup for localhost in Chrome.
|
||||
|
||||
## Sample prompt
|
||||
|
||||
* `List all my today's meeting from 7am to 7pm.`
|
||||
* `Get the details of the first event.`
|
||||
* `List all my today's meeting from 7am to 7pm.`
|
||||
* `Get the details of the first event.`
|
||||
|
||||
@@ -1,22 +1,32 @@
|
||||
# Output Schema with Tools Sample Agent
|
||||
|
||||
This sample demonstrates how to use structured output (`output_schema`) alongside other tools in an ADK agent. Previously, this combination was not allowed, but now it's supported through a special processor that handles the interaction.
|
||||
This sample demonstrates how to use structured output (`output_schema`)
|
||||
alongside other tools in an ADK agent. Previously, this combination was not
|
||||
allowed, but now it's supported through a special processor that handles the
|
||||
interaction.
|
||||
|
||||
## How it Works
|
||||
|
||||
The agent combines:
|
||||
- **Tools**: `search_wikipedia` and `get_current_year` for gathering information
|
||||
- **Structured Output**: `PersonInfo` schema to ensure consistent response format
|
||||
|
||||
- **Tools**: `search_wikipedia` and `get_current_year` for gathering
|
||||
information
|
||||
- **Structured Output**: `PersonInfo` schema to ensure consistent response
|
||||
format
|
||||
|
||||
When both `output_schema` and `tools` are specified:
|
||||
1. ADK automatically adds a special `set_model_response` tool
|
||||
2. The model can use the regular tools for information gathering
|
||||
3. For the final response, the model uses `set_model_response` with structured data
|
||||
4. ADK extracts and validates the structured response
|
||||
|
||||
1. ADK automatically adds a special `set_model_response` tool
|
||||
2. The model can use the regular tools for information gathering
|
||||
3. For the final response, the model uses `set_model_response` with structured
|
||||
data
|
||||
4. ADK extracts and validates the structured response
|
||||
|
||||
## Expected Response Format
|
||||
|
||||
The agent will return information in this structured format for user query "Tell me about Albert Einstein":
|
||||
The agent will return information in this structured format for user query
|
||||
|
||||
> Tell me about Albert Einstein.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -30,7 +40,7 @@ The agent will return information in this structured format for user query "Tell
|
||||
|
||||
## Key Features Demonstrated
|
||||
|
||||
1. **Tool Usage**: Agent can search Wikipedia and get current year
|
||||
2. **Structured Output**: Response follows strict PersonInfo schema
|
||||
3. **Validation**: ADK validates the response matches the schema
|
||||
4. **Flexibility**: Works with any combination of tools and output schemas
|
||||
1. **Tool Usage**: Agent can search Wikipedia and get current year
|
||||
2. **Structured Output**: Response follows strict PersonInfo schema
|
||||
3. **Validation**: ADK validates the response matches the schema
|
||||
4. **Flexibility**: Works with any combination of tools and output schemas
|
||||
|
||||
Reference in New Issue
Block a user