@@ -749,6 +749,27 @@ def _to_grounding_source_dict(self) -> Dict[str, Any]:
749
749
}
750
750
751
751
752
+ @dataclasses .dataclass
753
+ class InlineContext (_GroundingSourceBase ):
754
+ """InlineContext represents a grounding source using provided inline context.
755
+ Attributes:
756
+ inline_context: The content used as inline context.
757
+ """
758
+
759
+ inline_context : str
760
+ _type : str = dataclasses .field (default = "INLINE" , init = False , repr = False )
761
+
762
+ def _to_grounding_source_dict (self ) -> Dict [str , Any ]:
763
+ return {
764
+ "sources" : [
765
+ {
766
+ "type" : self ._type ,
767
+ }
768
+ ],
769
+ "inlineContext" : self .inline_context ,
770
+ }
771
+
772
+
752
773
@dataclasses .dataclass
753
774
class VertexAISearch (_GroundingSourceBase ):
754
775
"""VertexAISearchDatastore represents a grounding source using Vertex AI Search datastore
@@ -792,6 +813,7 @@ class GroundingSource:
792
813
793
814
WebSearch = WebSearch
794
815
VertexAISearch = VertexAISearch
816
+ InlineContext = InlineContext
795
817
796
818
797
819
@dataclasses .dataclass
@@ -976,7 +998,11 @@ def predict(
976
998
stop_sequences : Optional [List [str ]] = None ,
977
999
candidate_count : Optional [int ] = None ,
978
1000
grounding_source : Optional [
979
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
1001
+ Union [
1002
+ GroundingSource .WebSearch ,
1003
+ GroundingSource .VertexAISearch ,
1004
+ GroundingSource .InlineContext ,
1005
+ ]
980
1006
] = None ,
981
1007
logprobs : Optional [int ] = None ,
982
1008
presence_penalty : Optional [float ] = None ,
@@ -1053,7 +1079,11 @@ async def predict_async(
1053
1079
stop_sequences : Optional [List [str ]] = None ,
1054
1080
candidate_count : Optional [int ] = None ,
1055
1081
grounding_source : Optional [
1056
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
1082
+ Union [
1083
+ GroundingSource .WebSearch ,
1084
+ GroundingSource .VertexAISearch ,
1085
+ GroundingSource .InlineContext ,
1086
+ ]
1057
1087
] = None ,
1058
1088
logprobs : Optional [int ] = None ,
1059
1089
presence_penalty : Optional [float ] = None ,
@@ -1284,7 +1314,11 @@ def _create_text_generation_prediction_request(
1284
1314
stop_sequences : Optional [List [str ]] = None ,
1285
1315
candidate_count : Optional [int ] = None ,
1286
1316
grounding_source : Optional [
1287
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
1317
+ Union [
1318
+ GroundingSource .WebSearch ,
1319
+ GroundingSource .VertexAISearch ,
1320
+ GroundingSource .InlineContext ,
1321
+ ]
1288
1322
] = None ,
1289
1323
logprobs : Optional [int ] = None ,
1290
1324
presence_penalty : Optional [float ] = None ,
@@ -2136,7 +2170,11 @@ def _prepare_request(
2136
2170
stop_sequences : Optional [List [str ]] = None ,
2137
2171
candidate_count : Optional [int ] = None ,
2138
2172
grounding_source : Optional [
2139
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
2173
+ Union [
2174
+ GroundingSource .WebSearch ,
2175
+ GroundingSource .VertexAISearch ,
2176
+ GroundingSource .InlineContext ,
2177
+ ]
2140
2178
] = None ,
2141
2179
) -> _PredictionRequest :
2142
2180
"""Prepares a request for the language model.
@@ -2289,7 +2327,11 @@ def send_message(
2289
2327
stop_sequences : Optional [List [str ]] = None ,
2290
2328
candidate_count : Optional [int ] = None ,
2291
2329
grounding_source : Optional [
2292
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
2330
+ Union [
2331
+ GroundingSource .WebSearch ,
2332
+ GroundingSource .VertexAISearch ,
2333
+ GroundingSource .InlineContext ,
2334
+ ]
2293
2335
] = None ,
2294
2336
) -> "MultiCandidateTextGenerationResponse" :
2295
2337
"""Sends message to the language model and gets a response.
@@ -2352,7 +2394,11 @@ async def send_message_async(
2352
2394
stop_sequences : Optional [List [str ]] = None ,
2353
2395
candidate_count : Optional [int ] = None ,
2354
2396
grounding_source : Optional [
2355
- Union [GroundingSource .WebSearch , GroundingSource .VertexAISearch ]
2397
+ Union [
2398
+ GroundingSource .WebSearch ,
2399
+ GroundingSource .VertexAISearch ,
2400
+ GroundingSource .InlineContext ,
2401
+ ]
2356
2402
] = None ,
2357
2403
) -> "MultiCandidateTextGenerationResponse" :
2358
2404
"""Asynchronously sends message to the language model and gets a response.
0 commit comments