langtrace-python-sdk 1.2.19__py3-none-any.whl → 1.2.21__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.
@@ -194,9 +194,20 @@ def chat_completions_create(original_method, version, tracer):
194
194
  span.end()
195
195
  return result
196
196
  else:
197
- prompt_tokens = calculate_prompt_tokens(
198
- json.dumps(kwargs.get("messages", {})[0]), kwargs.get("model")
199
- )
197
+ # iterate over kwargs.get("messages", {}) and calculate the prompt tokens
198
+ prompt_tokens = 0
199
+ for message in kwargs.get("messages", {}):
200
+ prompt_tokens += calculate_prompt_tokens(
201
+ json.dumps(message), kwargs.get("model")
202
+ )
203
+
204
+ # iterate over kwargs.get("functions") and calculate the prompt tokens
205
+ if kwargs.get("functions") is not None:
206
+ for function in kwargs.get("functions"):
207
+ prompt_tokens += calculate_prompt_tokens(
208
+ json.dumps(function), kwargs.get("model")
209
+ )
210
+
200
211
  return handle_streaming_response(
201
212
  result,
202
213
  span,
@@ -270,30 +281,19 @@ def chat_completions_create(original_method, version, tracer):
270
281
  }
271
282
  ),
272
283
  )
273
- if function_call is False:
274
- span.set_attribute(
275
- "llm.responses",
276
- json.dumps(
284
+ span.set_attribute(
285
+ "llm.responses",
286
+ json.dumps(
287
+ [
277
288
  {
278
289
  "message": {
279
290
  "role": "assistant",
280
291
  "content": "".join(result_content),
281
292
  }
282
293
  }
283
- ),
284
- )
285
- else:
286
- span.set_attribute(
287
- "llm.responses",
288
- json.dumps(
289
- {
290
- "message": {
291
- "role": "assistant",
292
- "function_call": "".join(result_content),
293
- }
294
- }
295
- ),
296
- )
294
+ ]
295
+ ),
296
+ )
297
297
  span.set_status(StatusCode.OK)
298
298
  span.end()
299
299
 
@@ -1 +1 @@
1
- __version__ = "1.2.19"
1
+ __version__ = "1.2.21"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 1.2.19
3
+ Version: 1.2.21
4
4
  Summary: Python SDK for LangTrace
5
5
  Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
6
6
  Author-email: Scale3 Labs <engineering@scale3labs.com>
@@ -18,7 +18,7 @@ examples/pinecone_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
18
18
  examples/pinecone_example/basic.py,sha256=hdV6-5Fmol9zeyFzDtdabD62vkqUJ4lCHG2YcVNpIpI,933
19
19
  langtrace_python_sdk/__init__.py,sha256=SlHg447-nQBbw8exRNJP_OyHUZ39Sldb7aaQ35hIRm8,262
20
20
  langtrace_python_sdk/langtrace.py,sha256=sWC7WqbOdOUB1sZ_hzLZVp0_Q8fBTRJRMUvOPyO6f20,3170
21
- langtrace_python_sdk/version.py,sha256=vBqPpUxy9sFZkDmAAvQCrIqAA_ye7foz7jV5SkuJi0I,23
21
+ langtrace_python_sdk/version.py,sha256=3uF8dV6igE_qWszFViblw_rtJOgCwoi-rVuWcQrSR0A,23
22
22
  langtrace_python_sdk/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=OfgvphRBPENwsAizqzka9lFu9aDw-A7ErYJ0atl3bpI,56
24
24
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -50,14 +50,14 @@ langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py,sha256=wVSvxS
50
50
  langtrace_python_sdk/instrumentation/llamaindex/patch.py,sha256=NqBsPM4eE3yMu1aIev8p8yH5Thsv72JL68ABEZNe2ug,2043
51
51
  langtrace_python_sdk/instrumentation/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  langtrace_python_sdk/instrumentation/openai/instrumentation.py,sha256=stlFopPggB8mgnn4QdVh41rmA8mlzH5x-C00XHfApCE,1408
53
- langtrace_python_sdk/instrumentation/openai/patch.py,sha256=H0c12pl7UZDyn2Go0a2ftcXcJNaGWlW4FzT4qHBMtUY,15228
53
+ langtrace_python_sdk/instrumentation/openai/patch.py,sha256=iP4RFL5ZHqu3BlNNq5DmmstLMaqaXmk4VKRbGXts1EI,15341
54
54
  langtrace_python_sdk/instrumentation/pinecone/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  langtrace_python_sdk/instrumentation/pinecone/instrumentation.py,sha256=o0EUd5jvHaDKOUTj4NjnL5UfDHDHxyXkWGlTW4oeRDk,1784
56
56
  langtrace_python_sdk/instrumentation/pinecone/patch.py,sha256=5lF7hQmg2-U2EWtOC0w8_peRaNMysBomb0fjiNoS6eQ,2200
57
57
  langtrace_python_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
58
  langtrace_python_sdk/utils/llm.py,sha256=4z2e-md_ELXCEuOIRVWracR6qH2pmsOxCqpkuF9_3Nw,1589
59
59
  langtrace_python_sdk/utils/with_root_span.py,sha256=N7ONrcF0myZbHBy5gpQffDbX-Kf63Crsz9szG0i3m08,1889
60
- langtrace_python_sdk-1.2.19.dist-info/METADATA,sha256=rm-JsAkSY5nhdnd1Wuuv6liUzDVnKdSm_yzeX4SS5Ao,7695
61
- langtrace_python_sdk-1.2.19.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
62
- langtrace_python_sdk-1.2.19.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
63
- langtrace_python_sdk-1.2.19.dist-info/RECORD,,
60
+ langtrace_python_sdk-1.2.21.dist-info/METADATA,sha256=9yDWY-fJ-Sgnc6-M4apfEza7U9X-j0TWn6OQhfWmOZA,7695
61
+ langtrace_python_sdk-1.2.21.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
62
+ langtrace_python_sdk-1.2.21.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
63
+ langtrace_python_sdk-1.2.21.dist-info/RECORD,,