44 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
| #!/usr/bin/env python3
 | |
| # -*- coding: utf-8 -*-
 | |
| """
 | |
| 测试 Google ADK 安装和基本功能
 | |
| """
 | |
| 
 | |
| import os
 | |
| from google.adk import Agent
 | |
| 
 | |
| def test_adk_installation():
 | |
|     """测试 ADK 安装是否成功"""
 | |
|     try:
 | |
|         # 创建一个简单的测试智能体
 | |
|         test_agent = Agent(
 | |
|             name="测试智能体",
 | |
|             model="gemini-2.0-flash-exp"
 | |
|         )
 | |
|         
 | |
|         print("✅ Google ADK 安装成功!")
 | |
|         print(f"智能体名称: {test_agent.name}")
 | |
|         print(f"使用模型: {test_agent.model}")
 | |
|         print(f"描述: {test_agent.description}")
 | |
|         
 | |
|         # 检查环境变量
 | |
|         google_api_key = os.getenv('GOOGLE_API_KEY')
 | |
|         if google_api_key:
 | |
|             print(f"✅ GOOGLE_API_KEY 已配置 (长度: {len(google_api_key)} 字符)")
 | |
|         else:
 | |
|             print("⚠️  GOOGLE_API_KEY 未配置,需要设置 API 密钥")
 | |
|             print("请访问 https://aistudio.google.com/ 获取 API 密钥")
 | |
|         
 | |
|         return True
 | |
|         
 | |
|     except Exception as e:
 | |
|         print(f"❌ ADK 安装测试失败: {e}")
 | |
|         return False
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     print("🚀 开始测试 Google ADK 安装...")
 | |
|     test_adk_installation()
 | |
|     print("\n📝 下一步: 配置 GOOGLE_API_KEY 环境变量")
 | |
|     print("   1. 访问 https://aistudio.google.com/")
 | |
|     print("   2. 获取 API 密钥")
 | |
|     print("   3. 在 Doppler 中设置: doppler secrets set GOOGLE_API_KEY=your_key") |