mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: ApigeeLLM support for Built-in tools like GoogleSearch, BuiltInCodeExecutor when calling Gemini models through Apigee
PiperOrigin-RevId: 840459113
This commit is contained in:
committed by
Copybara-Service
parent
3d444cc953
commit
a9b853fe36
@@ -34,12 +34,17 @@ def extract_model_name(model_string: str) -> str:
|
||||
The extracted model name (e.g., "gemini-2.5-pro")
|
||||
"""
|
||||
# Pattern for path-based model names
|
||||
path_pattern = (
|
||||
r'^projects/[^/]+/locations/[^/]+/publishers/[^/]+/models/(.+)$'
|
||||
# Need to support both Vertex/Gemini and Apigee model paths.
|
||||
path_patterns = (
|
||||
r'^projects/[^/]+/locations/[^/]+/publishers/[^/]+/models/(.+)$',
|
||||
r'^apigee/(?:[^/]+/)?(?:[^/]+/)?(.+)$',
|
||||
)
|
||||
match = re.match(path_pattern, model_string)
|
||||
if match:
|
||||
return match.group(1)
|
||||
# Check against all path-based patterns
|
||||
for pattern in path_patterns:
|
||||
match = re.match(pattern, model_string)
|
||||
if match:
|
||||
# Return the captured group (the model name)
|
||||
return match.group(1)
|
||||
|
||||
# Handle 'models/' prefixed names like "models/gemini-2.5-pro"
|
||||
if model_string.startswith('models/'):
|
||||
|
||||
@@ -42,6 +42,24 @@ class TestExtractModelName:
|
||||
path_model_3 = 'projects/test-project/locations/europe-west1/publishers/google/models/claude-3-sonnet'
|
||||
assert extract_model_name(path_model_3) == 'claude-3-sonnet'
|
||||
|
||||
path_model_4 = 'apigee/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_4) == 'gemini-2.5-flash'
|
||||
|
||||
path_model_5 = 'apigee/v1/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_5) == 'gemini-2.5-flash'
|
||||
|
||||
path_model_6 = 'apigee/gemini/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_6) == 'gemini-2.5-flash'
|
||||
|
||||
path_model_7 = 'apigee/vertex_ai/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_7) == 'gemini-2.5-flash'
|
||||
|
||||
path_model_8 = 'apigee/gemini/v1/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_8) == 'gemini-2.5-flash'
|
||||
|
||||
path_model_9 = 'apigee/vertex_ai/v1beta/gemini-2.5-flash'
|
||||
assert extract_model_name(path_model_9) == 'gemini-2.5-flash'
|
||||
|
||||
def test_extract_model_name_with_models_prefix(self):
|
||||
"""Test extraction of model names with 'models/' prefix."""
|
||||
assert extract_model_name('models/gemini-2.5-pro') == 'gemini-2.5-pro'
|
||||
|
||||
Reference in New Issue
Block a user