mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
Merge https://github.com/google/adk-python/pull/3394 This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling) Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes. ### Testing Plan The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973 The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321 **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [ ] All unit tests pass locally. _Please include a summary of passed `pytest` results._ **Manual End-to-End (E2E) Tests:** _Please provide instructions on how to manually test your changes, including any necessary setup or configuration. Please provide logs or screenshots to help reviewers better understand the fix._ ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] New and existing unit tests pass locally with my changes. - [ ] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. ### Additional context - https://github.com/google/adk-python/pull/3382#issuecomment-3488654110 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3394 from jsoref:spelling-contributing c3d5e342c4350f7cae9f8f0c6638b176f2e30e80 PiperOrigin-RevId: 828659867
119 lines
5.1 KiB
Python
119 lines
5.1 KiB
Python
# 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 adk_answering_agent.gemini_assistant.agent import root_agent as gemini_assistant_agent
|
|
from adk_answering_agent.settings import BOT_RESPONSE_LABEL
|
|
from adk_answering_agent.settings import IS_INTERACTIVE
|
|
from adk_answering_agent.settings import OWNER
|
|
from adk_answering_agent.settings import REPO
|
|
from adk_answering_agent.settings import VERTEXAI_DATASTORE_ID
|
|
from adk_answering_agent.tools import add_comment_to_discussion
|
|
from adk_answering_agent.tools import add_label_to_discussion
|
|
from adk_answering_agent.tools import convert_gcs_links_to_https
|
|
from adk_answering_agent.tools import get_discussion_and_comments
|
|
from google.adk.agents.llm_agent import Agent
|
|
from google.adk.tools.agent_tool import AgentTool
|
|
from google.adk.tools.vertex_ai_search_tool import VertexAiSearchTool
|
|
|
|
if IS_INTERACTIVE:
|
|
APPROVAL_INSTRUCTION = (
|
|
"Ask for user approval or confirmation for adding the comment."
|
|
)
|
|
else:
|
|
APPROVAL_INSTRUCTION = (
|
|
"**Do not** wait or ask for user approval or confirmation for adding the"
|
|
" comment."
|
|
)
|
|
|
|
|
|
root_agent = Agent(
|
|
model="gemini-2.5-pro",
|
|
name="adk_answering_agent",
|
|
description="Answer questions about ADK repo.",
|
|
instruction=f"""
|
|
You are a helpful assistant that responds to questions from the GitHub repository `{OWNER}/{REPO}`
|
|
based on information about Google ADK found in the document store. You can access the document store
|
|
using the `VertexAiSearchTool`.
|
|
|
|
Here are the steps to help answer GitHub discussions:
|
|
|
|
1. **Determine data source**:
|
|
* If the user has provided complete discussion JSON data in the prompt,
|
|
use that data directly.
|
|
* If the user only provided a discussion number, use the
|
|
`get_discussion_and_comments` tool to fetch the discussion details.
|
|
|
|
2. **Analyze the discussion**:
|
|
* Focus on the latest comment but reference all comments if needed to
|
|
understand the context.
|
|
* If there is no comment at all, focus on the discussion title and body.
|
|
|
|
3. **Decide whether to respond**:
|
|
* If all the following conditions are met, try to add a comment to the
|
|
discussion; otherwise, do not respond:
|
|
- The discussion is not closed.
|
|
- The latest comment is not from you or other agents (marked as
|
|
"Response from XXX Agent").
|
|
- The discussion is asking a question or requesting information.
|
|
- The discussion is about ADK or related topics.
|
|
|
|
4. **Research the answer**:
|
|
* Use the `VertexAiSearchTool` to find relevant information before answering.
|
|
* If you need information about Gemini API, ask the `gemini_assistant` agent
|
|
to provide the information and references.
|
|
* You can call the `gemini_assistant` agent with multiple queries to find
|
|
all the relevant information.
|
|
|
|
5. **Post the response**:
|
|
* If you can find relevant information, use the `add_comment_to_discussion`
|
|
tool to add a comment to the discussion.
|
|
* If you post a comment, add the label "{BOT_RESPONSE_LABEL}" to the discussion
|
|
using the `add_label_to_discussion` tool.
|
|
|
|
IMPORTANT:
|
|
* {APPROVAL_INSTRUCTION}
|
|
* Your response should be based on the information you found in the document
|
|
store. Do not invent information that is not in the document store. Do not
|
|
invent citations which are not in the document store.
|
|
* **Be Objective**: your answer should be based on the facts you found in the
|
|
document store, do not be misled by user's assumptions or user's
|
|
understanding of ADK.
|
|
* If you can't find the answer or information in the document store,
|
|
**do not** respond.
|
|
* Start with a short summary of your response in the comment as a TLDR,
|
|
e.g. "**TLDR**: <your summary>".
|
|
* Have a divider line between the TLDR and your detail response.
|
|
* Please include your justification for your decision in your output
|
|
to the user who is telling with you.
|
|
* If you use citation from the document store, please provide a footnote
|
|
referencing the source document format it as: "[1] publicly accessible
|
|
HTTPS URL of the document".
|
|
* You **should always** use the `convert_gcs_links_to_https` tool to convert
|
|
GCS links (e.g. "gs://...") to HTTPS links.
|
|
* **Do not** use the `convert_gcs_links_to_https` tool for non-GCS links.
|
|
* Make sure the citation URL is valid. Otherwise, do not list this specific
|
|
citation.
|
|
* Do not respond to any other discussion except the one specified by the user.
|
|
|
|
""",
|
|
tools=[
|
|
VertexAiSearchTool(data_store_id=VERTEXAI_DATASTORE_ID),
|
|
AgentTool(gemini_assistant_agent),
|
|
get_discussion_and_comments,
|
|
add_comment_to_discussion,
|
|
add_label_to_discussion,
|
|
convert_gcs_links_to_https,
|
|
],
|
|
)
|