langtrace-python-sdk 3.3.17__py3-none-any.whl → 3.3.19__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,25 @@ 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
+ total_cost, response_model = list(instance.get_total_usage().keys())
96
+ set_span_attribute(
97
+ span, SpanAttributes.LLM_RESPONSE_MODEL, response_model
98
+ )
99
+ set_usage_attributes(
100
+ span, instance.get_total_usage().get(response_model)
101
+ )
101
102
 
102
103
  return result
103
104
 
@@ -130,3 +131,20 @@ def parse_agent(agent):
130
131
  "llm_config": str(getattr(agent, "llm_config", None)),
131
132
  "human_input_mode": getattr(agent, "human_input_mode", None),
132
133
  }
134
+
135
+
136
+ def parse_kwargs(kwargs, llm_config):
137
+ # Handle cases where llm_config is False or None
138
+ if not llm_config:
139
+ return kwargs
140
+
141
+ if isinstance(llm_config, dict) and "config_list" in llm_config:
142
+ return {
143
+ **kwargs,
144
+ **llm_config.get("config_list")[0],
145
+ }
146
+ else:
147
+ return {
148
+ **kwargs,
149
+ **llm_config,
150
+ }
@@ -156,8 +156,10 @@ def get_headers(config: LangtraceConfig):
156
156
  def append_api_path(host: str):
157
157
  if host == LANGTRACE_REMOTE_URL:
158
158
  return f"{host}/api/trace"
159
- if "localhost" in host:
159
+
160
+ if "/api/trace" in host:
160
161
  return host
162
+
161
163
  return f"{host}/v1/traces"
162
164
 
163
165
 
@@ -1 +1 @@
1
- __version__ = "3.3.17"
1
+ __version__ = "3.3.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.3.17
3
+ Version: 3.3.19
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>
@@ -108,8 +108,8 @@ examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YP
108
108
  examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
109
109
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
110
110
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
111
- langtrace_python_sdk/langtrace.py,sha256=Jbrmf3c8WwCb75fPU7Pp38EbgVPp6MxNlTL1DIwD00k,13150
112
- langtrace_python_sdk/version.py,sha256=XsZO_FxCrBTe748Sk8qc957jJGKzbb_MCEA7H8yz2-I,23
111
+ langtrace_python_sdk/langtrace.py,sha256=nvPaJc426Iww3ildrhsSacXtLdzsZIa94_rlK2giyVM,13153
112
+ langtrace_python_sdk/version.py,sha256=knIyubzVCY3fFC1Cqx86HkFZ65n9VrwkejA71pRiLLs,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=pYcFnET9AwC1NiZ-NCZe7D11QhfFMMU_Bcl767pDInk,5128
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.17.dist-info/METADATA,sha256=CQZSp7-_M2whPPPbtgOJ7VVIaGNRWIthKJobbXKQr_k,15676
274
- langtrace_python_sdk-3.3.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
275
- langtrace_python_sdk-3.3.17.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
276
- langtrace_python_sdk-3.3.17.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
277
- langtrace_python_sdk-3.3.17.dist-info/RECORD,,
273
+ langtrace_python_sdk-3.3.19.dist-info/METADATA,sha256=t4SCYlUNsydN3kBf4RUhPMYlww9iZBomnfkv8cTOq9w,15676
274
+ langtrace_python_sdk-3.3.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
275
+ langtrace_python_sdk-3.3.19.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
276
+ langtrace_python_sdk-3.3.19.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
277
+ langtrace_python_sdk-3.3.19.dist-info/RECORD,,