chore(ai): remove ADK references and migrate to PydanticAI
This commit completes the cleanup of Google ADK references after migrating to PydanticAI. Changes: - Removed ADK agent implementation (adk_agent.py) - Removed ADK test files (test_06, test_07, test_10) - Removed ADK diagnostic files - Updated config to use pydantic_system_prompt_variant instead of adk_system_prompt_variant - Updated prompts.py to rename adk_agent to pydantic_agent - Updated tool registry and tools.py docstrings to remove ADK references - Added new comprehensive PydanticAI tests (test_06, test_07, test_10) - Marked legacy ADK functions as deprecated for backwards compatibility The codebase is now clean and stable with PydanticAI as the primary agent framework. Docker container builds successfully with no ADK import errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,139 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Diagnostic tool to test ADK agent directly (without HTTP layer).
|
||||
This tests ADK initialization and basic completion without tools.
|
||||
|
||||
Usage:
|
||||
python diagnostics/test_adk_direct.py
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path to import from src
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from src.config import get_settings
|
||||
from src.agents import ADK_AVAILABLE
|
||||
|
||||
if not ADK_AVAILABLE:
|
||||
print("✗ Google ADK not available")
|
||||
print(" Install with: pip install google-adk")
|
||||
sys.exit(1)
|
||||
|
||||
from src.agents import ADKAgent
|
||||
|
||||
|
||||
async def test_adk_direct():
|
||||
"""Test ADK agent without HTTP layer"""
|
||||
settings = get_settings()
|
||||
|
||||
print("=" * 70)
|
||||
print("ADK DIRECT TEST (No Tools)")
|
||||
print("=" * 70)
|
||||
|
||||
print(f"\n1. Configuration")
|
||||
print(f" Model: {settings.agent_model}")
|
||||
print(f" Ollama URL: {settings.ollama_base_url}")
|
||||
print(f" ADK Prompt Variant: {settings.adk_system_prompt_variant}")
|
||||
|
||||
# Test cases without tools
|
||||
test_cases = [
|
||||
{
|
||||
"name": "Simple question",
|
||||
"messages": [
|
||||
{"role": "user", "content": "What is the capital of France? Answer in one sentence."}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Math problem",
|
||||
"messages": [
|
||||
{"role": "user", "content": "What is 15 + 27? Just give me the number."}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Multi-step reasoning",
|
||||
"messages": [
|
||||
{"role": "user", "content": "If I have 3 apples and buy 2 more, then eat 1, how many do I have left?"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
# Run tests
|
||||
for i, test_case in enumerate(test_cases, 1):
|
||||
print(f"\n{'-' * 70}")
|
||||
print(f"Test {i}/{len(test_cases)}: {test_case['name']}")
|
||||
print(f"{'-' * 70}")
|
||||
|
||||
try:
|
||||
# Initialize ADK agent (no tools)
|
||||
print("\n→ Initializing ADK agent (no tools)...")
|
||||
agent = ADKAgent(tools=[])
|
||||
print("✓ ADK agent initialized")
|
||||
|
||||
# Test non-streaming
|
||||
print(f"\n→ Testing non-streaming completion...")
|
||||
print(f" Question: {test_case['messages'][0]['content']}")
|
||||
|
||||
response = await agent.chat_completion(
|
||||
messages=test_case['messages']
|
||||
)
|
||||
|
||||
print(f"\n✓ Response received:")
|
||||
print(f" {response}")
|
||||
|
||||
# Test streaming
|
||||
print(f"\n→ Testing streaming completion...")
|
||||
chunks = []
|
||||
event_count = 0
|
||||
|
||||
async for chunk in agent.chat(
|
||||
messages=test_case['messages'],
|
||||
stream=True
|
||||
):
|
||||
event_count += 1
|
||||
chunk_type = chunk.get("type")
|
||||
|
||||
if chunk_type == "content" and chunk.get("content"):
|
||||
chunks.append(chunk["content"])
|
||||
elif chunk_type == "tool_call":
|
||||
print(f" 🔧 Tool call: {chunk.get('tool')}")
|
||||
elif chunk_type == "tool_result":
|
||||
print(f" ✅ Tool result")
|
||||
elif chunk_type == "error":
|
||||
print(f" ❌ Error: {chunk.get('content')}")
|
||||
|
||||
full_content = "".join(chunks)
|
||||
print(f"\n✓ Streaming response received:")
|
||||
print(f" Events: {event_count}")
|
||||
print(f" Content: {full_content}")
|
||||
|
||||
print(f"\n✓ Test {i} PASSED")
|
||||
|
||||
except ImportError as e:
|
||||
print(f"\n✗ Test {i} FAILED: ADK import error")
|
||||
print(f" Error: {e}")
|
||||
print(f" Install: pip install google-adk")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n✗ Test {i} FAILED")
|
||||
print(f" Error: {type(e).__name__}: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("✓ ALL ADK TESTS PASSED (No Tools)!")
|
||||
print("=" * 70)
|
||||
print("\nNext steps:")
|
||||
print(" 1. ADK initialization works")
|
||||
print(" 2. ADK can generate responses without tools")
|
||||
print(" 3. Ready to add tool integration (Phase 2)")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = asyncio.run(test_adk_direct())
|
||||
sys.exit(0 if result else 1)
|
||||
@@ -1,199 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Diagnostic tool to test ADK agent with tools.
|
||||
|
||||
This tests:
|
||||
1. Local tool registration
|
||||
2. Tool execution
|
||||
3. ADK agent with tools
|
||||
4. (Optional) REST tool discovery from core-api
|
||||
|
||||
Usage:
|
||||
python diagnostics/test_adk_tools.py
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path to import from src
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from src.config import get_settings
|
||||
from src.tools import get_all_tools, get_agent_tools, discover_and_register_tools
|
||||
from src.agents import ADK_AVAILABLE
|
||||
|
||||
if not ADK_AVAILABLE:
|
||||
print("✗ Google ADK not available")
|
||||
print(" Install with: pip install google-adk")
|
||||
sys.exit(1)
|
||||
|
||||
from src.agents import ADKAgent
|
||||
|
||||
|
||||
async def test_tools_diagnostic():
|
||||
"""Test ADK agent with tools"""
|
||||
settings = get_settings()
|
||||
|
||||
print("=" * 70)
|
||||
print("ADK TOOLS DIAGNOSTIC")
|
||||
print("=" * 70)
|
||||
|
||||
# ========================================================================
|
||||
# Part 1: Local Tools
|
||||
# ========================================================================
|
||||
print("\n" + "=" * 70)
|
||||
print("PART 1: LOCAL TOOLS")
|
||||
print("=" * 70)
|
||||
|
||||
print("\n1. Local Tool Registration")
|
||||
tools = get_all_tools()
|
||||
print(f" Registered tools: {len(tools)}")
|
||||
for tool_name in tools.keys():
|
||||
print(f" - {tool_name}")
|
||||
|
||||
# Test local tools directly
|
||||
print("\n2. Testing Local Tools")
|
||||
|
||||
print("\n → Testing get_current_time...")
|
||||
from src.tools.local import get_current_time
|
||||
time_result = await get_current_time()
|
||||
print(f" Result: {time_result}")
|
||||
|
||||
print("\n → Testing get_current_date...")
|
||||
from src.tools.local import get_current_date
|
||||
date_result = await get_current_date()
|
||||
print(f" Result: {date_result}")
|
||||
|
||||
print("\n → Testing calculate...")
|
||||
from src.tools.local import calculate
|
||||
calc_result = await calculate("15 + 27")
|
||||
print(f" Result: 15 + 27 = {calc_result}")
|
||||
|
||||
print("\n → Testing date operations...")
|
||||
from src.tools.local import add_days_to_date, calculate_date_difference
|
||||
future_date = await add_days_to_date(date_result, 30)
|
||||
print(f" {date_result} + 30 days = {future_date}")
|
||||
|
||||
diff = await calculate_date_difference(date_result, future_date)
|
||||
print(f" Difference: {diff}")
|
||||
|
||||
print("\n✓ All local tools working")
|
||||
|
||||
# ========================================================================
|
||||
# Part 2: ADK Integration
|
||||
# ========================================================================
|
||||
print("\n" + "=" * 70)
|
||||
print("PART 2: ADK INTEGRATION")
|
||||
print("=" * 70)
|
||||
|
||||
print("\n3. Converting Tools to ADK Format")
|
||||
adk_tools = get_agent_tools()
|
||||
print(f" ADK tools created: {len(adk_tools)}")
|
||||
|
||||
# ========================================================================
|
||||
# Part 3: ADK Agent with Tools
|
||||
# ========================================================================
|
||||
print("\n" + "=" * 70)
|
||||
print("PART 3: ADK AGENT WITH TOOLS")
|
||||
print("=" * 70)
|
||||
|
||||
test_cases = [
|
||||
{
|
||||
"name": "Simple calculation with tool",
|
||||
"messages": [
|
||||
{"role": "user", "content": "What is 123 + 456? Use the calculate tool to find the answer."}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Current time query",
|
||||
"messages": [
|
||||
{"role": "user", "content": "What is the current time and date? Use the appropriate tools."}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Date calculation",
|
||||
"messages": [
|
||||
{"role": "user", "content": "What will the date be 45 days from now? Use the date tools."}
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
# Run tests
|
||||
for i, test_case in enumerate(test_cases, 1):
|
||||
print(f"\n{'-' * 70}")
|
||||
print(f"Test {i}/{len(test_cases)}: {test_case['name']}")
|
||||
print(f"{'-' * 70}")
|
||||
|
||||
try:
|
||||
# Initialize ADK agent with tools
|
||||
print("\n→ Initializing ADK agent with tools...")
|
||||
agent = ADKAgent(discover_tools=True)
|
||||
print(f"✓ ADK agent initialized with {len(agent.tools)} tools")
|
||||
|
||||
# Test non-streaming
|
||||
print(f"\n→ Query: {test_case['messages'][0]['content']}")
|
||||
|
||||
response = await agent.chat_completion(
|
||||
messages=test_case['messages']
|
||||
)
|
||||
|
||||
print(f"\n✓ Response:")
|
||||
print(f" {response}")
|
||||
|
||||
print(f"\n✓ Test {i} PASSED")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n✗ Test {i} FAILED")
|
||||
print(f" Error: {type(e).__name__}: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
# ========================================================================
|
||||
# Part 4: REST Tool Discovery (Optional)
|
||||
# ========================================================================
|
||||
print("\n" + "=" * 70)
|
||||
print("PART 4: REST TOOL DISCOVERY (OPTIONAL)")
|
||||
print("=" * 70)
|
||||
|
||||
print(f"\n4. Attempting to discover tools from core-api")
|
||||
print(f" Core-API URL: {settings.core_api_base_url}")
|
||||
|
||||
try:
|
||||
print("\n→ Fetching OpenAPI spec from core-api...")
|
||||
rest_tools_count = await discover_and_register_tools()
|
||||
print(f"✓ Discovered and registered {rest_tools_count} REST tools from core-api")
|
||||
|
||||
# Show all tools now
|
||||
all_tools = get_all_tools()
|
||||
print(f"\n Total tools registered: {len(all_tools)}")
|
||||
for tool_name in all_tools.keys():
|
||||
print(f" - {tool_name}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n⚠️ Could not discover REST tools from core-api")
|
||||
print(f" Reason: {type(e).__name__}: {e}")
|
||||
print(f" This is expected if core-api is not running or doesn't have OpenAPI docs yet")
|
||||
|
||||
# ========================================================================
|
||||
# Summary
|
||||
# ========================================================================
|
||||
print("\n" + "=" * 70)
|
||||
print("✓ ADK TOOLS DIAGNOSTIC COMPLETE!")
|
||||
print("=" * 70)
|
||||
print("\nResults:")
|
||||
print(f" ✓ Local tools: {len([t for t in get_all_tools().keys() if 'calculate' in t or 'date' in t or 'time' in t])}")
|
||||
print(f" ✓ ADK integration: Working")
|
||||
print(f" ✓ Tool calling: Working")
|
||||
print("\nNext steps:")
|
||||
print(" 1. Local tools are working")
|
||||
print(" 2. ADK agent can use tools")
|
||||
print(" 3. Ready to add REST tools from core-api")
|
||||
print(" 4. Ready for Phase 3: Full tool integration")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = asyncio.run(test_tools_diagnostic())
|
||||
sys.exit(0 if result else 1)
|
||||
Reference in New Issue
Block a user