@@ -395,11 +395,10 @@ def set_metrics(
395395
396396 Args:
397397 metrics: List of metrics to set. Supports:
398- - Metric.scorers values (e.g., Metric.scorers. correctness) - Recommended
398+ - GalileoScorers enum values (e.g., GalileoScorers. correctness)
399399 - Metric objects (including from Metric.get(id="..."))
400400 - LocalMetricConfig objects for custom scoring functions
401401 - String names of built-in metrics
402- - GalileoScorers enum values (backward compatible)
403402
404403 Returns
405404 -------
@@ -423,7 +422,6 @@ def set_metrics(
423422 Metric.get(id="metric-from-console-uuid"), # From console
424423 ])
425424 """
426- < << << << HEAD
427425 try :
428426 logger .info (f"LogStream.enable_metrics: id='{ self .id } ' metrics={ [str (m ) for m in metrics ]} - started" )
429427 log_streams_service = LogStreams ()
@@ -692,103 +690,6 @@ def context(self) -> Any:
692690 response = openai_client.chat.completions.create(...)
693691 """
694692 return galileo_context (project = self .project .name if self .project else None , log_stream = self .name )
695- == == == =
696- logger .info (f"LogStream.set_metrics: id='{ self .id } ' metrics={ [str (m ) for m in metrics ]} - started" )
697- log_streams_service = LogStreams ()
698- log_stream = log_streams_service .get (name = self .name , project_id = self .project_id )
699- if log_stream is None :
700- raise ValueError (f"Log stream '{ self .name } ' not found" )
701- result = log_stream .enable_metrics (metrics )
702- logger .info (f"LogStream.set_metrics: id='{ self .id } ' - completed" )
703- return result
704-
705- def add_metrics (
706- self , metrics : builtins .list [GalileoScorers | Metric | LocalMetricConfig | str ]
707- ) - > builtins .list [LocalMetricConfig ]:
708- """
709- Add metrics to the existing metrics on this log stream.
710-
711- This adds to the current set of metrics without removing existing ones.
712-
713- Args:
714- metrics: List of metrics to add. Supports:
715- - GalileoScorers enum values (e.g., GalileoScorers.correctness)
716- - Metric objects (including from Metric.get(id="..."))
717- - LocalMetricConfig objects for custom scoring functions
718- - String names of built-in metrics
719-
720- Returns
721- -------
722- List[LocalMetricConfig]: Local metric configurations that must be
723- computed client-side.
724-
725- Raises
726- ------
727- ValueError: If any specified metrics are unknown.
728-
729- Examples
730- --------
731- log_stream = LogStream.get(name="Production Logs", project_name="My Project")
732-
733- # Add more metrics to existing ones
734- log_stream.add_metrics([
735- Metric.scorers.toxicity,
736- "prompt_injection",
737- ])
738- """
739- logger .info (f"LogStream.add_metrics: id='{ self .id } ' adding { len (metrics )} metrics - started" )
740-
741- # Get current metrics
742- current_metric_names : set [str ] = set (self .get_metrics ())
743- logger .debug (f"LogStream.add_metrics: current metrics={ current_metric_names } " )
744-
745- # Build combined list (avoid duplicates by name)
746- combined_metrics = list (metrics ) # Start with new metrics
747-
748- # Add existing metrics that aren't being replaced
749- for metric_name in current_metric_names :
750- # Check if this metric is being replaced
751- is_replaced = any (
752- (isinstance (m , str ) and m == metric_name )
753- or (hasattr (m , "name" ) and m .name == metric_name )
754- or (isinstance (m , GalileoScorers ) and m .value .lstrip ("_" ) == metric_name )
755- for m in metrics
756- )
757- if not is_replaced :
758- combined_metrics .append (metric_name )
759-
760- logger .info (f"LogStream.add_metrics: setting { len (combined_metrics )} total metrics" )
761- return self .set_metrics (combined_metrics )
762-
763- def enable_metrics (
764- self , metrics : builtins .list [GalileoScorers | Metric | LocalMetricConfig | str ]
765- ) - > builtins .list [LocalMetricConfig ]:
766- """
767- Enable metrics on this log stream.
768-
769- Alias for set_metrics() for backward compatibility.
770-
771- Args:
772- metrics: List of metrics to enable.
773-
774- Returns
775- -------
776- List[LocalMetricConfig]: Local metric configurations that must be
777- computed client-side.
778-
779- Examples
780- --------
781- log_stream.enable_metrics([
782- Metric.scorers.correctness,
783- "completeness",
784- ])
785- """
786- return self .set_metrics (metrics )
787-
788- def __str__ (self ) - > str :
789- """String representation of the log stream."""
790- return f"LogStream(name='{ self .name } ', id='{ self .id } ', project_id='{ self .project_id } ')"
791- >> >> >> > 37 c9012 (add / update )
792693
793694 @property
794695 def project (self ) -> Project | None :
0 commit comments