googleapis / googleapis/python-genai
Design of class genai.Content
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 1k
- Merge medio
- 2g 12h
- PR unite (30g)
- 41
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.