StreamingTextContent Class
This represents streaming text response content.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Inheritance
-
StreamingTextContentStreamingTextContent
Constructor
StreamingTextContent(*, inner_content: Any | None = None, ai_model_id: str | None = None, metadata: dict[str, Any] = None, content_type: Literal[ContentTypes.TEXT_CONTENT] = 'text', text: str, encoding: str | None = None, choice_index: int)
Parameters
Name | Description |
---|---|
choice_index
Required
|
int - The index of the choice that generated this response. |
inner_content
Required
|
Optional[Any] - The inner content of the response, this should hold all the information from the response so even when not creating a subclass a developer can leverage the full thing. |
ai_model_id
Required
|
Optional[str] - The id of the AI model that generated this response. |
metadata
Required
|
Dict[str, Any] - Any metadata that should be attached to the response. |
text
Required
|
Optional[str] - The text of the response. |
encoding
Required
|
Optional[str] - The encoding of the text. |
Keyword-Only Parameters
Name | Description |
---|---|
inner_content
Required
|
|
ai_model_id
Required
|
|
metadata
Required
|
|
content_type
|
Default value: text
|
text
Required
|
|
encoding
Required
|
|
choice_index
Required
|
|
Attributes
model_computed_fields
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_assignment': True}
model_fields
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.fields from Pydantic V1.
model_fields: ClassVar[Dict[str, FieldInfo]] = {'ai_model_id': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'choice_index': FieldInfo(annotation=int, required=True), 'content_type': FieldInfo(annotation=Literal[<ContentTypes.TEXT_CONTENT: 'text'>], required=False, default='text', init=False), 'encoding': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'inner_content': FieldInfo(annotation=Union[Any, NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=dict[str, Any], required=False, default_factory=dict), 'text': FieldInfo(annotation=str, required=True)}
ai_model_id
ai_model_id: str | None
choice_index
choice_index: int
content_type
content_type: Literal[ContentTypes.TEXT_CONTENT]
encoding
encoding: str | None
inner_content
inner_content: Any | None
metadata
metadata: dict[str, Any]
text
text: str