3838 )
3939
4040
41+ # Use parameter signature from
42+ # https://github.com/googleapis/python-aiplatform/blob/v1.76.0/vertexai/generative_models/_generative_models.py#L595
43+ # to handle named vs positional args robustly
44+ def _extract_params (
45+ contents : ContentsType ,
46+ * ,
47+ generation_config : Optional [GenerationConfigType ] = None ,
48+ safety_settings : Optional [SafetySettingsType ] = None ,
49+ tools : Optional [list [Tool ]] = None ,
50+ tool_config : Optional [ToolConfig ] = None ,
51+ labels : Optional [dict [str , str ]] = None ,
52+ stream : bool = False ,
53+ ** _kwargs : Any ,
54+ ) -> GenerateContentParams :
55+ return GenerateContentParams (
56+ contents = contents ,
57+ generation_config = generation_config ,
58+ safety_settings = safety_settings ,
59+ tools = tools ,
60+ tool_config = tool_config ,
61+ labels = labels ,
62+ stream = stream ,
63+ )
64+
65+
4166def generate_content_create (
4267 tracer : Tracer , event_logger : EventLogger , capture_content : bool
4368):
@@ -51,32 +76,7 @@ def traced_method(
5176 args : Any ,
5277 kwargs : Any ,
5378 ):
54- # Use parameter signature from
55- # https://github.com/googleapis/python-aiplatform/blob/v1.76.0/vertexai/generative_models/_generative_models.py#L595
56- # to handle named vs positional args robustly
57- def extract_params (
58- contents : ContentsType ,
59- * ,
60- generation_config : Optional [GenerationConfigType ] = None ,
61- safety_settings : Optional [SafetySettingsType ] = None ,
62- tools : Optional [list [Tool ]] = None ,
63- tool_config : Optional [ToolConfig ] = None ,
64- labels : Optional [dict [str , str ]] = None ,
65- stream : bool = False ,
66- ** _kwargs : Any ,
67- ) -> GenerateContentParams :
68- return GenerateContentParams (
69- contents = contents ,
70- generation_config = generation_config ,
71- safety_settings = safety_settings ,
72- tools = tools ,
73- tool_config = tool_config ,
74- labels = labels ,
75- stream = stream ,
76- )
77-
78- params = extract_params (* args , ** kwargs )
79-
79+ params = _extract_params (* args , ** kwargs )
8080 span_attributes = get_genai_request_attributes (instance , params )
8181
8282 span_name = get_span_name (span_attributes )
0 commit comments