langtrace-python-sdk 1.2.18__py3-none-any.whl → 1.2.20__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,
@@ -219,6 +230,8 @@ def chat_completions_create(original_method, version, tracer):
219
230
  completion_tokens = 0
220
231
  try:
221
232
  for chunk in result:
233
+ if hasattr(chunk, "model") and chunk.model is not None:
234
+ span.set_attribute("llm.model", chunk.model)
222
235
  if hasattr(chunk, "choices") and chunk.choices is not None:
223
236
  token_counts = [
224
237
  (
@@ -287,7 +300,7 @@ def chat_completions_create(original_method, version, tracer):
287
300
  {
288
301
  "message": {
289
302
  "role": "assistant",
290
- "function_call": "".join(result_content),
303
+ "content": "".join(result_content),
291
304
  }
292
305
  }
293
306
  ),
@@ -1 +1 @@
1
- __version__ = "1.2.18"
1
+ __version__ = "1.2.20"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 1.2.18
3
+ Version: 1.2.20
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=XcELISZQTMy84hZtR4cdOkuOGviIP82q_-L9IH-Qu7A,23
21
+ langtrace_python_sdk/version.py,sha256=nQtXpLTEUbMtAPecTV_hZAJZb9EhWc8glRv6hgKyvG4,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=tsGlmxEp4gNT6IyLQjJzJ9pdGhYVm2WdrPp4DEKRMOw,15091
53
+ langtrace_python_sdk/instrumentation/openai/patch.py,sha256=Owy_M5dwsCNSeYQVcYKof1Cr-s2AnEXG4IN5ch3Nn84,15764
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.18.dist-info/METADATA,sha256=lTQggsZSgkfVWFVewx_ad131c_X9stT2C6Is0Zr1-7Y,7695
61
- langtrace_python_sdk-1.2.18.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
62
- langtrace_python_sdk-1.2.18.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
63
- langtrace_python_sdk-1.2.18.dist-info/RECORD,,
60
+ langtrace_python_sdk-1.2.20.dist-info/METADATA,sha256=dGcm1zAGjaNqo-ahHvoc89V8L6hT_NZUSBZZIQb-PzI,7695
61
+ langtrace_python_sdk-1.2.20.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
62
+ langtrace_python_sdk-1.2.20.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
63
+ langtrace_python_sdk-1.2.20.dist-info/RECORD,,