google.generativeai.caching.CachedContent
Cached content resource.
google.generativeai.caching.CachedContent(
name
)
Args |
`name`
|
The resource name referring to the cached content.
|
Attributes |
`create_time`
|
|
`display_name`
|
|
`expire_time`
|
|
`model`
|
|
`name`
|
|
`update_time`
|
|
`usage_metadata`
|
|
Methods
create
View source
@classmethod
create(
model: str,
*,
display_name: (str | None) = None,
system_instruction: Optional[content_types.ContentType] = None,
contents: Optional[content_types.ContentsType] = None,
tools: Optional[content_types.FunctionLibraryType] = None,
tool_config: Optional[content_types.ToolConfigType] = None,
ttl: Optional[caching_types.TTLTypes] = None,
expire_time: Optional[caching_types.ExpireTimeTypes] = None
) -> CachedContent
Creates CachedContent
resource.
Args |
`model`
|
The name of the `model` to use for cached content creation.
Any `CachedContent` resource can be only used with the
`model` it was created for.
|
`display_name`
|
The user-generated meaningful display name
of the cached content. `display_name` must be no
more than 128 unicode characters.
|
`system_instruction`
|
Developer set system instruction.
|
`contents`
|
Contents to cache.
|
`tools`
|
A list of `Tools` the model may use to generate response.
|
`tool_config`
|
Config to apply to all tools.
|
`ttl`
|
TTL for cached resource (in seconds). Defaults to 1 hour.
`ttl` and `expire_time` are exclusive arguments.
|
`expire_time`
|
Expiration time for cached resource.
`ttl` and `expire_time` are exclusive arguments.
|
Returns |
`CachedContent` resource with specified name.
|
delete
View source
delete() -> None
Deletes CachedContent
resource.
get
View source
@classmethod
get(
name: str
) -> CachedContent
Fetches required CachedContent
resource.
Args |
`name`
|
The resource name referring to the cached content.
|
Returns |
`CachedContent` resource with specified `name`.
|
list
View source
@classmethod
list(
page_size: Optional[int] = 1
) -> Iterable[CachedContent]
Lists CachedContent
objects associated with the project.
Args |
`page_size`
|
The maximum number of permissions to return (per page).
The service may return fewer `CachedContent` objects.
|
Returns |
A paginated list of `CachedContent` objects.
|
update
View source
update(
*,
ttl: Optional[caching_types.TTLTypes] = None,
expire_time: Optional[caching_types.ExpireTimeTypes] = None
) -> None
Updates requested CachedContent
resource.
Args |
`ttl`
|
TTL for cached resource (in seconds). Defaults to 1 hour.
`ttl` and `expire_time` are exclusive arguments.
|
`expire_time`
|
Expiration time for cached resource.
`ttl` and `expire_time` are exclusive arguments.
|