Skip to content

Commit 09c7fae

Browse files
feat: [google-ai-generativelanguage] Add content caching (#12790)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Add content caching feat: Add cached_content_token_count to generative_service's UsageMetadata feat: Add cached_content_token_count to CountTokensResponse docs: Small fixes END_COMMIT_OVERRIDE PiperOrigin-RevId: 642001790 Source-Link: googleapis/googleapis@804ed3e Source-Link: googleapis/googleapis-gen@cefe39f Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFpLWdlbmVyYXRpdmVsYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiY2VmZTM5ZjVlOWE0NWFkODI2MzlhMDhlMDIzMTQ4ODQwNmUxYjZiOSJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 8f9f5bf commit 09c7fae

41 files changed

Lines changed: 11629 additions & 57 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CacheService
2+
------------------------------
3+
4+
.. automodule:: google.ai.generativelanguage_v1beta.services.cache_service
5+
:members:
6+
:inherited-members:
7+
8+
.. automodule:: google.ai.generativelanguage_v1beta.services.cache_service.pagers
9+
:members:
10+
:inherited-members:

packages/google-ai-generativelanguage/docs/generativelanguage_v1beta/services_.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Services for Google Ai Generativelanguage v1beta API
33
.. toctree::
44
:maxdepth: 2
55

6+
cache_service
67
discuss_service
78
file_service
89
generative_service

packages/google-ai-generativelanguage/google/ai/generativelanguage/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
__version__ = package_version.__version__
1919

2020

21+
from google.ai.generativelanguage_v1beta.services.cache_service.async_client import (
22+
CacheServiceAsyncClient,
23+
)
24+
from google.ai.generativelanguage_v1beta.services.cache_service.client import (
25+
CacheServiceClient,
26+
)
2127
from google.ai.generativelanguage_v1beta.services.discuss_service.async_client import (
2228
DiscussServiceAsyncClient,
2329
)
@@ -60,6 +66,15 @@
6066
from google.ai.generativelanguage_v1beta.services.text_service.client import (
6167
TextServiceClient,
6268
)
69+
from google.ai.generativelanguage_v1beta.types.cache_service import (
70+
CreateCachedContentRequest,
71+
DeleteCachedContentRequest,
72+
GetCachedContentRequest,
73+
ListCachedContentsRequest,
74+
ListCachedContentsResponse,
75+
UpdateCachedContentRequest,
76+
)
77+
from google.ai.generativelanguage_v1beta.types.cached_content import CachedContent
6378
from google.ai.generativelanguage_v1beta.types.citation import (
6479
CitationMetadata,
6580
CitationSource,
@@ -213,6 +228,8 @@
213228
)
214229

215230
__all__ = (
231+
"CacheServiceClient",
232+
"CacheServiceAsyncClient",
216233
"DiscussServiceClient",
217234
"DiscussServiceAsyncClient",
218235
"FileServiceClient",
@@ -227,6 +244,13 @@
227244
"RetrieverServiceAsyncClient",
228245
"TextServiceClient",
229246
"TextServiceAsyncClient",
247+
"CreateCachedContentRequest",
248+
"DeleteCachedContentRequest",
249+
"GetCachedContentRequest",
250+
"ListCachedContentsRequest",
251+
"ListCachedContentsResponse",
252+
"UpdateCachedContentRequest",
253+
"CachedContent",
230254
"CitationMetadata",
231255
"CitationSource",
232256
"Blob",

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
__version__ = package_version.__version__
1919

2020

21+
from .services.cache_service import CacheServiceAsyncClient, CacheServiceClient
2122
from .services.discuss_service import DiscussServiceAsyncClient, DiscussServiceClient
2223
from .services.file_service import FileServiceAsyncClient, FileServiceClient
2324
from .services.generative_service import (
@@ -34,6 +35,15 @@
3435
RetrieverServiceClient,
3536
)
3637
from .services.text_service import TextServiceAsyncClient, TextServiceClient
38+
from .types.cache_service import (
39+
CreateCachedContentRequest,
40+
DeleteCachedContentRequest,
41+
GetCachedContentRequest,
42+
ListCachedContentsRequest,
43+
ListCachedContentsResponse,
44+
UpdateCachedContentRequest,
45+
)
46+
from .types.cached_content import CachedContent
3747
from .types.citation import CitationMetadata, CitationSource
3848
from .types.content import (
3949
Blob,
@@ -184,6 +194,7 @@
184194
)
185195

186196
__all__ = (
197+
"CacheServiceAsyncClient",
187198
"DiscussServiceAsyncClient",
188199
"FileServiceAsyncClient",
189200
"GenerativeServiceAsyncClient",
@@ -202,6 +213,8 @@
202213
"BatchUpdateChunksRequest",
203214
"BatchUpdateChunksResponse",
204215
"Blob",
216+
"CacheServiceClient",
217+
"CachedContent",
205218
"Candidate",
206219
"Chunk",
207220
"ChunkData",
@@ -218,6 +231,7 @@
218231
"CountTextTokensResponse",
219232
"CountTokensRequest",
220233
"CountTokensResponse",
234+
"CreateCachedContentRequest",
221235
"CreateChunkRequest",
222236
"CreateCorpusRequest",
223237
"CreateDocumentRequest",
@@ -228,6 +242,7 @@
228242
"CreateTunedModelRequest",
229243
"CustomMetadata",
230244
"Dataset",
245+
"DeleteCachedContentRequest",
231246
"DeleteChunkRequest",
232247
"DeleteCorpusRequest",
233248
"DeleteDocumentRequest",
@@ -259,6 +274,7 @@
259274
"GenerateTextResponse",
260275
"GenerationConfig",
261276
"GenerativeServiceClient",
277+
"GetCachedContentRequest",
262278
"GetChunkRequest",
263279
"GetCorpusRequest",
264280
"GetDocumentRequest",
@@ -271,6 +287,8 @@
271287
"GroundingPassages",
272288
"HarmCategory",
273289
"Hyperparameters",
290+
"ListCachedContentsRequest",
291+
"ListCachedContentsResponse",
274292
"ListChunksRequest",
275293
"ListChunksResponse",
276294
"ListCorporaRequest",
@@ -320,6 +338,7 @@
320338
"TuningSnapshot",
321339
"TuningTask",
322340
"Type",
341+
"UpdateCachedContentRequest",
323342
"UpdateChunkRequest",
324343
"UpdateCorpusRequest",
325344
"UpdateDocumentRequest",

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/gapic_metadata.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,100 @@
55
"protoPackage": "google.ai.generativelanguage.v1beta",
66
"schema": "1.0",
77
"services": {
8+
"CacheService": {
9+
"clients": {
10+
"grpc": {
11+
"libraryClient": "CacheServiceClient",
12+
"rpcs": {
13+
"CreateCachedContent": {
14+
"methods": [
15+
"create_cached_content"
16+
]
17+
},
18+
"DeleteCachedContent": {
19+
"methods": [
20+
"delete_cached_content"
21+
]
22+
},
23+
"GetCachedContent": {
24+
"methods": [
25+
"get_cached_content"
26+
]
27+
},
28+
"ListCachedContents": {
29+
"methods": [
30+
"list_cached_contents"
31+
]
32+
},
33+
"UpdateCachedContent": {
34+
"methods": [
35+
"update_cached_content"
36+
]
37+
}
38+
}
39+
},
40+
"grpc-async": {
41+
"libraryClient": "CacheServiceAsyncClient",
42+
"rpcs": {
43+
"CreateCachedContent": {
44+
"methods": [
45+
"create_cached_content"
46+
]
47+
},
48+
"DeleteCachedContent": {
49+
"methods": [
50+
"delete_cached_content"
51+
]
52+
},
53+
"GetCachedContent": {
54+
"methods": [
55+
"get_cached_content"
56+
]
57+
},
58+
"ListCachedContents": {
59+
"methods": [
60+
"list_cached_contents"
61+
]
62+
},
63+
"UpdateCachedContent": {
64+
"methods": [
65+
"update_cached_content"
66+
]
67+
}
68+
}
69+
},
70+
"rest": {
71+
"libraryClient": "CacheServiceClient",
72+
"rpcs": {
73+
"CreateCachedContent": {
74+
"methods": [
75+
"create_cached_content"
76+
]
77+
},
78+
"DeleteCachedContent": {
79+
"methods": [
80+
"delete_cached_content"
81+
]
82+
},
83+
"GetCachedContent": {
84+
"methods": [
85+
"get_cached_content"
86+
]
87+
},
88+
"ListCachedContents": {
89+
"methods": [
90+
"list_cached_contents"
91+
]
92+
},
93+
"UpdateCachedContent": {
94+
"methods": [
95+
"update_cached_content"
96+
]
97+
}
98+
}
99+
}
100+
}
101+
},
8102
"DiscussService": {
9103
"clients": {
10104
"grpc": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2024 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
from .async_client import CacheServiceAsyncClient
17+
from .client import CacheServiceClient
18+
19+
__all__ = (
20+
"CacheServiceClient",
21+
"CacheServiceAsyncClient",
22+
)

0 commit comments

Comments
 (0)