feat(kagent-adk): remove litellm as dependency from kagent-adk#1540
feat(kagent-adk): remove litellm as dependency from kagent-adk#1540EItanya merged 9 commits intokagent-dev:mainfrom
Conversation
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
There was a problem hiding this comment.
Minor — stale LiteLLM references in docstrings
A few docstrings in _memory_service.py still reference LiteLLM after this change:
- Line 27 (class docstring):
"Generates embeddings using LiteLLM" - Lines 60, 71 (
add_session_to_memory/_add_session_to_memory_backgrounddocstrings):"Optional ADK model object (e.g., LiteLlm, OpenAI)" - Line 447 (
_summarize_session_content_asyncdocstring): same
These are cosmetic but worth updating for accuracy.
Comment left by Claude on behalf of @iplay88keys
python/packages/kagent-adk/tests/unittests/models/test_ollama.py
Outdated
Show resolved
Hide resolved
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
There was a problem hiding this comment.
Pull request overview
This PR removes the litellm dependency from kagent-adk by replacing LiteLLM-based model/embedding usage with provider-specific SDK implementations (Anthropic, Ollama, Bedrock, and OpenAI SDK calls), and adds unit tests to validate the new dispatch behavior.
Changes:
- Drop
litellmfromkagent-adkdependencies and lockfile. - Replace LiteLLM model creation with native provider model classes (Anthropic/Ollama/Bedrock) and update model dispatch in
types.py. - Rework embedding generation to call provider SDKs directly, and add new unit tests for embeddings and the new model adapters.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Removes litellm (and its transitive deps like fastuuid) from the workspace lock. |
| python/packages/kagent-adk/pyproject.toml | Removes litellm dependency; retains/uses provider SDK deps (openai/anthropic/boto3/ollama/numpy). |
| python/packages/kagent-adk/src/kagent/adk/_memory_service.py | Replaces LiteLLM embedding calls with provider-specific SDK embedding dispatch. |
| python/packages/kagent-adk/src/kagent/adk/types.py | Updates _create_llm_from_model_config to instantiate native Anthropic/Ollama/Bedrock implementations. |
| python/packages/kagent-adk/src/kagent/adk/models/_anthropic.py | Adds KAgentAnthropicLlm with base_url/headers and API key passthrough support. |
| python/packages/kagent-adk/src/kagent/adk/models/_bedrock.py | Adds KAgentBedrockLlm using Bedrock Converse / ConverseStream APIs via boto3. |
| python/packages/kagent-adk/src/kagent/adk/models/_ollama.py | Adds KAgentOllamaLlm using the native Ollama SDK and tool/function-call conversions. |
| python/packages/kagent-adk/src/kagent/adk/models/init.py | Exports new model classes instead of the removed LiteLLM wrapper. |
| python/packages/kagent-adk/src/kagent/adk/models/_litellm.py | Deletes the LiteLLM wrapper model class. |
| python/packages/kagent-adk/tests/unittests/test_embedding.py | Adds unit tests for embedding dispatch/truncation/normalization without LiteLLM. |
| python/packages/kagent-adk/tests/unittests/models/test_anthropic.py | Adds unit tests for the Anthropic adapter behavior. |
| python/packages/kagent-adk/tests/unittests/models/test_bedrock.py | Adds unit tests for Bedrock adapter + client region selection. |
| python/packages/kagent-adk/tests/unittests/models/test_ollama.py | Adds unit tests for Ollama adapter + option/header forwarding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
|
I threw a claude team at this just to double check, lmk what you think. I'm happy to merge without everything fixed to get rid of Review:
|
|
Quick comments based on my context:
We already set the AWS_REGION env var during translation, so it should work fine
Some models do not allow configuring embedding dimensions (returns a fixed size vector that is more than 768), that's the purpose of truncation and re-normalization. According to prior research this works fine in most cases, as long as the call to the model returns a vector longer than 768.
Probably out of scope, we might want to rework the embedding interface in the future for wider support |
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Removes
litellmas a dependency from kagent.litellmis now replaced with provider specific sdks.Testing
ollama
kubectl -n kagent exec -it deploy/ollama -- ollama pull llama3.2:1bkubectl port-forward -n kagent svc/kagent-ui 3000:8080embedding - google
kubectl port-forward -n kagent svc/kagent-ui 3000:8080bedrock