View source on GitHub |
An API for semantic search over a corpus of user uploaded content.
google.ai.generativelanguage.RetrieverServiceAsyncClient(
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, RetrieverServiceTransport] = 'grpc_asyncio',
client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO
) -> None
Raises | |
---|---|
google.auth.exceptions.MutualTlsChannelError
|
If mutual TLS transport creation failed for any reason. |
Attributes | |
---|---|
transport
|
Returns the transport used by the client instance. |
Methods
batch_create_chunks
batch_create_chunks(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Batch create Chunk
\ s.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_batch_create_chunks():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
requests = generativelanguage_v1beta.CreateChunkRequest()
requests.parent = "parent_value"
requests.chunk.data.string_value = "string_value_value"
request = generativelanguage_v1beta.BatchCreateChunksRequest(
requests=requests,
)
# Make the request
response = await client.batch_create_chunks(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.BatchCreateChunksRequest, dict]]
The request object. Request to batch create |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.BatchCreateChunksResponse
|
Response from BatchCreateChunks containing a list of created Chunks. |
batch_delete_chunks
batch_delete_chunks(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Batch delete Chunk
\ s.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_batch_delete_chunks():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
requests = generativelanguage_v1beta.DeleteChunkRequest()
requests.name = "name_value"
request = generativelanguage_v1beta.BatchDeleteChunksRequest(
requests=requests,
)
# Make the request
await client.batch_delete_chunks(request=request)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.BatchDeleteChunksRequest, dict]]
The request object. Request to batch delete |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
batch_update_chunks
batch_update_chunks(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Batch update Chunk
\ s.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_batch_update_chunks():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
requests = generativelanguage_v1beta.UpdateChunkRequest()
requests.chunk.data.string_value = "string_value_value"
request = generativelanguage_v1beta.BatchUpdateChunksRequest(
requests=requests,
)
# Make the request
response = await client.batch_update_chunks(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.BatchUpdateChunksRequest, dict]]
The request object. Request to batch update |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.BatchUpdateChunksResponse
|
Response from BatchUpdateChunks containing a list of updated Chunks. |
create_chunk
create_chunk(
request=None,
*,
parent=None,
chunk=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Creates a Chunk
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_create_chunk():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
chunk = generativelanguage_v1beta.Chunk()
chunk.data.string_value = "string_value_value"
request = generativelanguage_v1beta.CreateChunkRequest(
parent="parent_value",
chunk=chunk,
)
# Make the request
response = await client.create_chunk(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.CreateChunkRequest, dict]]
parent (:class:
chunk (:class: |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Chunk
|
A Chunk is a subpart of a Document that is treated as an independent unit for the purposes of vector representation and storage. A Corpus can have a maximum of 1 million Chunks. |
create_corpus
create_corpus(
request=None,
*,
corpus=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Creates an empty Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_create_corpus():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.CreateCorpusRequest(
)
# Make the request
response = await client.create_corpus(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.CreateCorpusRequest, dict]]
corpus (:class: |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Corpus
|
A Corpus is a collection of Documents. A project can create up to 5 corpora. |
create_document
create_document(
request=None,
*,
parent=None,
document=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Creates an empty Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_create_document():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.CreateDocumentRequest(
parent="parent_value",
)
# Make the request
response = await client.create_document(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.CreateDocumentRequest, dict]]
parent (:class:
document (:class: |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Document
|
A Document is a collection of Chunks. A Corpus can have a maximum of 10,000 Documents. |
delete_chunk
delete_chunk(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Deletes a Chunk
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_delete_chunk():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.DeleteChunkRequest(
name="name_value",
)
# Make the request
await client.delete_chunk(request=request)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.DeleteChunkRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
delete_corpus
delete_corpus(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Deletes a Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_delete_corpus():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.DeleteCorpusRequest(
name="name_value",
)
# Make the request
await client.delete_corpus(request=request)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.DeleteCorpusRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
delete_document
delete_document(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Deletes a Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_delete_document():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.DeleteDocumentRequest(
name="name_value",
)
# Make the request
await client.delete_document(request=request)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.DeleteDocumentRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
from_service_account_file
@classmethod
from_service_account_file( filename: str, *args, **kwargs )
Creates an instance of this client using the provided credentials file.
Args | |
---|---|
filename
|
str
The path to the service account private key json file. |
args
|
Additional arguments to pass to the constructor. |
kwargs
|
Additional arguments to pass to the constructor. |
Returns | |
---|---|
RetrieverServiceAsyncClient
|
The constructed client. |
from_service_account_info
@classmethod
from_service_account_info( info: dict, *args, **kwargs )
Creates an instance of this client using the provided credentials info.
Args | |
---|---|
info
|
dict
The service account private key info. |
args
|
Additional arguments to pass to the constructor. |
kwargs
|
Additional arguments to pass to the constructor. |
Returns | |
---|---|
RetrieverServiceAsyncClient
|
The constructed client. |
from_service_account_json
@classmethod
from_service_account_json( filename: str, *args, **kwargs )
Creates an instance of this client using the provided credentials file.
Args | |
---|---|
filename
|
str
The path to the service account private key json file. |
args
|
Additional arguments to pass to the constructor. |
kwargs
|
Additional arguments to pass to the constructor. |
Returns | |
---|---|
RetrieverServiceAsyncClient
|
The constructed client. |
get_chunk
get_chunk(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Gets information about a specific Chunk
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_get_chunk():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.GetChunkRequest(
name="name_value",
)
# Make the request
response = await client.get_chunk(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.GetChunkRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Chunk
|
A Chunk is a subpart of a Document that is treated as an independent unit for the purposes of vector representation and storage. A Corpus can have a maximum of 1 million Chunks. |
get_corpus
get_corpus(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Gets information about a specific Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_get_corpus():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.GetCorpusRequest(
name="name_value",
)
# Make the request
response = await client.get_corpus(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.GetCorpusRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Corpus
|
A Corpus is a collection of Documents. A project can create up to 5 corpora. |
get_document
get_document(
request=None,
*,
name=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Gets information about a specific Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_get_document():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.GetDocumentRequest(
name="name_value",
)
# Make the request
response = await client.get_document(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.GetDocumentRequest, dict]]
name (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Document
|
A Document is a collection of Chunks. A Corpus can have a maximum of 10,000 Documents. |
get_mtls_endpoint_and_cert_source
@classmethod
get_mtls_endpoint_and_cert_source( client_options: Optional[ClientOptions] = None )
Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order:
(1) if GOOGLE_API_USE_CLIENT_CERTIFICATE
environment variable is not "true", the
client cert source is None.
(2) if client_options.client_cert_source
is provided, use the provided one; if the
default client cert source exists, use the default one; otherwise the client cert
source is None.
The API endpoint is determined in the following order:
(1) if client_options.api_endpoint
if provided, use the provided one.
(2) if GOOGLE_API_USE_CLIENT_CERTIFICATE
environment variable is "always", use the
default mTLS endpoint; if the environment variable is "never", use the default API
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114
Args | |
---|---|
client_options
|
google.api_core.client_options.ClientOptions
Custom options for the
client. Only the |
Returns | |
---|---|
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the client cert source to use. |
Raises | |
---|---|
google.auth.exceptions.MutualTLSChannelError
|
If any errors happen. |
get_transport_class
get_transport_class()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
list_chunks
list_chunks(
request=None,
*,
parent=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Lists all Chunk
\ s in a Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_list_chunks():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.ListChunksRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_chunks(request=request)
# Handle the response
async for response in page_result:
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.ListChunksRequest, dict]]
parent (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListChunksAsyncPager
|
Response from ListChunks containing a paginated list of Chunks.
The Chunks are sorted by ascending chunk.create_time.
Iterating over this object will yield results and resolve additional pages automatically. |
list_corpora
list_corpora(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Lists all Corpora
owned by the user.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_list_corpora():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.ListCorporaRequest(
)
# Make the request
page_result = client.list_corpora(request=request)
# Handle the response
async for response in page_result:
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.ListCorporaRequest, dict]]
The request object. Request for listing |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListCorporaAsyncPager
|
Response from ListCorpora containing a paginated list of Corpora.
The results are sorted by ascending
corpus.create_time.
Iterating over this object will yield results and resolve additional pages automatically. |
list_documents
list_documents(
request=None,
*,
parent=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Lists all Document
\ s in a Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_list_documents():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.ListDocumentsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_documents(request=request)
# Handle the response
async for response in page_result:
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.ListDocumentsRequest, dict]]
parent (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListDocumentsAsyncPager
|
Response from ListDocuments containing a paginated list of Documents.
The Documents are sorted by ascending
document.create_time.
Iterating over this object will yield results and resolve additional pages automatically. |
query_corpus
query_corpus(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Performs semantic search over a Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_query_corpus():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.QueryCorpusRequest(
name="name_value",
query="query_value",
)
# Make the request
response = await client.query_corpus(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.QueryCorpusRequest, dict]]
The request object. Request for querying a |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.QueryCorpusResponse
|
Response from QueryCorpus containing a list of relevant chunks. |
query_document
query_document(
request=None,
*,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Performs semantic search over a Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_query_document():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.QueryDocumentRequest(
name="name_value",
query="query_value",
)
# Make the request
response = await client.query_document(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.QueryDocumentRequest, dict]]
The request object. Request for querying a |
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.QueryDocumentResponse
|
Response from QueryDocument containing a list of relevant chunks. |
update_chunk
update_chunk(
request=None,
*,
chunk=None,
update_mask=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Updates a Chunk
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_update_chunk():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
chunk = generativelanguage_v1beta.Chunk()
chunk.data.string_value = "string_value_value"
request = generativelanguage_v1beta.UpdateChunkRequest(
chunk=chunk,
)
# Make the request
response = await client.update_chunk(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.UpdateChunkRequest, dict]]
chunk (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Chunk
|
A Chunk is a subpart of a Document that is treated as an independent unit for the purposes of vector representation and storage. A Corpus can have a maximum of 1 million Chunks. |
update_corpus
update_corpus(
request=None,
*,
corpus=None,
update_mask=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Updates a Corpus
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_update_corpus():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.UpdateCorpusRequest(
)
# Make the request
response = await client.update_corpus(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.UpdateCorpusRequest, dict]]
corpus (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Corpus
|
A Corpus is a collection of Documents. A project can create up to 5 corpora. |
update_document
update_document(
request=None,
*,
document=None,
update_mask=None,
retry=<_MethodDefault._DEFAULT_VALUE: <object object>>,
timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>,
metadata=()
)
Updates a Document
.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# <a href="https://googleapis.dev/python/google-api-core/latest/client_options.html">https://googleapis.dev/python/google-api-core/latest/client_options.html</a>
from google.ai import generativelanguage_v1beta
async def sample_update_document():
# Create a client
client = generativelanguage_v1beta.RetrieverServiceAsyncClient()
# Initialize request argument(s)
request = generativelanguage_v1beta.UpdateDocumentRequest(
)
# Make the request
response = await client.update_document(request=request)
# Handle the response
print(response)
Args | |
---|---|
request
|
Optional[Union[google.ai.generativelanguage.UpdateDocumentRequest, dict]]
document (:class:
|
retry
|
google.api_core.retry_async.AsyncRetry
Designation of what errors, if any, should be retried. |
timeout
|
float
The timeout for this request. |
metadata
|
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
google.ai.generativelanguage.Document
|
A Document is a collection of Chunks. A Corpus can have a maximum of 10,000 Documents. |
Class Variables | |
---|---|
DEFAULT_ENDPOINT |
'generativelanguage.googleapis.com'
|
DEFAULT_MTLS_ENDPOINT |
'generativelanguage.mtls.googleapis.com'
|