ragaai-catalyst 2.2.4b4__py3-none-any.whl → 2.2.5b1__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.
Files changed (46) hide show
  1. ragaai_catalyst/__init__.py +0 -2
  2. ragaai_catalyst/dataset.py +59 -1
  3. ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +1 -22
  4. ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +0 -2
  5. ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py +1 -1
  6. ragaai_catalyst/tracers/exporters/__init__.py +1 -2
  7. ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -1
  8. ragaai_catalyst/tracers/exporters/ragaai_trace_exporter.py +23 -1
  9. ragaai_catalyst/tracers/tracer.py +6 -186
  10. ragaai_catalyst/tracers/utils/trace_json_converter.py +2 -2
  11. {ragaai_catalyst-2.2.4b4.dist-info → ragaai_catalyst-2.2.5b1.dist-info}/METADATA +1 -1
  12. {ragaai_catalyst-2.2.4b4.dist-info → ragaai_catalyst-2.2.5b1.dist-info}/RECORD +15 -46
  13. ragaai_catalyst/experiment.py +0 -486
  14. ragaai_catalyst/tracers/agentic_tracing/tests/FinancialAnalysisSystem.ipynb +0 -536
  15. ragaai_catalyst/tracers/agentic_tracing/tests/GameActivityEventPlanner.ipynb +0 -134
  16. ragaai_catalyst/tracers/agentic_tracing/tests/TravelPlanner.ipynb +0 -563
  17. ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py +0 -0
  18. ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py +0 -197
  19. ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py +0 -172
  20. ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +0 -687
  21. ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +0 -1319
  22. ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +0 -347
  23. ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py +0 -0
  24. ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +0 -1182
  25. ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py +0 -288
  26. ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +0 -557
  27. ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py +0 -129
  28. ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py +0 -74
  29. ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +0 -21
  30. ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +0 -32
  31. ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py +0 -28
  32. ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py +0 -133
  33. ragaai_catalyst/tracers/agentic_tracing/utils/supported_llm_provider.toml +0 -34
  34. ragaai_catalyst/tracers/exporters/raga_exporter.py +0 -467
  35. ragaai_catalyst/tracers/langchain_callback.py +0 -821
  36. ragaai_catalyst/tracers/llamaindex_callback.py +0 -361
  37. ragaai_catalyst/tracers/llamaindex_instrumentation.py +0 -424
  38. ragaai_catalyst/tracers/upload_traces.py +0 -170
  39. ragaai_catalyst/tracers/utils/convert_langchain_callbacks_output.py +0 -62
  40. ragaai_catalyst/tracers/utils/convert_llama_instru_callback.py +0 -69
  41. ragaai_catalyst/tracers/utils/extraction_logic_llama_index.py +0 -74
  42. ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py +0 -82
  43. ragaai_catalyst/tracers/utils/rag_trace_json_converter.py +0 -403
  44. {ragaai_catalyst-2.2.4b4.dist-info → ragaai_catalyst-2.2.5b1.dist-info}/WHEEL +0 -0
  45. {ragaai_catalyst-2.2.4b4.dist-info → ragaai_catalyst-2.2.5b1.dist-info}/licenses/LICENSE +0 -0
  46. {ragaai_catalyst-2.2.4b4.dist-info → ragaai_catalyst-2.2.5b1.dist-info}/top_level.txt +0 -0
@@ -1,288 +0,0 @@
1
- from datetime import datetime
2
- import socket
3
- from http.client import HTTPConnection, HTTPSConnection
4
- import aiohttp
5
- import requests
6
- import urllib
7
- import uuid
8
-
9
-
10
- class NetworkTracer:
11
- def __init__(self):
12
- self.network_calls = []
13
- self.patches_applied = False # Track whether patches are active
14
- # Store original functions for restoration
15
- self._original_urlopen = None
16
- self._original_requests_request = None
17
- self._original_http_request = None
18
- self._original_https_request = None
19
- self._original_socket_create_connection = None
20
-
21
- def record_call(
22
- self,
23
- method,
24
- url,
25
- status_code=None,
26
- error=None,
27
- start_time=None,
28
- end_time=None,
29
- request_headers=None,
30
- response_headers=None,
31
- request_body=None,
32
- response_body=None,
33
- ):
34
- duration = (
35
- (end_time - start_time).total_seconds() if start_time and end_time else None
36
- )
37
-
38
- # Calculate bytes sent/received from headers and body
39
- bytes_sent = len(str(request_headers or "")) + len(str(request_body or ""))
40
- bytes_received = len(str(response_headers or "")) + len(str(response_body or ""))
41
-
42
- # Extract protocol from URL
43
- protocol = "https" if url.startswith("https") else "http"
44
-
45
- self.network_calls.append(
46
- {
47
- "url": url,
48
- "method": method,
49
- "status_code": status_code,
50
- "start_time": start_time.isoformat() if start_time else None,
51
- "end_time": end_time.isoformat() if end_time else None,
52
- "response_time": duration,
53
- "bytes_sent": bytes_sent,
54
- "bytes_received": bytes_received,
55
- "protocol": protocol,
56
- "connection_id": str(uuid.uuid4()), # Generate unique connection ID
57
- "parent_id": None, # Will be set by the component
58
- "request": {
59
- "headers": request_headers,
60
- "body": request_body if request_body else None,
61
- },
62
- "response": {
63
- "headers": response_headers,
64
- "body": response_body if response_body else None,
65
- },
66
- "error": str(error) if error else None,
67
- }
68
- )
69
-
70
- def activate_patches(self):
71
- if not self.patches_applied:
72
- # Apply monkey patches and store originals
73
- self._original_urlopen = monkey_patch_urllib(self)
74
- self._original_requests_request = monkey_patch_requests(self)
75
- self._original_http_request, self._original_https_request = (
76
- monkey_patch_http_client(self)
77
- )
78
- self._original_socket_create_connection = monkey_patch_socket(self)
79
- self.patches_applied = True
80
-
81
- def deactivate_patches(self):
82
- if self.patches_applied:
83
- # Restore original functions
84
- restore_urllib(self._original_urlopen)
85
- restore_requests(self._original_requests_request)
86
- restore_http_client(
87
- self._original_http_request, self._original_https_request
88
- )
89
- restore_socket(self._original_socket_create_connection)
90
- self.network_calls = []
91
- self.patches_applied = False
92
-
93
-
94
- # Define the monkey patch and restore functions
95
- def monkey_patch_urllib(network_tracer):
96
- from urllib.request import urlopen
97
-
98
- original_urlopen = urlopen
99
-
100
- def patched_urlopen(url, data=None, timeout=None, *args, **kwargs):
101
- if isinstance(url, str):
102
- method = "GET" if data is None else "POST"
103
- url_str = url
104
- else:
105
- method = url.get_method()
106
- url_str = url.full_url
107
-
108
- start_time = datetime.now().astimezone()
109
- try:
110
- response = original_urlopen(url, data, timeout, *args, **kwargs)
111
- end_time = datetime.now().astimezone()
112
- network_tracer.record_call(
113
- method=method,
114
- url=url_str,
115
- status_code=response.status,
116
- start_time=start_time,
117
- end_time=end_time,
118
- request_headers=dict(response.request.headers),
119
- response_headers=dict(response.headers),
120
- request_body=data,
121
- response_body=response.read().decode("utf-8", errors="ignore"),
122
- )
123
- return response
124
- except Exception as e:
125
- end_time = datetime.now().astimezone()
126
- network_tracer.record_call(
127
- method=method,
128
- url=url_str,
129
- error=e,
130
- start_time=start_time,
131
- end_time=end_time,
132
- )
133
- raise
134
-
135
- urllib.request.urlopen = patched_urlopen
136
- return original_urlopen # Return the original function
137
-
138
-
139
- def restore_urllib(original_urlopen):
140
- urllib.request.urlopen = original_urlopen
141
-
142
-
143
- def monkey_patch_requests(network_tracer):
144
- original_request = requests.Session.request
145
-
146
- def patched_request(self, method, url, *args, **kwargs):
147
- start_time = datetime.now().astimezone()
148
- try:
149
- response = original_request(self, method, url, *args, **kwargs)
150
- end_time = datetime.now().astimezone()
151
- network_tracer.record_call(
152
- method=method,
153
- url=url,
154
- status_code=response.status_code,
155
- start_time=start_time,
156
- end_time=end_time,
157
- request_headers=dict(response.request.headers),
158
- response_headers=dict(response.headers),
159
- request_body=kwargs.get("data") or kwargs.get("json"),
160
- response_body=response.text,
161
- )
162
- return response
163
- except Exception as e:
164
- end_time = datetime.now().astimezone()
165
- network_tracer.record_call(
166
- method=method,
167
- url=url,
168
- error=e,
169
- start_time=start_time,
170
- end_time=end_time,
171
- )
172
- raise
173
-
174
- requests.Session.request = patched_request
175
- return original_request
176
-
177
-
178
- def restore_requests(original_request):
179
- requests.Session.request = original_request
180
-
181
-
182
- def monkey_patch_http_client(network_tracer):
183
- original_http_request = HTTPConnection.request
184
- original_https_request = HTTPSConnection.request
185
-
186
- def patched_request(self, method, url, body=None, headers=None, *args, **kwargs):
187
- start_time = datetime.now().astimezone()
188
- try:
189
- result = (
190
- original_http_request(self, method, url, body, headers, *args, **kwargs)
191
- if isinstance(self, HTTPConnection)
192
- else original_https_request(
193
- self, method, url, body, headers, *args, **kwargs
194
- )
195
- )
196
- response = self.getresponse()
197
- end_time = datetime.now().astimezone()
198
- network_tracer.record_call(
199
- method=method,
200
- url=f"{self._http_vsn_str} {self.host}:{self.port}{url}",
201
- status_code=response.status,
202
- start_time=start_time,
203
- end_time=end_time,
204
- request_headers=headers,
205
- response_headers=dict(response.headers),
206
- request_body=body,
207
- response_body=response.read().decode("utf-8", errors="ignore"),
208
- )
209
- return result
210
- except Exception as e:
211
- end_time = datetime.now().astimezone()
212
- network_tracer.record_call(
213
- method=method,
214
- url=f"{self._http_vsn_str} {self.host}:{self.port}{url}",
215
- error=e,
216
- start_time=start_time,
217
- end_time=end_time,
218
- )
219
- raise
220
-
221
- HTTPConnection.request = patched_request
222
- HTTPSConnection.request = patched_request
223
- return original_http_request, original_https_request
224
-
225
-
226
- def restore_http_client(original_http_request, original_https_request):
227
- HTTPConnection.request = original_http_request
228
- HTTPSConnection.request = original_https_request
229
-
230
-
231
- def monkey_patch_socket(network_tracer):
232
- original_create_connection = socket.create_connection
233
-
234
- def patched_create_connection(address, *args, **kwargs):
235
- host, port = address
236
- start_time = datetime.now().astimezone()
237
- try:
238
- result = original_create_connection(address, *args, **kwargs)
239
- end_time = datetime.now().astimezone()
240
- network_tracer.record_call(
241
- method="CONNECT",
242
- url=f"{host}:{port}",
243
- start_time=start_time,
244
- end_time=end_time,
245
- )
246
- return result
247
- except Exception as e:
248
- end_time = datetime.now().astimezone()
249
- network_tracer.record_call(
250
- method="CONNECT",
251
- url=f"{host}:{port}",
252
- error=e,
253
- start_time=start_time,
254
- end_time=end_time,
255
- )
256
- raise
257
-
258
- socket.create_connection = patched_create_connection
259
- return original_create_connection
260
-
261
-
262
- def restore_socket(original_create_connection):
263
- socket.create_connection = original_create_connection
264
-
265
-
266
- async def patch_aiohttp_trace_config(network_tracer):
267
- async def on_request_start(session, trace_config_ctx, params):
268
- trace_config_ctx.start = datetime.now().astimezone()
269
-
270
- async def on_request_end(session, trace_config_ctx, params):
271
- end_time = datetime.now().astimezone()
272
- response = params.response
273
- network_tracer.record_call(
274
- method=params.method,
275
- url=str(params.url),
276
- status_code=response.status,
277
- start_time=trace_config_ctx.start,
278
- end_time=end_time,
279
- request_headers=dict(params.headers),
280
- response_headers=dict(response.headers),
281
- request_body=await params.response.text(),
282
- response_body=await response.text(),
283
- )
284
-
285
- trace_config = aiohttp.TraceConfig()
286
- trace_config.on_request_start.append(on_request_start)
287
- trace_config.on_request_end.append(on_request_end)
288
- return trace_config