googleapis / googleapis/python-genai

Design of class genai.Content

Open
#1,049 1 comment 0 reactions 1 assignee Claimed by @Venkaiahbabuneelam View on GitHub
priority: p3 type: question
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

While developing Agent's with Google's ADK, I discovered them using `genai.Content` and I saw they use this condition:

`if event.content and event.content.parts:` : The full code is available [here](https://google.github.io/adk-docs/tutorials/agent-team/#step-1-your-first-agent-basic-weather-lookup) (Do Ctrl + F and type in the the if condition).

Now, the class Content is as follows:
```python
class Content(_common.BaseModel):
"""Contains the multi-part content of a message."""

parts: Optional[list[Part]] = Field(
default=None,
description="""List of parts that constitute a single message. Each part may have
a different IANA MIME type.""",
)
role: Optional[str] = Field(
default=None,
description="""Optional. The producer of the content. Must be either 'user' or
'model'. Useful to set for multi-turn conversations, otherwise can be
empty. If role is not specified, SDK will determine the role.""",
)
````

There is not a separate validation, but it is safe to assume that there will not be any response which has a role, but no parts.

Now even if you do encounter a possibility where out of user or model (as role field) , only role is set, then is not it a vague design from the genai repo? I mean there is a role but empty list as output.

When I asked them this [question](https://github.com/google/adk-python/issues/1543#issuecomment-3006939872), they said that I should ask you guys.

Feel free to counter me by all means.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.