写点什么

Google Cloud Agent Starter Pack

作者:qife
  • 2025-07-09
    福建
  • 本文字数:2057 字

    阅读完需:约 7 分钟

项目标题与描述

Google Cloud Agent Starter Pack 是一个专为 Google Cloud 设计的生成式 AI 代理模板集合。该项目旨在加速生成式 AI 代理的开发过程,提供从原型到生产的完整解决方案。


核心价值:


  • 提供多种预构建代理模板(ReAct、RAG、多代理、实时 API 等)

  • 内置 Vertex AI 评估和交互式测试环境

  • 生产级基础设施(监控、可观测性)

  • 支持快速定制和扩展

功能特性

核心功能

  • 多种代理模板:包括基础代理、研究代理、多模态代理等多种模板

  • 生产就绪架构:内置监控、日志和可观测性功能

  • 灵活的数据存储选项:支持 Vertex AI Search 和 Vertex AI Vector Search

  • 自动化数据管道:自动化的数据摄取和处理流程

  • 开发工具集成:与 LangChain、CrewAI 等流行框架集成

特色代理

  • ADK 基础代理:展示 Agent Development Kit 核心概念

  • 全栈研究代理:复杂的研究工作流,支持人机交互

  • 多模态实时代理:处理音频、视频和文本交互

  • RAG 代理:增强检索能力的问答代理

  • CrewAI 编码代理:协作式代码生成代理

安装指南

系统要求

  • Python 3.10+

  • Google Cloud SDK

  • Terraform (用于基础设施部署)

安装步骤

  1. 克隆仓库:


   git clone https://github.com/GoogleCloudPlatform/agent-starter-pack.git   cd agent-starter-pack
复制代码


  1. 安装依赖:


   make install
复制代码


  1. 设置 GCP 项目:


   export GOOGLE_CLOUD_PROJECT=your-project-id   gcloud config set project $GOOGLE_CLOUD_PROJECT
复制代码


  1. 启用所需 API:


   make enable-apis
复制代码


  1. 部署基础设施:


   make deploy-infra
复制代码

使用说明

基础使用

启动交互式测试环境:


make playground
复制代码

运行数据摄取管道

export PROJECT_ID="your-project-id"make data-ingestion
复制代码

部署代理到 Cloud Run

make deploy-cloud-run
复制代码

API 示例

基础代理调用示例:


from app.agent import root_agent
response = root_agent.invoke("What's the weather in San Francisco?")print(response)
复制代码

核心代码

基础代理实现

import datetimeimport osfrom zoneinfo import ZoneInfo
import google.authfrom google.adk.agents import Agent
_, project_id = google.auth.default()os.environ.setdefault("GOOGLE_CLOUD_PROJECT", project_id)os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global")os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True")
def get_weather(query: str) -> str: """模拟天气查询""" if "sf" in query.lower() or "san francisco" in query.lower(): return "It's 60 degrees and foggy." return "It's 90 degrees and sunny."
def get_current_time(query: str) -> str: """模拟时间查询""" if "sf" in query.lower() or "san francisco" in query.lower(): tz_identifier = "America/Los_Angeles" else: return f"Sorry, I don't have timezone information for query: {query}."
tz = ZoneInfo(tz_identifier) now = datetime.datetime.now(tz) return f"The current time for query {query} is {now.strftime('%Y-%m-%d %H:%M:%S %Z%z')}"
root_agent = Agent( name="root_agent", model="gemini-2.5-flash", instruction="You are a helpful AI assistant designed to provide accurate and useful information.", tools=[get_weather, get_current_time],)
复制代码

数据摄取管道

from kfp import dsl
@dsl.pipeline(description="Data ingestion pipeline into datastore")def pipeline( project_id: str, location: str, is_incremental: bool = True, look_back_days: int = 1, chunk_size: int = 1500, chunk_overlap: int = 20, destination_table: str = "incremental_questions_embeddings", deduped_table: str = "questions_embeddings", destination_dataset: str = "stackoverflow_data", data_store_region: str = "", data_store_id: str = "",) -> None: """Processes data and ingests it into a datastore for RAG Retrieval""" processed_data = process_data( project_id=project_id, schedule_time=dsl.PIPELINE_JOB_SCHEDULE_TIME_UTC_PLACEHOLDER, is_incremental=is_incremental, look_back_days=look_back_days, chunk_size=chunk_size, chunk_overlap=chunk_overlap, destination_dataset=destination_dataset, destination_table=destination_table, deduped_table=deduped_table, location=location, embedding_column="embedding", ).set_retry(num_retries=2) ingest_data( project_id=project_id, data_store_region=data_store_region, input_files=processed_data.output, data_store_id=data_store_id, embedding_column="embedding", ).set_retry(num_retries=2)
复制代码


更多精彩内容 请关注我的个人公众号 公众号(办公 AI 智能小助手)公众号二维码


办公AI智能小助手


用户头像

qife

关注

还未添加个人签名 2021-05-19 加入

还未添加个人简介

评论

发布
暂无评论
Google Cloud Agent Starter Pack_generative-ai_qife_InfoQ写作社区