Skip to content

Commit 3d70b80

Browse files
committed
feat(models): add OCI Generative AI provider for Google Gemini on OCI
Adds first-class support for Google Gemini models hosted on Oracle Cloud Infrastructure (OCI) Generative AI service — a native Google × OCI model partnership that makes Gemini available directly through OCI's inference endpoints. Key design points: - Subclasses BaseLlm following the anthropic_llm.py pattern - Uses the OCI Python SDK directly (no LangChain dependency) - Optional dependency: pip install google-adk[oci] - Supports API_KEY, INSTANCE_PRINCIPAL, and RESOURCE_PRINCIPAL auth - Both non-streaming (_call_oci) and streaming (_call_oci_stream) paths share setup code via _build_chat_details(); streaming collects OCI's OpenAI-compatible SSE events in a thread pool (asyncio.to_thread) and yields partial then final LlmResponse - Registers google.gemini-* (and other OCI-hosted) model patterns in LLMRegistry via optional try/except in models/__init__.py - 37 unit tests (fully mocked, no OCI account needed) - 10 integration tests (skipped when OCI_COMPARTMENT_ID is unset) Supported models: google.gemini-*, google.gemma-*, meta.llama-*, mistralai.*, xai.grok-*, nvidia.*
1 parent abcf14c commit 3d70b80

File tree

5 files changed

+1597
-0
lines changed

5 files changed

+1597
-0
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ toolbox = ["toolbox-adk>=1.0.0, <2.0.0"]
176176

177177
slack = ["slack-bolt>=1.22.0"]
178178

179+
oci = ["oci>=2.126.0"] # For OCI Generative AI model support
180+
179181
[tool.pyink]
180182
# Format py files following Google style-guide
181183
line-length = 80

src/google/adk/models/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@
6363
except Exception:
6464
# Gemma3Ollama requires LiteLLM: pip install google-adk[extensions]
6565
pass
66+
67+
# Optionally register OCIGenAILlm if oci package is installed
68+
try:
69+
from .oci_genai_llm import OCIGenAILlm
70+
71+
LLMRegistry.register(OCIGenAILlm)
72+
__all__.append('OCIGenAILlm')
73+
except Exception:
74+
# OCI support requires: pip install google-adk[oci]
75+
pass

0 commit comments

Comments
 (0)