langtrace-python-sdk 3.3.18__py3-none-any.whl → 3.3.20__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,12 +56,8 @@ def patch_initiate_chat(name, version, tracer: Tracer):
56
56
  def patch_generate_reply(name, version, tracer: Tracer):
57
57
 
58
58
  def traced_method(wrapped, instance, args, kwargs):
59
-
60
59
  llm_config = instance.llm_config
61
- kwargs = {
62
- **kwargs,
63
- **llm_config.get("config_list")[0],
64
- }
60
+ kwargs = parse_kwargs(kwargs, llm_config)
65
61
  service_provider = SERVICE_PROVIDERS["AUTOGEN"]
66
62
 
67
63
  span_attributes = {
@@ -84,20 +80,28 @@ def patch_generate_reply(name, version, tracer: Tracer):
84
80
  try:
85
81
 
86
82
  result = wrapped(*args, **kwargs)
87
-
83
+
88
84
  # if caching is disabled, return result as langtrace will instrument the rest.
89
- if "cache_seed" in llm_config and llm_config.get("cache_seed") is None:
85
+ if (
86
+ llm_config
87
+ and "cache_seed" in llm_config
88
+ and llm_config.get("cache_seed") is None
89
+ ):
90
90
  return result
91
91
 
92
92
  set_span_attributes(span, attributes)
93
93
  set_event_completion(span, [{"role": "assistant", "content": result}])
94
- total_cost, response_model = list(instance.get_total_usage().keys())
95
- set_span_attribute(
96
- span, SpanAttributes.LLM_RESPONSE_MODEL, response_model
97
- )
98
- set_usage_attributes(
99
- span, instance.get_total_usage().get(response_model)
100
- )
94
+ if llm_config:
95
+ if instance.get_total_usage() is not None:
96
+ total_cost, response_model = list(
97
+ instance.get_total_usage().keys()
98
+ )
99
+ set_span_attribute(
100
+ span, SpanAttributes.LLM_RESPONSE_MODEL, response_model
101
+ )
102
+ set_usage_attributes(
103
+ span, instance.get_total_usage().get(response_model)
104
+ )
101
105
 
102
106
  return result
103
107
 
@@ -130,3 +134,20 @@ def parse_agent(agent):
130
134
  "llm_config": str(getattr(agent, "llm_config", None)),
131
135
  "human_input_mode": getattr(agent, "human_input_mode", None),
132
136
  }
137
+
138
+
139
+ def parse_kwargs(kwargs, llm_config):
140
+ # Handle cases where llm_config is False or None
141
+ if not llm_config:
142
+ return kwargs
143
+
144
+ if isinstance(llm_config, dict) and "config_list" in llm_config:
145
+ return {
146
+ **kwargs,
147
+ **llm_config.get("config_list")[0],
148
+ }
149
+ else:
150
+ return {
151
+ **kwargs,
152
+ **llm_config,
153
+ }
@@ -1 +1 @@
1
- __version__ = "3.3.18"
1
+ __version__ = "3.3.20"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.3.18
3
+ Version: 3.3.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>
@@ -109,7 +109,7 @@ examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56sn
109
109
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
110
110
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
111
111
  langtrace_python_sdk/langtrace.py,sha256=nvPaJc426Iww3ildrhsSacXtLdzsZIa94_rlK2giyVM,13153
112
- langtrace_python_sdk/version.py,sha256=9g2UTdPAtK4y3-RMCghlZIFhe-b0mxLKaThdD7MED8M,23
112
+ langtrace_python_sdk/version.py,sha256=81bzJ_fJLZ-62a4Hk7ky5bhaetRoFWuYWwZn42n0fPc,23
113
113
  langtrace_python_sdk/constants/__init__.py,sha256=3CNYkWMdd1DrkGqzLUgNZXjdAlM6UFMlf_F-odAToyc,146
114
114
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=EVCrouYCpY98f0KSaKr4PzNxPULTZZO6dSA_crEOyJU,106
115
115
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -141,7 +141,7 @@ langtrace_python_sdk/instrumentation/anthropic/patch.py,sha256=ztPN4VZujoxYOKhTb
141
141
  langtrace_python_sdk/instrumentation/anthropic/types.py,sha256=WdeXe2tkjAisMLK38STKwVe7MJS5SLoETJ_aKhA_-UU,2463
142
142
  langtrace_python_sdk/instrumentation/autogen/__init__.py,sha256=unDhpqWQIdHFw24lRsRu1Mm1NCZxZgyBrPRZrAJL3Lo,90
143
143
  langtrace_python_sdk/instrumentation/autogen/instrumentation.py,sha256=MVDUCBi6XzLQYmZd6myAounI0HeM8QWX5leuul5Hj0Q,1262
144
- langtrace_python_sdk/instrumentation/autogen/patch.py,sha256=mp6WxHYVqTXvqZOi6CnZNN0MmzoG5v9LPMU2fjkivsY,4650
144
+ langtrace_python_sdk/instrumentation/autogen/patch.py,sha256=7Sq3C8Q5tT27UkWXd1SZgnLC1pbQf_tpTrxoBIYsDw4,5273
145
145
  langtrace_python_sdk/instrumentation/aws_bedrock/__init__.py,sha256=IHqPgR1kdDvcoV1nUb-B21PaJ_qbQB0jc011Udi1ioU,96
146
146
  langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py,sha256=2l-WiyWYUEoGre92rmylq2jPZ5w4jcxTXmCTuQNC1RU,1911
147
147
  langtrace_python_sdk/instrumentation/aws_bedrock/patch.py,sha256=VAroMezSGKT2jQ5tggbdiMRIPr9mtLItGJJgZ-xoGls,6296
@@ -270,8 +270,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
270
270
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
271
271
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
272
272
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
273
- langtrace_python_sdk-3.3.18.dist-info/METADATA,sha256=M4r-V_wmy75oIlqyYNY0beRto96gM-DjA7OXdvuCmyg,15676
274
- langtrace_python_sdk-3.3.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
275
- langtrace_python_sdk-3.3.18.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
276
- langtrace_python_sdk-3.3.18.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
277
- langtrace_python_sdk-3.3.18.dist-info/RECORD,,
273
+ langtrace_python_sdk-3.3.20.dist-info/METADATA,sha256=cbJScXuK1lpnJnx-ywg1uO_xCgmByqSVGSLwH3w7cNo,15676
274
+ langtrace_python_sdk-3.3.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
275
+ langtrace_python_sdk-3.3.20.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
276
+ langtrace_python_sdk-3.3.20.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
277
+ langtrace_python_sdk-3.3.20.dist-info/RECORD,,