Skip to content

[Bug]: GoogleGenAI raises error when using stream_complete #20215

@yeosadchuk

Description

@yeosadchuk

Bug Description

When using GoogleGenAI llm through the API, the stream_complete is not working and raises an error.

"pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatMessage
blocks.0
Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value='What is the capital of France? answer short.', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/model_attributes_type"

Version

0.14.7

Steps to Reproduce

from llama_index.llms.google_genai import GoogleGenAI

import config

llm = GoogleGenAI(
model="gemini-2.0-flash",
api_key=config.GEMINI_API_KEY,
context_window=10000,
)

resp = llm.stream_complete(["What is the capital of France? answer short."])

Relevant Logs/Tracbacks

venv/lib/python3.11/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatMessage
blocks.0
  Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value='What is the capital of France? answer short.', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/model_attributes_type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs to be triaged/prioritized

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions