mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-12-19 03:42:22 -06:00
Create a developer folder and add samples.
PiperOrigin-RevId: 755885332
This commit is contained in:
committed by
Copybara-Service
parent
180c2a934b
commit
a4adb739c0
39
contributing/samples/application_integration_agent/README.md
Normal file
39
contributing/samples/application_integration_agent/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Application Integration Agent Sample
|
||||
|
||||
## Introduction
|
||||
|
||||
This sample demonstrates how to use the `ApplicationIntegrationToolset` within an ADK agent to interact with external applications, specifically Jira in this case. The agent (`agent.py`) is configured to manage Jira issues using a pre-configured Application Integration connection.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Set up Integration Connection:**
|
||||
* You need an existing [Integration connection](https://cloud.google.com/integration-connectors/docs/overview) configured to interact with your Jira instance. Follow the [documentation](https://google.github.io/adk-docs/tools/google-cloud-tools/#use-integration-connectors) to provision the Integration Connector in Google Cloud and then use this [documentation](https://cloud.google.com/integration-connectors/docs/connectors/jiracloud/configure) to create an JIRA connection. Note the `Connection Name`, `Project ID`, and `Location` of your connection.
|
||||
*
|
||||
|
||||
2. **Configure Environment Variables:**
|
||||
* Create a `.env` file in the same directory as `agent.py` (or add to your existing one).
|
||||
* Add the following variables to the `.env` file, replacing the placeholder values with your actual connection details:
|
||||
|
||||
```dotenv
|
||||
CONNECTION_NAME=<YOUR_JIRA_CONNECTION_NAME>
|
||||
CONNECTION_PROJECT=<YOUR_GOOGLE_CLOUD_PROJECT_ID>
|
||||
CONNECTION_LOCATION=<YOUR_CONNECTION_LOCATION>
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
1. **Install Dependencies:** Ensure you have the necessary libraries installed (e.g., `google-adk`, `python-dotenv`).
|
||||
2. **Run the Agent:** Execute the agent script from your terminal:
|
||||
```bash
|
||||
python agent.py
|
||||
```
|
||||
3. **Interact:** Once the agent starts, you can interact with it by typing prompts related to Jira issue management.
|
||||
|
||||
## Sample Prompts
|
||||
|
||||
Here are some examples of how you can interact with the agent:
|
||||
|
||||
* `Can you list me all the issues ?`
|
||||
* `Can you list me all the projects ?`
|
||||
* `Can you create an issue: "Bug in product XYZ" in project ABC ?`
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from . import agent
|
||||
50
contributing/samples/application_integration_agent/agent.py
Normal file
50
contributing/samples/application_integration_agent/agent.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Sample agent using Application Integration toolset."""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from google.adk.agents.llm_agent import LlmAgent
|
||||
from google.adk.tools.application_integration_tool import ApplicationIntegrationToolset
|
||||
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
connection_name = os.getenv("CONNECTION_NAME")
|
||||
connection_project = os.getenv("CONNECTION_PROJECT")
|
||||
connection_location = os.getenv("CONNECTION_LOCATION")
|
||||
|
||||
|
||||
jira_tool = ApplicationIntegrationToolset(
|
||||
project=connection_project,
|
||||
location=connection_location,
|
||||
connection=connection_name,
|
||||
entity_operations={"Issues": [], "Projects": []},
|
||||
tool_name="jira_issue_manager",
|
||||
)
|
||||
|
||||
root_agent = LlmAgent(
|
||||
model="gemini-2.0-flash",
|
||||
name="Issue_Management_Agent",
|
||||
instruction="""
|
||||
You are an agent that helps manage issues in a JIRA instance.
|
||||
Be accurate in your responses based on the tool response. You can perform any formatting in the response that is appropriate or if asked by the user.
|
||||
If there is an error in the tool response, understand the error and try and see if you can fix the error and then and execute the tool again. For example if a variable or parameter is missing, try and see if you can find it in the request or user query or default it and then execute the tool again or check for other tools that could give you the details.
|
||||
If there are any math operations like count or max, min in the user request, call the tool to get the data and perform the math operations and then return the result in the response. For example for maximum, fetch the list and then do the math operation.
|
||||
""",
|
||||
tools=jira_tool.get_tools(),
|
||||
)
|
||||
Reference in New Issue
Block a user