lmnr 0.7.16__py3-none-any.whl → 0.7.17__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.

Potentially problematic release.


This version of lmnr might be problematic. Click here for more details.

@@ -21,6 +21,7 @@ from .schema_utils import SchemaJSONEncoder, process_schema
21
21
  from .utils import (
22
22
  dont_throw,
23
23
  get_content,
24
+ merge_text_parts,
24
25
  process_content_union,
25
26
  process_stream_chunk,
26
27
  role_from_content_union,
@@ -403,7 +404,7 @@ def _build_from_streaming_response(
403
404
  candidates=[
404
405
  {
405
406
  "content": {
406
- "parts": final_parts,
407
+ "parts": merge_text_parts(final_parts),
407
408
  "role": role,
408
409
  },
409
410
  }
@@ -453,7 +454,7 @@ async def _abuild_from_streaming_response(
453
454
  candidates=[
454
455
  {
455
456
  "content": {
456
- "parts": final_parts,
457
+ "parts": merge_text_parts(final_parts),
457
458
  "role": role,
458
459
  },
459
460
  }
@@ -40,6 +40,56 @@ class ProcessChunkResult(TypedDict):
40
40
  model_version: str | None
41
41
 
42
42
 
43
+ def merge_text_parts(
44
+ parts: list[types.PartDict | types.File | types.Part | str],
45
+ ) -> list[types.Part]:
46
+ if not parts:
47
+ return []
48
+
49
+ merged_parts: list[types.Part] = []
50
+ accumulated_text = ""
51
+
52
+ for part in parts:
53
+ # Handle string input - treat as text
54
+ if isinstance(part, str):
55
+ accumulated_text += part
56
+ # Handle File objects - they are not text, so don't merge
57
+ elif isinstance(part, types.File):
58
+ # Flush any accumulated text first
59
+ if accumulated_text:
60
+ merged_parts.append(types.Part(text=accumulated_text))
61
+ accumulated_text = ""
62
+ # Add the File as-is (wrapped in a Part if needed)
63
+ # Note: File objects should be passed through as-is in the original part
64
+ merged_parts.append(part)
65
+ # Handle Part and PartDict (dicts)
66
+ else:
67
+ part_dict = to_dict(part)
68
+
69
+ # Check if this is a text part
70
+ if part_dict.get("text") is not None:
71
+ accumulated_text += part_dict.get("text")
72
+ else:
73
+ # Non-text part (inline_data, function_call, etc.)
74
+ # Flush any accumulated text first
75
+ if accumulated_text:
76
+ merged_parts.append(types.Part(text=accumulated_text))
77
+ accumulated_text = ""
78
+
79
+ # Add the non-text part as-is
80
+ if isinstance(part, types.Part):
81
+ merged_parts.append(part)
82
+ elif isinstance(part, dict):
83
+ # Convert dict to Part object
84
+ merged_parts.append(types.Part(**part_dict))
85
+
86
+ # Don't forget to add any remaining accumulated text
87
+ if accumulated_text:
88
+ merged_parts.append(types.Part(text=accumulated_text))
89
+
90
+ return merged_parts
91
+
92
+
43
93
  def set_span_attribute(span: Span, name: str, value: Any):
44
94
  if value is not None and value != "":
45
95
  span.set_attribute(name, value)
lmnr/version.py CHANGED
@@ -3,7 +3,7 @@ import httpx
3
3
  from packaging import version
4
4
 
5
5
 
6
- __version__ = "0.7.16"
6
+ __version__ = "0.7.17"
7
7
  PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
8
8
 
9
9
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lmnr
3
- Version: 0.7.16
3
+ Version: 0.7.17
4
4
  Summary: Python SDK for Laminar
5
5
  Author: lmnr.ai
6
6
  Author-email: lmnr.ai <founders@lmnr.ai>
@@ -26,6 +26,7 @@ Requires-Dist: grpcio>=1
26
26
  Requires-Dist: httpx>=0.24.0
27
27
  Requires-Dist: orjson>=3.0.0
28
28
  Requires-Dist: packaging>=22.0
29
+ Requires-Dist: opentelemetry-instrumentation-threading>=0.57b0
29
30
  Requires-Dist: opentelemetry-instrumentation-alephalpha>=0.47.1 ; extra == 'alephalpha'
30
31
  Requires-Dist: opentelemetry-instrumentation-alephalpha>=0.47.1 ; extra == 'all'
31
32
  Requires-Dist: opentelemetry-instrumentation-bedrock>=0.47.1 ; extra == 'all'
@@ -16,10 +16,10 @@ lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/version.py,sha256
16
16
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_agent/__init__.py,sha256=48391d935883506fe1dc4f6ace6011ecaed76a8f82f8026ccb553b2180afdb8c,3455
17
17
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_computer/__init__.py,sha256=61d2681e99c3084d1bcc27f7ca551f44a70126df6c5f23320c1e9c1654e05c42,15037
18
18
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_computer/utils.py,sha256=19090d4d9a0511645f66112ebe6f05a9993905b11d8ae3060dab2dcc4c1a5fb2,329
19
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/__init__.py,sha256=a0037e5ed736e3124c7cd0af7eff6d2656a622d4b0a16785e2d2fb7d760f85a0,20163
19
+ lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/__init__.py,sha256=02f426b0296b3537705bdaf306f91cc7e914812ecb8eb18a18e43a9f4ed2b659,20221
20
20
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/config.py,sha256=db9cdebc9ee0dccb493ffe608eede3047efec20ed26c3924b72b2e50edbd92c2,245
21
21
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/schema_utils.py,sha256=b10619e76e5893f8b891f92531d29dcf6651e8f9a7dcbf81c3f35341ce311f6e,753
22
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/utils.py,sha256=2e1dc91b04757f7f6c960e3f1c58bb9f7e735f0e1dcb811a08833faf18766d3b,9242
22
+ lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/utils.py,sha256=ac662208d336cb9f5eb086389cd77d73e1a5a8bcc22ce8fffccd12a828b4e5cd,11092
23
23
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/__init__.py,sha256=1e98467711405e4ff8ccd0b53c002e7a676c581616ef015e8b6606bd7057478b,14986
24
24
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/config.py,sha256=29d557d9dee56354e89634bdc3f4795f346ee67bbfec56184b4fb394e45a7e03,203
25
25
  lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/event_emitter.py,sha256=1f07d78bf360832951c708fcb3737718e50d39ce05beb8adbf57e818b4873703,4481
@@ -97,8 +97,8 @@ lmnr/sdk/laminar.py,sha256=24adfd64da01d7fd69ba9437cf9860a5c64aa6baab1bb92d8ba14
97
97
  lmnr/sdk/log.py,sha256=9edfd83263f0d4845b1b2d1beeae2b4ed3f8628de941f371a893d72b79c348d4,2213
98
98
  lmnr/sdk/types.py,sha256=d8061ca90dd582b408a893ebbbeb1586e8750ed30433ef4f6d63423a078511b0,14574
99
99
  lmnr/sdk/utils.py,sha256=4114559ba6ae57fcba2de2bfaa09339688ce5752c36f028a7b55e51eae624947,6307
100
- lmnr/version.py,sha256=cc6cc51d32104d432712f37c6215b60901c85269bf239b623a9d3d72dcd220f8,1322
101
- lmnr-0.7.16.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
102
- lmnr-0.7.16.dist-info/entry_points.txt,sha256=abdf3411b7dd2d7329a241f2da6669bab4e314a747a586ecdb9f888f3035003c,39
103
- lmnr-0.7.16.dist-info/METADATA,sha256=0405208ecd989926a7b75dd4fedbab4fbd010c126fca736e09673ea955efeed6,14195
104
- lmnr-0.7.16.dist-info/RECORD,,
100
+ lmnr/version.py,sha256=e305a8be18cd8c4d3cd950cef8dc20ffba7c351cd92c344aff4358aa9b520316,1322
101
+ lmnr-0.7.17.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
102
+ lmnr-0.7.17.dist-info/entry_points.txt,sha256=abdf3411b7dd2d7329a241f2da6669bab4e314a747a586ecdb9f888f3035003c,39
103
+ lmnr-0.7.17.dist-info/METADATA,sha256=e295f9fd97eda35dd4e7dcc564ced240043eeda521bff23fd3072b5347caf810,14258
104
+ lmnr-0.7.17.dist-info/RECORD,,
File without changes