Retrieves relevant contexts for a query.
HTTP request
POST https://{service-endpoint}/v1beta1/{parent}:retrieveContexts
Where {service-endpoint}
is one of the supported service endpoints.
Path parameters
Parameters | |
---|---|
parent |
Required. The resource name of the Location from which to retrieve RagContexts. The users must have permission to make a call in the project. Format: |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "query": { object ( |
Fields | |
---|---|
query |
Required. Single RAG retrieve query. |
Union field data_source . Data Source to retrieve contexts. data_source can be only one of the following: |
|
vertexRagStore |
The data source for Vertex RagStore. |
Response body
Response message for VertexRagService.RetrieveContexts
.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"contexts": {
object ( |
Fields | |
---|---|
contexts |
The contexts of the query. |
Authorization scopes
Requires the following OAuth scope:
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
IAM Permissions
Requires the following IAM permission on the parent
resource:
aiplatform.locations.get
For more information, see the IAM documentation.
VertexRagStore
The data source for Vertex RagStore.
JSON representation |
---|
{
"ragCorpora": [
string
],
"ragResources": [
{
object ( |
Fields | |
---|---|
ragCorpora[] |
Optional. Deprecated. Please use ragResources to specify the data source. |
ragResources[] |
Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support. |
vectorDistanceThreshold |
Optional. Only return contexts with vector distance smaller than the threshold. |
RagResource
The definition of the Rag resource.
JSON representation |
---|
{ "ragCorpus": string, "ragFileIds": [ string ] } |
Fields | |
---|---|
ragCorpus |
Optional. RagCorpora resource name. Format: |
ragFileIds[] |
Optional. ragFileId. The files should be in the same ragCorpus set in ragCorpus field. |
RagQuery
A query to retrieve relevant contexts.
JSON representation |
---|
{ "similarityTopK": integer, // Union field |
Fields | |
---|---|
similarityTopK |
Optional. The number of contexts to retrieve. |
Union field query . The query to retrieve contexts. Currently only text query is supported. query can be only one of the following: |
|
text |
Optional. The query in text format to get relevant contexts. |
RagContexts
Relevant contexts for one query.
JSON representation |
---|
{
"contexts": [
{
object ( |
Fields | |
---|---|
contexts[] |
All its contexts. |
Context
A context of the query.
JSON representation |
---|
{ "sourceUri": string, "text": string, "distance": number } |
Fields | |
---|---|
sourceUri |
For vertex RagStore, if the file is imported from Cloud Storage or Google Drive, sourceUri will be original file URI in Cloud Storage or Google Drive; if file is uploaded, sourceUri will be file display name. |
text |
The text chunk. |
distance |
The distance between the query vector and the context text vector. |