feat:contrib/model-prism: pluggable LLM backend SPI for ADK Java via ServiceLoader#1199
feat:contrib/model-prism: pluggable LLM backend SPI for ADK Java via ServiceLoader#1199svetanis wants to merge 1 commit into
ServiceLoader#1199Conversation
ServiceLoader
|
Hi @svetanis, thank you for your contribution! We appreciate you taking the time to submit this pull request. Currently this PR is under review by our team, we will keep you posted if any additional information is required. thank you. |
|
@tilgalas, Could you please review this PR. |
|
Closing this PR — some context on why, and where the work goes next: This PR reflects a snapshot from two months ago, and the ground has shifted under it since. For these reasons, I'm closing this PR today:
Rather than rebase a large diff whose foundations have shifted, I'm closing this in favor of a Thanks @hemasekhar-p and @tilgalas for the triage — the follow-up will be a much easier review. |
Add
model-prism: pluggable LLM backend SPI for ADK Java viaServiceLoaderPlease ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Related discussion:
2. Description of change:
This is a working prototype demonstrating one way to add pluggable LLM backends to ADK-Java via
ServiceLoader.Problem
Python ADK gets zero-code provider switching for free — dynamic imports and LiteLLM resolve a model string from config at runtime. This PR demonstrates the Java-idiomatic equivalent: a
ServiceLoader-based SPI where a model string in config plus a Maven dependency swap is all it takes.What goes where
Into
google-adk.jar— SPI layer (3 files):ModelProvider— SPI interfaceModelProviderRegistry—ServiceLoaderwiringOpenAiCompatibleLlm— reusable base class for anyPOST /v1/chat/completionsproviderInto
google-adk.jar— HTTP and serialization layer (or replaced by Google's existing implementation):OpenAiHttpClient— HTTP client interface (default impl included; could be backed by ADK's existingChatCompletionsHttpClient)OpenAiMessageSerializer— serializer interface (default impl included; could be replaced byAdkChatSerializerusing ADK 1.1.0 internal DTOs for richer response mapping)Into
RunnerandAdkWebServer.start()(2 lines total):Everything else stays external. Provider JARs (Groq, Ollama, OpenRouter) live outside ADK and self-register via
META-INF/services. No ADK PR is needed to add a new provider — dropping a JAR on the classpath in an ADK application is enough.What's included
model-prism-coreModelProviderSPI +OpenAiCompatibleLlmbase classmodel-prism-groqgroq/.*)model-prism-ollamamodel-prism-openroutermodel-prism-demoTests
13 unit tests, all passing. See PR description for full list.
Manual E2E verified with Groq and Ollama.
Proposed core integration (one line)
Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
The
model-prism-demomodule includes 11 runnable demo classes. To verify end-to-end:For Ollama (no API key required): install Ollama, run
ollama pull llama3, then use model nameollama/llama3.Checklist
Additional context
Modules added under
contrib/model-prism/:model-prism-coreModelProviderSPI,ModelProviderRegistry,OpenAiCompatibleLlmbase classmodel-prism-groqgroq/.*)model-prism-ollamaollama/.*, no API key)model-prism-openrouteropenrouter/.*, free tier available)model-prism-demo