mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Refine Ollama content flattening and provider checks
- Stripping whitespace from custom LLM provider and model names when checking for "ollama_chat". - Enhancing `_flatten_ollama_content` to correctly handle content that is None, a string, a dictionary, or an iterable (like a tuple) of content blocks, not just lists. This aligns with LiteLLM's `OpenAIMessageContent` type being an `Iterable`. Close #3928 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 845848017
This commit is contained in:
committed by
Copybara-Service
parent
1add41e160
commit
c6f389d4bc
@@ -1549,6 +1549,17 @@ async def test_generate_content_async_custom_provider_flattens_content(
|
||||
assert "Describe this image." in message_content
|
||||
|
||||
|
||||
def test_flatten_ollama_content_accepts_tuple_blocks():
|
||||
from google.adk.models.lite_llm import _flatten_ollama_content
|
||||
|
||||
content = (
|
||||
{"type": "text", "text": "first"},
|
||||
{"type": "text", "text": "second"},
|
||||
)
|
||||
flattened = _flatten_ollama_content(content)
|
||||
assert flattened == "first\nsecond"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_content_to_message_param_user_message():
|
||||
content = types.Content(
|
||||
|
||||
Reference in New Issue
Block a user