ragaai-catalyst 2.2.2__py3-none-any.whl → 2.2.3b0__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.
@@ -1,26 +1,35 @@
1
- import asyncio
1
+ import os
2
+ import uuid
2
3
  import datetime
3
- import json
4
4
  import logging
5
- import os
6
- from concurrent.futures import ThreadPoolExecutor
7
- from contextlib import contextmanager
8
- from pathlib import Path
9
-
5
+ import asyncio
10
6
  import aiohttp
11
7
  import requests
12
8
  from litellm import model_cost
9
+ from pathlib import Path
10
+ from contextlib import contextmanager
11
+ from concurrent.futures import ThreadPoolExecutor
12
+ from ragaai_catalyst.tracers.langchain_callback import LangchainTracer
13
+ from ragaai_catalyst.tracers.utils.convert_langchain_callbacks_output import convert_langchain_callbacks_output
13
14
 
14
- # from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
15
- from openinference.instrumentation.langchain import LangChainInstrumentor
15
+ from ragaai_catalyst.tracers.utils.langchain_tracer_extraction_logic import langchain_tracer_extraction
16
+ from ragaai_catalyst.tracers.upload_traces import UploadTraces
17
+ import tempfile
18
+ import json
19
+ import numpy as np
16
20
  from opentelemetry.sdk import trace as trace_sdk
17
21
  from opentelemetry.sdk.trace.export import SimpleSpanProcessor
18
-
22
+ from ragaai_catalyst.tracers.exporters.file_span_exporter import FileSpanExporter
23
+ from ragaai_catalyst.tracers.exporters.raga_exporter import RagaExporter
24
+ from ragaai_catalyst.tracers.utils import get_unique_key
25
+ # from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
26
+ from ragaai_catalyst.tracers.llamaindex_instrumentation import LlamaIndexInstrumentationTracer
27
+ from openinference.instrumentation.langchain import LangChainInstrumentor
19
28
  from ragaai_catalyst import RagaAICatalyst
20
29
  from ragaai_catalyst.tracers.agentic_tracing import AgenticTracing
30
+ from ragaai_catalyst.tracers.agentic_tracing.tracers.llm_tracer import LLMTracerMixin
31
+ from ragaai_catalyst.tracers.exporters.ragaai_trace_exporter import RAGATraceExporter
21
32
  from ragaai_catalyst.tracers.agentic_tracing.utils.file_name_tracker import TrackName
22
- from ragaai_catalyst.tracers.exporters.file_span_exporter import FileSpanExporter
23
- from ragaai_catalyst.tracers.utils import get_unique_key
24
33
 
25
34
  logger = logging.getLogger(__name__)
26
35
  logging_level = (
@@ -191,16 +200,12 @@ class Tracer(AgenticTracing):
191
200
  # Add LLM Instrumentors
192
201
  if tracer_type in ['agentic/crewai']:
193
202
  try:
194
- from openinference.instrumentation.vertexai import (
195
- VertexAIInstrumentor,
196
- )
203
+ from openinference.instrumentation.vertexai import VertexAIInstrumentor
197
204
  instrumentors.append((VertexAIInstrumentor, []))
198
205
  except (ImportError, ModuleNotFoundError):
199
206
  logger.debug("VertexAI not available in environment")
200
207
  try:
201
- from openinference.instrumentation.anthropic import (
202
- AnthropicInstrumentor,
203
- )
208
+ from openinference.instrumentation.anthropic import AnthropicInstrumentor
204
209
  instrumentors.append((AnthropicInstrumentor, []))
205
210
  except (ImportError, ModuleNotFoundError):
206
211
  logger.debug("Anthropic not available in environment")
@@ -210,16 +215,12 @@ class Tracer(AgenticTracing):
210
215
  except (ImportError, ModuleNotFoundError):
211
216
  logger.debug("Groq not available in environment")
212
217
  try:
213
- from openinference.instrumentation.litellm import (
214
- LiteLLMInstrumentor,
215
- )
218
+ from openinference.instrumentation.litellm import LiteLLMInstrumentor
216
219
  instrumentors.append((LiteLLMInstrumentor, []))
217
220
  except (ImportError, ModuleNotFoundError):
218
221
  logger.debug("LiteLLM not available in environment")
219
222
  try:
220
- from openinference.instrumentation.mistralai import (
221
- MistralAIInstrumentor,
222
- )
223
+ from openinference.instrumentation.mistralai import MistralAIInstrumentor
223
224
  instrumentors.append((MistralAIInstrumentor, []))
224
225
  except (ImportError, ModuleNotFoundError):
225
226
  logger.debug("MistralAI not available in environment")
@@ -229,9 +230,7 @@ class Tracer(AgenticTracing):
229
230
  except (ImportError, ModuleNotFoundError):
230
231
  logger.debug("OpenAI not available in environment")
231
232
  try:
232
- from openinference.instrumentation.bedrock import (
233
- BedrockInstrumentor,
234
- )
233
+ from openinference.instrumentation.bedrock import BedrockInstrumentor
235
234
  instrumentors.append((BedrockInstrumentor, []))
236
235
  except (ImportError, ModuleNotFoundError):
237
236
  logger.debug("Bedrock not available in environment")
@@ -244,9 +243,7 @@ class Tracer(AgenticTracing):
244
243
  try:
245
244
  # LlamaIndex
246
245
  try:
247
- from openinference.instrumentation.llama_index import (
248
- LlamaIndexInstrumentor,
249
- )
246
+ from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
250
247
  instrumentors.append((LlamaIndexInstrumentor, []))
251
248
  logger.info("Instrumenting LlamaIndex...")
252
249
  except (ImportError, ModuleNotFoundError):
@@ -254,9 +251,7 @@ class Tracer(AgenticTracing):
254
251
 
255
252
  # LangChain
256
253
  try:
257
- from openinference.instrumentation.langchain import (
258
- LangChainInstrumentor,
259
- )
254
+ from openinference.instrumentation.langchain import LangChainInstrumentor
260
255
  instrumentors.append((LangChainInstrumentor, []))
261
256
  logger.info("Instrumenting LangChain...")
262
257
  except (ImportError, ModuleNotFoundError):
@@ -264,9 +259,7 @@ class Tracer(AgenticTracing):
264
259
 
265
260
  # CrewAI
266
261
  try:
267
- from openinference.instrumentation.crewai import (
268
- CrewAIInstrumentor,
269
- )
262
+ from openinference.instrumentation.crewai import CrewAIInstrumentor
270
263
  instrumentors.append((CrewAIInstrumentor, []))
271
264
  logger.info("Instrumenting CrewAI...")
272
265
  except (ImportError, ModuleNotFoundError):
@@ -274,9 +267,7 @@ class Tracer(AgenticTracing):
274
267
 
275
268
  # Haystack
276
269
  try:
277
- from openinference.instrumentation.haystack import (
278
- HaystackInstrumentor,
279
- )
270
+ from openinference.instrumentation.haystack import HaystackInstrumentor
280
271
  instrumentors.append((HaystackInstrumentor, []))
281
272
  logger.info("Instrumenting Haystack...")
282
273
  except (ImportError, ModuleNotFoundError):
@@ -284,9 +275,7 @@ class Tracer(AgenticTracing):
284
275
 
285
276
  # AutoGen
286
277
  try:
287
- from openinference.instrumentation.autogen import (
288
- AutogenInstrumentor,
289
- )
278
+ from openinference.instrumentation.autogen import AutogenInstrumentor
290
279
  instrumentors.append((AutogenInstrumentor, []))
291
280
  logger.info("Instrumenting AutoGen...")
292
281
  except (ImportError, ModuleNotFoundError):
@@ -294,9 +283,7 @@ class Tracer(AgenticTracing):
294
283
 
295
284
  # Smolagents
296
285
  try:
297
- from openinference.instrumentation.smolagents import (
298
- SmolagentsInstrumentor,
299
- )
286
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
300
287
  instrumentors.append((SmolagentsInstrumentor, []))
301
288
  logger.info("Instrumenting Smolagents...")
302
289
  except (ImportError, ModuleNotFoundError):
@@ -304,9 +291,7 @@ class Tracer(AgenticTracing):
304
291
 
305
292
  # OpenAI Agents
306
293
  try:
307
- from openinference.instrumentation.openai_agents import (
308
- OpenAIAgentsInstrumentor,
309
- )
294
+ from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
310
295
  instrumentors.append((OpenAIAgentsInstrumentor, []))
311
296
  logger.info("Instrumenting OpenAI Agents...")
312
297
  except (ImportError, ModuleNotFoundError):
@@ -324,22 +309,16 @@ class Tracer(AgenticTracing):
324
309
 
325
310
  # Handle specific framework instrumentation
326
311
  elif tracer_type == "agentic/llamaindex" or tracer_type == "llamaindex":
327
- from openinference.instrumentation.llama_index import (
328
- LlamaIndexInstrumentor,
329
- )
312
+ from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
330
313
  instrumentors += [(LlamaIndexInstrumentor, [])]
331
314
 
332
315
  elif tracer_type == "agentic/langchain" or tracer_type == "agentic/langgraph" or tracer_type == "langchain":
333
- from openinference.instrumentation.langchain import (
334
- LangChainInstrumentor,
335
- )
316
+ from openinference.instrumentation.langchain import LangChainInstrumentor
336
317
  instrumentors += [(LangChainInstrumentor, [])]
337
318
 
338
319
  elif tracer_type == "agentic/crewai":
339
320
  from openinference.instrumentation.crewai import CrewAIInstrumentor
340
- from openinference.instrumentation.langchain import (
341
- LangChainInstrumentor,
342
- )
321
+ from openinference.instrumentation.langchain import LangChainInstrumentor
343
322
  instrumentors += [(CrewAIInstrumentor, []), (LangChainInstrumentor, [])]
344
323
 
345
324
  elif tracer_type == "agentic/haystack":
@@ -351,15 +330,11 @@ class Tracer(AgenticTracing):
351
330
  instrumentors += [(AutogenInstrumentor, [])]
352
331
 
353
332
  elif tracer_type == "agentic/smolagents":
354
- from openinference.instrumentation.smolagents import (
355
- SmolagentsInstrumentor,
356
- )
333
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
357
334
  instrumentors += [(SmolagentsInstrumentor, [])]
358
335
 
359
336
  elif tracer_type == "agentic/openai_agents":
360
- from openinference.instrumentation.openai_agents import (
361
- OpenAIAgentsInstrumentor,
362
- )
337
+ from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
363
338
  instrumentors += [(OpenAIAgentsInstrumentor, [])]
364
339
 
365
340
  else:
@@ -440,7 +415,10 @@ class Tracer(AgenticTracing):
440
415
  'start_time', 'end_time', 'name', 'id',
441
416
  'hash_id', 'parent_id', 'source_hash_id',
442
417
  'cost', 'type', 'feedback', 'error', 'ctx','telemetry.sdk.version',
443
- 'telemetry.sdk.language','service.name'
418
+ 'telemetry.sdk.language','service.name', 'llm.model_name',
419
+ 'llm.invocation_parameters', 'metadata', 'openinference.span.kind',
420
+ 'llm.token_count.prompt', 'llm.token_count.completion', 'llm.token_count.total',
421
+ "input_cost", "output_cost", "total_cost", "status_code"
444
422
  }
445
423
  # Apply masking only if the key is NOT in the excluded list
446
424
  if parent_key and parent_key.lower() not in excluded_keys:
@@ -825,10 +803,7 @@ class Tracer(AgenticTracing):
825
803
  """
826
804
  from opentelemetry.sdk import trace as trace_sdk
827
805
  from opentelemetry.sdk.trace.export import SimpleSpanProcessor
828
-
829
- from ragaai_catalyst.tracers.exporters.dynamic_trace_exporter import (
830
- DynamicTraceExporter,
831
- )
806
+ from ragaai_catalyst.tracers.exporters.dynamic_trace_exporter import DynamicTraceExporter
832
807
 
833
808
  # Get the code_files
834
809
  self.file_tracker.trace_main_file()
@@ -15,6 +15,7 @@ from ragaai_catalyst.tracers.agentic_tracing.utils.llm_utils import (
15
15
 
16
16
  logger = logging.getLogger(__name__)
17
17
 
18
+
18
19
  def convert_time_format(original_time_str, target_timezone_str="Asia/Kolkata"):
19
20
  """
20
21
  Converts a UTC time string to a specified timezone format.
@@ -36,7 +37,7 @@ def convert_time_format(original_time_str, target_timezone_str="Asia/Kolkata"):
36
37
  # Format the datetime object to the desired string format
37
38
  formatted_time = target_time.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
38
39
  # Add a colon in the timezone offset for better readability
39
- formatted_time = formatted_time[:-2] + ':' + formatted_time[-2:]
40
+ formatted_time = formatted_time[:-2] + ":" + formatted_time[-2:]
40
41
  return formatted_time
41
42
 
42
43
 
@@ -44,35 +45,43 @@ def get_uuid(name):
44
45
  """Generate a random UUID (not based on name)."""
45
46
  return str(uuid.uuid5(uuid.NAMESPACE_DNS, name))
46
47
 
48
+
47
49
  def get_ordered_family(parent_children_mapping: Dict[str, Any]) -> List[str]:
48
50
  def ordering_function(parent_id: str, ordered_family: List[str]):
49
51
  children = parent_children_mapping.get(parent_id, [])
50
- parent_child_ids =[child['id'] for child in children if child['id'] in parent_children_mapping]
52
+ parent_child_ids = [
53
+ child["id"] for child in children if child["id"] in parent_children_mapping
54
+ ]
51
55
  for child_id in parent_child_ids:
52
56
  if child_id not in ordered_family:
53
57
  ordered_family.append(child_id)
54
58
  ordering_function(child_id, ordered_family)
59
+
55
60
  ordered_family = [None]
56
61
  ordering_function(None, ordered_family)
57
62
  return reversed(ordered_family)
58
63
 
64
+
59
65
  def get_spans(input_trace):
60
66
  data = input_trace.copy()
61
67
  from collections import defaultdict
62
-
68
+
63
69
  name_counts = defaultdict(int)
64
70
 
65
71
  for span in data:
66
72
  # 1. For each span add '.{occurence_no}' to the span name, where occurence_no is the number of times the span name has occurred
67
73
  span["name_occurrences"] = name_counts[span["name"]]
68
74
  name_counts[span["name"]] += 1
69
- span['name'] = f"{span['name']}.{span['name_occurrences']}"
75
+ span["name"] = f"{span['name']}.{span['name_occurrences']}"
70
76
 
71
77
  # 2. For each span add hash_id, which is uuid4 based on the span name
72
- span['hash_id'] = get_uuid(span['name'])
78
+ span["hash_id"] = get_uuid(span["name"])
73
79
  return data
74
80
 
75
- def convert_json_format(input_trace, custom_model_cost, user_context, user_gt,external_id):
81
+
82
+ def convert_json_format(
83
+ input_trace, custom_model_cost, user_context, user_gt, external_id
84
+ ):
76
85
  """
77
86
  Converts a JSON from one format to UI format, handling nested spans.
78
87
 
@@ -82,25 +91,20 @@ def convert_json_format(input_trace, custom_model_cost, user_context, user_gt,ex
82
91
  Returns:
83
92
  final_trace: The converted JSON, or None if an error occurs.
84
93
  """
94
+
85
95
  final_trace = {
86
96
  "id": input_trace[0]["context"]["trace_id"],
87
- "trace_name": "",
88
- "project_name": "",
89
- "start_time": convert_time_format(min(item["start_time"] for item in input_trace)),
97
+ "trace_name": "",
98
+ "project_name": "",
99
+ "start_time": convert_time_format(
100
+ min(item["start_time"] for item in input_trace)
101
+ ),
90
102
  "end_time": convert_time_format(max(item["end_time"] for item in input_trace)),
91
- "external_id": external_id
103
+ "external_id": external_id,
92
104
  }
93
105
  final_trace["metadata"] = {
94
- "tokens": {
95
- "prompt_tokens": 0.0,
96
- "completion_tokens": 0.0,
97
- "total_tokens": 0.0
98
- },
99
- "cost": {
100
- "input_cost": 0.0,
101
- "output_cost": 0.0,
102
- "total_cost": 0.0
103
- }
106
+ "tokens": {"prompt_tokens": 0.0, "completion_tokens": 0.0, "total_tokens": 0.0},
107
+ "cost": {"input_cost": 0.0, "output_cost": 0.0, "total_cost": 0.0},
104
108
  }
105
109
  final_trace["replays"] = {"source": None}
106
110
  final_trace["data"] = [{}]
@@ -113,27 +117,42 @@ def convert_json_format(input_trace, custom_model_cost, user_context, user_gt,ex
113
117
  # Add user passed context to the trace
114
118
  try:
115
119
  if user_context:
116
- spans.append(custom_spans(user_context, "Context", input_trace[0]["context"]["trace_id"], spans[0].get("parent_id")))
120
+ spans.append(
121
+ custom_spans(
122
+ user_context,
123
+ "Context",
124
+ input_trace[0]["context"]["trace_id"],
125
+ spans[0].get("parent_id"),
126
+ )
127
+ )
117
128
  except Exception as e:
118
129
  print(f"Error in adding context: {e}")
119
130
  return None
120
-
131
+
121
132
  try:
122
133
  if user_gt:
123
- spans.append(custom_spans(user_gt, "GroundTruth", input_trace[0]["context"]["trace_id"], spans[0].get("parent_id")))
134
+ spans.append(
135
+ custom_spans(
136
+ user_gt,
137
+ "GroundTruth",
138
+ input_trace[0]["context"]["trace_id"],
139
+ spans[0].get("parent_id"),
140
+ )
141
+ )
124
142
  except Exception as e:
125
143
  print(f"Error in adding ground truth: {e}")
126
144
  return None
127
145
 
128
-
129
146
  final_trace["data"][0]["spans"] = spans
130
-
147
+
131
148
  # Calculate token counts and costs from spans
132
149
  for span in spans:
133
150
  if "attributes" in span:
134
151
  # Extract token counts
135
152
  prompt_tokens = span["attributes"].get("llm.token_count.prompt", 0)
136
- completion_tokens = span["attributes"].get("llm.token_count.completion", 0)
153
+ completion_tokens = span["attributes"].get(
154
+ "llm.token_count.completion", 0
155
+ )
137
156
 
138
157
  # If prompt tokens or/and completion tokens are not present, will calculate it using tiktoken
139
158
  try:
@@ -141,35 +160,56 @@ def convert_json_format(input_trace, custom_model_cost, user_context, user_gt,ex
141
160
  prompt_value = span["attributes"].get("input.value")
142
161
  if prompt_value:
143
162
  prompt_tokens = count_tokens(prompt_value)
144
- logger.debug(f"Prompt tokens not present, calculated it: {prompt_tokens}")
163
+ logger.debug(
164
+ f"Prompt tokens not present, calculated it: {prompt_tokens}"
165
+ )
145
166
  if completion_tokens == 0:
146
167
  completion_value = span["attributes"].get("output.value")
147
168
  if completion_value:
148
169
  completion_tokens = count_tokens(completion_value)
149
- logger.debug(f"Completion tokens not present, calculated it: {completion_tokens}")
170
+ logger.debug(
171
+ f"Completion tokens not present, calculated it: {completion_tokens}"
172
+ )
150
173
  except Exception as e:
151
174
  logger.warning(f"Failed to calculate token counts: {e}")
152
175
 
153
176
  # Update token counts
154
177
  final_trace["metadata"]["tokens"]["prompt_tokens"] += prompt_tokens
155
- final_trace["metadata"]["tokens"]["completion_tokens"] += completion_tokens
156
- final_trace["metadata"]["tokens"]["total_tokens"] += prompt_tokens + completion_tokens
178
+ final_trace["metadata"]["tokens"]["completion_tokens"] += (
179
+ completion_tokens
180
+ )
181
+ final_trace["metadata"]["tokens"]["total_tokens"] += (
182
+ prompt_tokens + completion_tokens
183
+ )
157
184
 
158
185
  # Get model name from the last span
159
- model_name = span["attributes"].get("llm.model_name", "")
186
+ model_names = [
187
+ span["attributes"].get("llm.model_name", "") for span in spans
188
+ ]
189
+ model_name = next((name for name in reversed(model_names) if name), "")
160
190
  if model_name:
161
191
  try:
162
192
  model_costs = get_model_cost()
163
193
  span_cost = calculate_llm_cost(
164
- {"prompt_tokens": prompt_tokens, "completion_tokens": completion_tokens, "total_tokens": prompt_tokens + completion_tokens},
194
+ {
195
+ "prompt_tokens": prompt_tokens,
196
+ "completion_tokens": completion_tokens,
197
+ "total_tokens": prompt_tokens + completion_tokens,
198
+ },
165
199
  model_name,
166
200
  model_costs,
167
- custom_model_cost
201
+ custom_model_cost,
168
202
  )
169
- final_trace["metadata"]["cost"]["input_cost"] += span_cost["input_cost"]
170
- final_trace["metadata"]["cost"]["output_cost"] += span_cost["output_cost"]
171
- final_trace["metadata"]["cost"]["total_cost"] += span_cost["total_cost"]
172
-
203
+ final_trace["metadata"]["cost"]["input_cost"] += span_cost[
204
+ "input_cost"
205
+ ]
206
+ final_trace["metadata"]["cost"]["output_cost"] += span_cost[
207
+ "output_cost"
208
+ ]
209
+ final_trace["metadata"]["cost"]["total_cost"] += span_cost[
210
+ "total_cost"
211
+ ]
212
+
173
213
  # Add cost to span attributes for debugging
174
214
  span["attributes"]["llm.cost"] = span_cost
175
215
  except Exception as e:
@@ -179,75 +219,82 @@ def convert_json_format(input_trace, custom_model_cost, user_context, user_gt,ex
179
219
  raise Exception(f"Error in get_spans function: {e}")
180
220
 
181
221
  # Total metadata summary
182
- final_trace["metadata"]["total_cost"] = final_trace["metadata"]["cost"]["total_cost"]
183
- final_trace["metadata"]["total_tokens"] = final_trace["metadata"]["tokens"]["total_tokens"]
222
+ final_trace["metadata"]["total_cost"] = final_trace["metadata"]["cost"][
223
+ "total_cost"
224
+ ]
225
+ final_trace["metadata"]["total_tokens"] = final_trace["metadata"]["tokens"][
226
+ "total_tokens"
227
+ ]
184
228
 
185
229
  return final_trace
186
230
 
231
+
187
232
  def custom_spans(text, span_type, trace_id, parent_id):
188
- try:
233
+ try:
189
234
  return {
190
- "name": f"Custom{span_type}Span",
191
- "context": {
192
- "trace_id": trace_id,
193
- "span_id": f"0x{uuid.uuid4().hex[:16]}",
194
- "trace_state": "[]"
195
- },
196
- "kind": "SpanKind.INTERNAL",
197
- "parent_id": parent_id,
198
- "start_time": convert_time_format(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
199
- "end_time": convert_time_format(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
200
- "status": {
201
- "status_code": "OK"
202
- },
203
- "attributes": {
204
- "input.value": text,
205
- "openinference.span.kind": "UNKNOWN"
206
- },
207
- "events": [],
208
- "name_occurrences": 0,
209
- "hash_id": get_uuid(f"Custom{span_type}Span")
210
- }
235
+ "name": f"Custom{span_type}Span",
236
+ "context": {
237
+ "trace_id": trace_id,
238
+ "span_id": f"0x{uuid.uuid4().hex[:16]}",
239
+ "trace_state": "[]",
240
+ },
241
+ "kind": "SpanKind.INTERNAL",
242
+ "parent_id": parent_id,
243
+ "start_time": convert_time_format(
244
+ datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
245
+ ),
246
+ "end_time": convert_time_format(
247
+ datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
248
+ ),
249
+ "status": {"status_code": "OK"},
250
+ "attributes": {"input.value": text, "openinference.span.kind": "UNKNOWN"},
251
+ "events": [],
252
+ "name_occurrences": 0,
253
+ "hash_id": get_uuid(f"Custom{span_type}Span"),
254
+ }
211
255
  except Exception as e:
212
256
  logger.warning(f"Error in custom_spans function: {e}")
213
257
  return {
214
- "name": f"Custom{span_type}Span",
215
- "context": {
216
- "trace_id": trace_id,
217
- "span_id": f"0x{uuid.uuid4().hex[:16]}",
218
- "trace_state": "[]"
219
- },
220
- "kind": "SpanKind.INTERNAL",
221
- "parent_id": parent_id,
222
- "start_time": convert_time_format(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
223
- "end_time": convert_time_format(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
224
- "status": {
225
- "status_code": "ERROR",
226
- "description": str(e)
227
- },
228
- "attributes": {
229
- "input.value": text,
230
- "openinference.span.kind": "UNKNOWN"
231
- },
232
- "events": [],
233
- "name_occurrences": 0,
234
- "hash_id": get_uuid(f"Custom{span_type}Span")
235
- }
258
+ "name": f"Custom{span_type}Span",
259
+ "context": {
260
+ "trace_id": trace_id,
261
+ "span_id": f"0x{uuid.uuid4().hex[:16]}",
262
+ "trace_state": "[]",
263
+ },
264
+ "kind": "SpanKind.INTERNAL",
265
+ "parent_id": parent_id,
266
+ "start_time": convert_time_format(
267
+ datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
268
+ ),
269
+ "end_time": convert_time_format(
270
+ datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
271
+ ),
272
+ "status": {"status_code": "ERROR", "description": str(e)},
273
+ "attributes": {"input.value": text, "openinference.span.kind": "UNKNOWN"},
274
+ "events": [],
275
+ "name_occurrences": 0,
276
+ "hash_id": get_uuid(f"Custom{span_type}Span"),
277
+ }
278
+
236
279
 
237
280
  if __name__ == "__main__":
238
281
  if len(sys.argv) != 3:
239
- print("Usage: python convert.py <input_openinference_trace_path> <output_trace_path>")
240
- print("Example: python convert.py sample_openinference_trace/test.json output.json")
282
+ print(
283
+ "Usage: python convert.py <input_openinference_trace_path> <output_trace_path>"
284
+ )
285
+ print(
286
+ "Example: python convert.py sample_openinference_trace/test.json output.json"
287
+ )
241
288
  sys.exit(1)
242
289
  input_file_path = sys.argv[1]
243
290
  output_file_path = sys.argv[2]
244
- with open(input_file_path,'r') as fin:
245
- input_trace=[]
291
+ with open(input_file_path, "r") as fin:
292
+ input_trace = []
246
293
  for line in fin:
247
- data=json.loads(line)
294
+ data = json.loads(line)
248
295
  input_trace.append(data)
249
296
  payload = convert_json_format(input_trace)
250
297
  print(payload)
251
- with open(output_file_path,"w") as fout:
252
- json.dump(payload,fout)
298
+ with open(output_file_path, "w") as fout:
299
+ json.dump(payload, fout)
253
300
  fout.write("\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ragaai_catalyst
3
- Version: 2.2.2
3
+ Version: 2.2.3b0
4
4
  Summary: RAGA AI CATALYST
5
5
  Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>, Siddhartha Kosti <siddhartha.kosti@raga.ai>, Ritika Goel <ritika.goel@raga.ai>, Vijay Chaurasia <vijay.chaurasia@raga.ai>, Tushar Kumar <tushar.kumar@raga.ai>, Rishabh Pandey <rishabh.pandey@raga.ai>, Jyotsana C G <jyotsana@raga.ai>
6
6
  Requires-Python: <=3.13.2,>=3.10
@@ -31,7 +31,7 @@ ragaai_catalyst/tracers/distributed.py,sha256=MwlBwIxCAng-OI-7Ove_rkE1mTLeuW4Jw-
31
31
  ragaai_catalyst/tracers/langchain_callback.py,sha256=CB75zzG3-DkYTELj0vI1MOHQTY0MuQJfoHIXz9Cl8S8,34568
32
32
  ragaai_catalyst/tracers/llamaindex_callback.py,sha256=ZY0BJrrlz-P9Mg2dX-ZkVKG3gSvzwqBtk7JL_05MiYA,14028
33
33
  ragaai_catalyst/tracers/llamaindex_instrumentation.py,sha256=Ys_jLkvVqo12bKgXDmkp4TxJu9HkBATrFE8cIcTYxWw,14329
34
- ragaai_catalyst/tracers/tracer.py,sha256=ngHe17GDSjHThrZO9uPr8yH-qYvnysPQrS7B0Aq_hJU,42071
34
+ ragaai_catalyst/tracers/tracer.py,sha256=YphQkHARFV0qKQUSa1ip7j41rMg7S6_F4Z1rGBxJdSg,42228
35
35
  ragaai_catalyst/tracers/upload_traces.py,sha256=w1clGGfdOMpStUJX40NAlxe6dcFdN4pwcezyII0bGYA,6994
36
36
  ragaai_catalyst/tracers/agentic_tracing/README.md,sha256=X4QwLb7-Jg7GQMIXj-SerZIgDETfw-7VgYlczOR8ZeQ,4508
37
37
  ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=yf6SKvOPSpH-9LiKaoLKXwqj5sez8F_5wkOb91yp0oE,260
@@ -54,7 +54,7 @@ ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl
54
54
  ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=xxrliKPfdfbIZRZqMnUewsaTD8_Hv0dbuoBivNZGD4U,21674
55
55
  ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha256=bhSUhNQCuJXKjgJAXhjKEYjnHMpYN90FSZdR84fNIKU,4614
56
56
  ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
- ragaai_catalyst/tracers/agentic_tracing/upload/trace_uploader.py,sha256=yA2_4fO0rWP0O4mrqcPGt_aZiB4gluVS5nCk6Q6k1y8,12946
57
+ ragaai_catalyst/tracers/agentic_tracing/upload/trace_uploader.py,sha256=FqHjvFdq5Pqp8iZcLTwXaxnMmm8ATec3fLdDuzLITFs,13019
58
58
  ragaai_catalyst/tracers/agentic_tracing/upload/upload_agentic_traces.py,sha256=qcii8NMZGJvmv19AokjCH2egGIsALLWK9JqHtgkFB_0,10447
59
59
  ragaai_catalyst/tracers/agentic_tracing/upload/upload_code.py,sha256=XWRqVU_4kEgpPpx-TKmfgFFI5mxf_uO54yNhD5ogYNk,10170
60
60
  ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py,sha256=m1O8lKpxKwtHofXLW3fTHX5yfqDW5GxoveARlg5cTw4,2571
@@ -64,7 +64,7 @@ ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py,sha256=Kx
64
64
  ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py,sha256=YG601l1a29ov9VPu9Vl4RXxgL7l16k54_WWnoTNoG58,2064
65
65
  ragaai_catalyst/tracers/agentic_tracing/utils/generic.py,sha256=WwXT01xmp8MSr7KinuDCSK9a1ifpLcT7ajFkvYviG_A,1190
66
66
  ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py,sha256=vPZ4dn4EHFW0kqd1GyRpsYXbfrRrd0DXCmh-pzsDBNE,1109
67
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=Tdi4nnxsXywx-X-4FOvyzRpvB04rgyd3Mzf4o9k_BAI,22697
67
+ ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=47kP4zdRTkJsOlvf5Cjx9Tayj6Ux_F21Ut7eJIgXgoE,22975
68
68
  ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=2tzGw_cKCTPcfjEm7iGvFE6pTw7gMTPzeBov_MTaXNY,321336
69
69
  ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=qmODERcFZhc8MX24boFCXkkh6sJ-vZngRHPvxhyWFeE,4347
70
70
  ragaai_catalyst/tracers/agentic_tracing/utils/supported_llm_provider.toml,sha256=LvFDivDIE96Zasp-fgDEqUJ5GEQZUawQucR3aOcSUTY,926
@@ -86,10 +86,10 @@ ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=XS2_x2
86
86
  ragaai_catalyst/tracers/utils/model_prices_and_context_window_backup.json,sha256=C3uwkibJ08C9sOX-54kulZYmJlIpZ-SQpfE6HNGrjbM,343502
87
87
  ragaai_catalyst/tracers/utils/rag_extraction_logic_final.py,sha256=3ygkRT__lLDRflRttjzPu28tIA8cTCiGQVMQjqMItqQ,11309
88
88
  ragaai_catalyst/tracers/utils/rag_trace_json_converter.py,sha256=54IEZO-YRjUAahV5nw8KClXqTF1LhfDry_TsZ4KGow4,20467
89
- ragaai_catalyst/tracers/utils/trace_json_converter.py,sha256=YllXhkfyYOuQ0rsX9VqiUjMUeztDMs8TFMudIPkWvrY,10191
89
+ ragaai_catalyst/tracers/utils/trace_json_converter.py,sha256=FV7oOWJkDQGjD9Td8sFCiCiQWk0tch6qZrTnp1lU6zU,11295
90
90
  ragaai_catalyst/tracers/utils/utils.py,sha256=L19LQGc8h08FFhyptBtixIHGG_e-VdSPsKs7JNaXnGE,2378
91
- ragaai_catalyst-2.2.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
92
- ragaai_catalyst-2.2.2.dist-info/METADATA,sha256=2XcrTsdS1a_QyQyy5qa0dnxSBdKudwn62leYQNx0Udo,17677
93
- ragaai_catalyst-2.2.2.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
94
- ragaai_catalyst-2.2.2.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
95
- ragaai_catalyst-2.2.2.dist-info/RECORD,,
91
+ ragaai_catalyst-2.2.3b0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
92
+ ragaai_catalyst-2.2.3b0.dist-info/METADATA,sha256=D6E3L2zMZWn-IR_4NFDsOgVOKvmGSWo_NUMhY7U84Yw,17679
93
+ ragaai_catalyst-2.2.3b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
94
+ ragaai_catalyst-2.2.3b0.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
95
+ ragaai_catalyst-2.2.3b0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5