8000 chore: add rag agent for testing · lalitx17/adk-python@484b33e · GitHub
[go: up one dir, main page]

Skip to content

Commit 484b33e

Browse files
abchang123copybara-github
authored andcommitted
chore: add rag agent for testing
PiperOrigin-RevId: 769683091
1 parent aaf1f9b commit 484b33e

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from . import agent
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from dotenv import load_dotenv
18+
from google.adk.agents import Agent
19+
from google.adk.tools.retrieval.vertex_ai_rag_retrieval import VertexAiRagRetrieval
20+
from vertexai.preview import rag
21+
22+
load_dotenv()
23+
24+
ask_vertex_retrieval = VertexAiRagRetrieval(
25+
name="retrieve_rag_documentation",
26+
description=(
27+
"Use this tool to retrieve documentation and reference materials for"
28+
" the question from the RAG corpus,"
29+
),
30+
rag_resources=[
31+
rag.RagResource(
32+
# please fill in your own rag corpus
33+
# e.g. projects/123/locations/us-central1/ragCorpora/456
34+
rag_corpus=os.environ.get("RAG_CORPUS"),
35+
)
36+
],
37+
similarity_top_k=1,
38+
vector_distance_threshold=0.6,
39+
)
40+
41+
root_agent = Agent(
42+
model="gemini-2.0-flash-001",
43+
name="root_agent",
44+
instruction=(
45+
"You are an AI assistant with access to specialized corpus of"
46+
" documents. Your role is to provide accurate and concise answers to"
47+
" questions based on documents that are retrievable using"
48+
" ask_vertex_retrieval."
49+
),
50+
tools=[ask_vertex_retrieval],
51+
)

0 commit comments

Comments
 (0)
0