54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
# Copyright 2026 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.
|
|
|
|
"""ADK agent with vector search RAG tool."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from google.adk.agents.llm_agent import Agent
|
|
|
|
from .config_helper import settings
|
|
from .vector_search_tool import VectorSearchTool
|
|
|
|
# Create vector search tool with configuration
|
|
vector_search_tool = VectorSearchTool(
|
|
name='conocimiento',
|
|
description='Search the vector index for company products and services information',
|
|
embedder=settings.embedder,
|
|
project_id=settings.project_id,
|
|
location=settings.location,
|
|
bucket=settings.bucket,
|
|
index_name=settings.index_name,
|
|
index_endpoint=settings.index_endpoint,
|
|
index_deployed_id=settings.index_deployed_id,
|
|
similarity_top_k=5,
|
|
min_similarity_threshold=0.6,
|
|
relative_threshold_factor=0.9,
|
|
)
|
|
|
|
# Create agent with vector search tool
|
|
# Configure model with Vertex AI fully qualified path
|
|
model_path = (
|
|
f'projects/{settings.project_id}/locations/{settings.location}/'
|
|
f'publishers/google/models/{settings.agent_language_model}'
|
|
)
|
|
|
|
root_agent = Agent(
|
|
model=model_path,
|
|
name=settings.agent_name,
|
|
description='A helpful assistant for user questions.',
|
|
instruction=settings.agent_instructions,
|
|
tools=[vector_search_tool],
|
|
)
|