File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525from vertexai .preview .rag .utils import _gapic_utils
2626from vertexai .preview .rag .utils import resources
2727
28- from google . protobuf import any_pb2
28+
2929
3030
3131def retrieval_query (
@@ -537,14 +537,15 @@ async def async_retrieve_contexts(
537537 raw_op = response_lro .operation
538538 if raw_op .WhichOneof ("result" ) == "response" :
539539 any_response = raw_op .response
540- inner_any = any_pb2 .Any ()
541- if any_response .Unpack (inner_any ):
542- inner_any .type_url = "type.googleapis.com/google.cloud.aiplatform.v1beta1.RagContexts"
543- rag_contexts = aiplatform_v1beta1 .RagContexts ()
544- if inner_any .Unpack (rag_contexts ._pb ):
545- return aiplatform_v1beta1 .AsyncRetrieveContextsResponse (
546- contexts = rag_contexts
547- )
540+ # HACK: Override type_url to match SDK's expected type
541+ any_response .type_url = "type.googleapis.com/google.cloud.aiplatform.v1beta1.RagContexts"
542+ rag_contexts = aiplatform_v1beta1 .RagContexts ()
543+ if any_response .Unpack (rag_contexts ._pb ):
544+ if not rag_contexts .contexts :
545+ raise ValueError ("No rag contexts were returned." )
546+ return aiplatform_v1beta1 .AsyncRetrieveContextsResponse (
547+ contexts = rag_contexts
548+ )
548549 raise e
549550 except Exception as e :
550551 raise RuntimeError (
You can’t perform that action at this time.
0 commit comments