galileo-core 3.87.1__py3-none-any.whl → 3.88.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
galileo_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "3.87.1"
1
+ __version__ = "3.88.0"
@@ -182,7 +182,7 @@ class BaseStep(BaseModel):
182
182
  description="Galileo ID of the trace containing the span (or the same value as id for a trace)",
183
183
  )
184
184
 
185
- model_config = ConfigDict(validate_assignment=True, from_attributes=True)
185
+ model_config = ConfigDict(validate_assignment=True)
186
186
 
187
187
  def __init__(self, **data: Any):
188
188
  for k, v in list(data.items()):
@@ -1,11 +1,44 @@
1
1
  from operator import attrgetter
2
- from typing import Dict, List, Sequence
2
+ from typing import Dict, List, Sequence, cast
3
3
  from uuid import UUID
4
4
 
5
5
  from galileo_core.schemas.logging.session import BaseSession, Session
6
6
  from galileo_core.schemas.logging.span import Span, SpanAdapter
7
7
  from galileo_core.schemas.logging.step import BaseStep, StepType
8
8
  from galileo_core.schemas.logging.trace import Trace
9
+ from galileo_core.schemas.shared.records import RecordType
10
+
11
+
12
+ def records_to_base_steps(records: Sequence[RecordType]) -> List[BaseStep]:
13
+ """
14
+ Convert RecordType objects to BaseStep objects by validating from dicts.
15
+
16
+ This avoids re-validation issues that occur when passing model instances
17
+ directly to create_tree_for_trace/create_tree_for_session. By converting
18
+ to dicts first, Pydantic validates fresh data instead of re-validating
19
+ existing model instances.
20
+
21
+ Args:
22
+ records: Sequence of RecordType objects (TraceRecord, SpanRecord, SessionRecord, etc.)
23
+
24
+ Returns:
25
+ List of BaseStep objects suitable for passing to create_tree_for_trace/create_tree_for_session
26
+ """
27
+ result: List[BaseStep] = []
28
+ for record in records:
29
+ record_dict = record.model_dump()
30
+ record_type = record_dict.get("type")
31
+
32
+ if record_type == StepType.trace:
33
+ # Validate as Trace directly so create_tree_for_trace can use it
34
+ result.append(Trace.model_validate(record_dict))
35
+ elif record_type == StepType.session:
36
+ # Validate as BaseSession - create_tree_for_session will convert to Session
37
+ result.append(BaseSession.model_validate(record_dict))
38
+ else:
39
+ # For spans, validate through SpanAdapter to get correct span type
40
+ result.append(SpanAdapter.validate_python(record_dict))
41
+ return result
9
42
 
10
43
 
11
44
  def create_tree_for_trace(records: Sequence[BaseStep]) -> Sequence[Trace]:
@@ -15,13 +48,10 @@ def create_tree_for_trace(records: Sequence[BaseStep]) -> Sequence[Trace]:
15
48
  for record in records:
16
49
  if record.id is None:
17
50
  raise ValueError("Node ID cannot be None")
18
- # Handle both enum and string values for type
19
- record_type = record.type if isinstance(record.type, StepType) else StepType(record.type)
20
- if record_type == StepType.trace:
21
- trace_id_to_trace[record.id] = Trace.model_validate(record, from_attributes=True)
22
- elif record_type != StepType.session:
23
- # Use SpanAdapter with discriminator to pick the correct span class
24
- span_id_to_span[record.id] = SpanAdapter.validate_python(record, from_attributes=True)
51
+ if record.type is StepType.trace:
52
+ trace_id_to_trace[record.id] = Trace.model_validate(record)
53
+ elif record.type is not StepType.session:
54
+ span_id_to_span[record.id] = cast(Span, record)
25
55
  if (
26
56
  hasattr(record, "parent_id") and record.parent_id is not None
27
57
  ): # Only add value to the parent-child relationship if there is a parent
@@ -54,10 +84,8 @@ def create_tree_for_session(records: Sequence[BaseStep]) -> List[Session]:
54
84
  for record in records:
55
85
  if record.id is None:
56
86
  raise ValueError("Node ID cannot be None")
57
- # Handle both enum and string values for type
58
- record_type = record.type if isinstance(record.type, StepType) else StepType(record.type)
59
- if record_type == StepType.session:
60
- session = BaseSession.model_validate(record, from_attributes=True)
87
+ if record.type is StepType.session:
88
+ session = BaseSession.model_validate(record)
61
89
  session_id_to_session[record.id] = Session(**session.model_dump(), traces=[])
62
90
  else:
63
91
  if (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: galileo-core
3
- Version: 3.87.1
3
+ Version: 3.88.0
4
4
  Summary: Shared schemas and configuration for Galileo's Python packages.
5
5
  License: Apache-2.0
6
6
  Keywords: llm,quality,language_models,galileo
@@ -1,4 +1,4 @@
1
- galileo_core/__init__.py,sha256=JFk7X0ZpQQNC5vJgOTAgZQ7hqeaSnhrPcjt1w7A0GVg,23
1
+ galileo_core/__init__.py,sha256=F8ra0owkga0tPRG5jB7lK5XkSV5lY8Fd_Z-wmAIHr4E,23
2
2
  galileo_core/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  galileo_core/constants/config.py,sha256=MYvixj3X3CoiC38QVMdidApURKFOAaPaYoHhFESOJlU,329
4
4
  galileo_core/constants/dataset_format.py,sha256=H6ZigDd2QMpRcRhLC38e0hRoMh0kKbvdhbmS5yK1gZU,116
@@ -74,9 +74,9 @@ galileo_core/schemas/logging/agent.py,sha256=zexqP7o_wjicj4H1ZhrF9wkaYBxcj-skLv_
74
74
  galileo_core/schemas/logging/llm.py,sha256=BN2oya2sqAWdOxthN2bCWCfDXEsjKBTCXjBYWh4Q758,7521
75
75
  galileo_core/schemas/logging/session.py,sha256=R7J5B33ffdQrNpzj7HEBLjQ3rKqNRuHOYttO_-PK378,751
76
76
  galileo_core/schemas/logging/span.py,sha256=smaGm3kvghRi3seaFdMKcgdvRF0ZLerptBIZAh-I6i4,12722
77
- galileo_core/schemas/logging/step.py,sha256=Ar0S61lxGAABvZGHt6AeXlPErydvEMy0pXACXWW5uNA,8724
77
+ galileo_core/schemas/logging/step.py,sha256=rRwRSeFbUFbnWg6mOfclo3s6VTtPayLE2-7qBMwqKFQ,8702
78
78
  galileo_core/schemas/logging/trace.py,sha256=irLlf6XyPL0k326A3u_dfN7sb6TzEdfR8veCXWB3c3o,925
79
- galileo_core/schemas/logging/tree.py,sha256=zOiblz_WZIYV0AK_92HZchAyCjabtSr9zs9iEekOUOQ,3658
79
+ galileo_core/schemas/logging/tree.py,sha256=QZT2b77ASckcH3DOAF7_hMEDpoh4Rq1A0XvpQcF58qE,4622
80
80
  galileo_core/schemas/logging/union.py,sha256=iSQYPqlJkVBxkmxXaGNe6XPIL6nzP-6Ckb5fiO7zrCQ,396
81
81
  galileo_core/schemas/protect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  galileo_core/schemas/protect/action.py,sha256=PmCdiMOdC72m3C--avb4o_IY7DI8Coj61EV80krv7zA,1720
@@ -123,8 +123,8 @@ galileo_core/utils/dataset.py,sha256=wjm3NdNRuxj5mK7GqQUdA-Map_EB0SpFfM1QKapd6-A
123
123
  galileo_core/utils/json.py,sha256=ug5P-iozgmqXRhLZS3Dm_JPViTICboKukg1mqqBq2i4,327
124
124
  galileo_core/utils/name.py,sha256=kaDeZJ1K3-SSazYrUeSbUsQrnZlnOBYU42t-QvX-coE,204
125
125
  galileo_core/utils/scorer_validation.py,sha256=bjNmDZhNsmmb8qHBfndXVAL60W5nCvoDdKrAoAegxJg,11259
126
- galileo_core-3.87.1.dist-info/LICENSE,sha256=4D_6tarPnIYkAqF-0LzrodE9wFtSulO3V4RZf__MriE,10946
127
- galileo_core-3.87.1.dist-info/METADATA,sha256=C2cs_-9OqLEgie5Cks7m_rHuOTYDRe0TI_3vebMxvCU,2731
128
- galileo_core-3.87.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
129
- galileo_core-3.87.1.dist-info/entry_points.txt,sha256=epOvdlN6_7ua8stNHURhJhXDIIrheccwYv0Z-QFmHJU,61
130
- galileo_core-3.87.1.dist-info/RECORD,,
126
+ galileo_core-3.88.0.dist-info/LICENSE,sha256=4D_6tarPnIYkAqF-0LzrodE9wFtSulO3V4RZf__MriE,10946
127
+ galileo_core-3.88.0.dist-info/METADATA,sha256=ferBML3uAZ_CaVUheREXRi5FvmqXWgzYi4hh_ULbdpQ,2731
128
+ galileo_core-3.88.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
129
+ galileo_core-3.88.0.dist-info/entry_points.txt,sha256=epOvdlN6_7ua8stNHURhJhXDIIrheccwYv0Z-QFmHJU,61
130
+ galileo_core-3.88.0.dist-info/RECORD,,