lmnr 0.3.2__tar.gz → 0.3.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lmnr"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  description = "Python SDK for Laminar AI"
5
5
  authors = [
6
6
  { name = "lmnr.ai", email = "founders@lmnr.ai" }
@@ -11,7 +11,7 @@ license = "Apache-2.0"
11
11
 
12
12
  [tool.poetry]
13
13
  name = "lmnr"
14
- version = "0.3.2"
14
+ version = "0.3.4"
15
15
  description = "Python SDK for Laminar AI"
16
16
  authors = ["lmnr.ai"]
17
17
  readme = "README.md"
@@ -269,9 +269,9 @@ class LaminarContextManager:
269
269
  ) -> Span:
270
270
  """Internal method to update a span object. Use `SpanContext.update()` instead."""
271
271
  span.update(
272
- input=input,
272
+ input=input or span.input,
273
+ output=output or span.output,
273
274
  end_time=end_time,
274
- output=output,
275
275
  metadata=metadata,
276
276
  attributes=attributes,
277
277
  evaluate_events=evaluate_events,
@@ -284,7 +284,7 @@ class LaminarContextManager:
284
284
  def event(
285
285
  self,
286
286
  name: str,
287
- value: Optional[Union[str, int]] = None,
287
+ value: Optional[Union[str, int, float, bool]] = None,
288
288
  timestamp: Optional[datetime.datetime] = None,
289
289
  ):
290
290
  span = _lmnr_stack_context.get()[-1] if _lmnr_stack_context.get() else None
@@ -142,14 +142,14 @@ class LaminarDecorator:
142
142
  def event(
143
143
  self,
144
144
  name: str,
145
- value: Optional[Union[str, int]] = None,
145
+ value: Optional[Union[str, int, float, bool]] = None,
146
146
  timestamp: Optional[datetime.datetime] = None,
147
147
  ):
148
148
  """Associate an event with the current span
149
149
 
150
150
  Args:
151
151
  name (str): name of the event. Must be predefined in the Laminar events page.
152
- value (Optional[Union[str, int]], optional): value of the event. Must match range definition in Laminar events page. Defaults to None.
152
+ value (Optional[Union[str, int, float, bool]], optional): value of the event. Must match range definition in Laminar events page. Defaults to None.
153
153
  timestamp (Optional[datetime.datetime], optional): If you need custom timestamp. If not specified, current time is used. Defaults to None.
154
154
  """
155
155
  laminar = LaminarSingleton().get()
@@ -168,7 +168,7 @@ class LaminarDecorator:
168
168
  laminar = LaminarSingleton().get()
169
169
  laminar.evaluate_event(name, data)
170
170
 
171
- def run_pipeline(
171
+ def run(
172
172
  self,
173
173
  pipeline: str,
174
174
  inputs: dict[str, NodeInput],
@@ -156,14 +156,14 @@ class SpanContext(ObservationContext):
156
156
  def event(
157
157
  self,
158
158
  name: str,
159
- value: Optional[Union[str, int]] = None,
159
+ value: Optional[Union[str, int, float, bool]] = None,
160
160
  timestamp: Optional[datetime.datetime] = None,
161
161
  ) -> "SpanContext":
162
162
  """Associate an event with the current span
163
163
 
164
164
  Args:
165
165
  name (str): name of the event. Must be predefined in the Laminar events page.
166
- value (Optional[Union[str, int]], optional): value of the event. Must match range definition in Laminar events page. Defaults to None.
166
+ value (Optional[Union[str, int, float, bool]], optional): value of the event. Must match range definition in Laminar events page. Defaults to None.
167
167
  timestamp (Optional[datetime.datetime], optional): If you need custom timestamp. If not specified, current time is used. Defaults to None.
168
168
 
169
169
  Returns:
@@ -160,14 +160,14 @@ class Event(pydantic.BaseModel):
160
160
  templateName: str
161
161
  timestamp: datetime.datetime
162
162
  spanId: uuid.UUID
163
- value: Optional[Union[int, str]] = None
163
+ value: Optional[Union[int, str, float, bool]] = None
164
164
 
165
165
  def __init__(
166
166
  self,
167
167
  name: str,
168
168
  span_id: uuid.UUID,
169
169
  timestamp: Optional[datetime.datetime] = None,
170
- value: Optional[Union[int, str]] = None,
170
+ value: Optional[Union[int, str, float, bool]] = None,
171
171
  ):
172
172
  super().__init__(
173
173
  id=uuid.uuid4(),
@@ -3,6 +3,8 @@ import pydantic
3
3
  import uuid
4
4
  from typing import Optional, Union
5
5
 
6
+ from .utils import to_dict
7
+
6
8
 
7
9
  class ChatMessage(pydantic.BaseModel):
8
10
  role: str
@@ -30,7 +32,7 @@ class PipelineRunRequest(pydantic.BaseModel):
30
32
  def to_dict(self):
31
33
  return {
32
34
  "inputs": {
33
- k: v.model_dump() if isinstance(v, pydantic.BaseModel) else v
35
+ k: v.model_dump() if isinstance(v, pydantic.BaseModel) else to_dict(v)
34
36
  for k, v in self.inputs.items()
35
37
  },
36
38
  "pipeline": self.pipeline,
@@ -76,10 +76,7 @@ def to_dict(obj: typing.Any) -> dict[str, typing.Any]:
76
76
 
77
77
  return str(o)
78
78
 
79
- for key in obj.keys():
80
- obj[key] = to_dict_inner(obj[key])
81
-
82
- return obj
79
+ return to_dict_inner(obj)
83
80
 
84
81
 
85
82
  def get_input_from_func_args(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes