mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Add Gemma3Ollama model integration and a sample
This change introduces `Gemma3Ollama`, a new LLM model class for running Gemma 3 models locally via Ollama, leveraging LiteLLM. The function calling logic previously in the `Gemma` class has been refactored into a `GemmaFunctionCallingMixin` and is now used by both `Gemma` and `Gemma3Ollama`. A new sample application, `hello_world_gemma3_ollama`, is added to demonstrate using `Gemma3Ollama` with an agent. Unit tests for `Gemma3Ollama` are also included. Merge: https://github.com/google/adk-python/pull/3120 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 839996879
This commit is contained in:
committed by
Copybara-Service
co-authored by
George Weale
parent
b0c3cc6e36
commit
e9182e5eb4
@@ -504,3 +504,28 @@ def test_process_response_last_json_object():
|
||||
assert part.function_call.name == "second_call"
|
||||
assert part.function_call.args == {"b": 2}
|
||||
assert part.text is None
|
||||
|
||||
|
||||
# Tests for Gemma3Ollama (only run when LiteLLM is installed)
|
||||
try:
|
||||
from google.adk.models.gemma_llm import Gemma3Ollama
|
||||
|
||||
def test_gemma3_ollama_supported_models():
|
||||
assert Gemma3Ollama.supported_models() == [r"ollama/gemma3.*"]
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_arg,expected_model",
|
||||
[
|
||||
(None, "ollama/gemma3:12b"),
|
||||
("ollama/gemma3:27b", "ollama/gemma3:27b"),
|
||||
],
|
||||
)
|
||||
def test_gemma3_ollama_model(model_arg, expected_model):
|
||||
model = (
|
||||
Gemma3Ollama() if model_arg is None else Gemma3Ollama(model=model_arg)
|
||||
)
|
||||
assert model.model == expected_model
|
||||
|
||||
except ImportError:
|
||||
# LiteLLM not installed, skip Gemma3Ollama tests
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user