File tree 1 file changed +11
-2
lines changed
google/generativeai/types
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -671,15 +671,24 @@ def _encode_fd(fd: FunctionDeclaration | protos.FunctionDeclaration) -> protos.F
671
671
return fd .to_proto ()
672
672
673
673
674
- GoogleSearchRetrievalType = Union [protos .GoogleSearchRetrieval , dict [str , float ]]
674
+ class DynamicRetrievalConfigDict (TypedDict ):
675
+ mode : protos .DynamicRetrievalConfig .mode
676
+ dynamic_threshold : float
677
+
678
+ DynamicRetrievalConfig = Union [protos .DynamicRetrievalConfig , DynamicRetrievalConfigDict ]
679
+
680
+ class GoogleSearchRetrievalDict (TypedDict ):
681
+ dynamic_retrieval_config : DynamicRetrievalConfig
682
+
683
+ GoogleSearchRetrievalType = Union [protos .GoogleSearchRetrieval , GoogleSearchRetrievalDict ]
675
684
676
685
677
686
def _make_google_search_retrieval (gsr : GoogleSearchRetrievalType ):
678
687
if isinstance (gsr , protos .GoogleSearchRetrieval ):
679
688
return gsr
680
689
elif isinstance (gsr , Mapping ):
681
690
drc = gsr .get ("dynamic_retrieval_config" , None )
682
- if drc is not None :
691
+ if drc is not None and isinstance ( drc , Mapping ) :
683
692
mode = drc .get ("mode" , None )
684
693
if mode is not None :
685
694
mode = to_mode (mode )
You can’t perform that action at this time.
0 commit comments