ragaai-catalyst 2.1b5__py3-none-any.whl → 2.1.1__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.
- ragaai_catalyst/tracers/agentic_tracing/README.md +97 -0
- ragaai_catalyst/tracers/agentic_tracing/__init__.py +4 -2
- ragaai_catalyst/tracers/agentic_tracing/data/__init__.py +0 -0
- ragaai_catalyst/tracers/agentic_tracing/{data_structure.py → data/data_structure.py} +14 -1
- ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py +0 -0
- ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py +0 -0
- ragaai_catalyst/tracers/agentic_tracing/{agent_tracer.py → tracers/agent_tracer.py} +15 -10
- ragaai_catalyst/tracers/agentic_tracing/{base.py → tracers/base.py} +5 -6
- ragaai_catalyst/tracers/agentic_tracing/{llm_tracer.py → tracers/llm_tracer.py} +36 -249
- ragaai_catalyst/tracers/agentic_tracing/{agentic_tracing.py → tracers/main_tracer.py} +41 -8
- ragaai_catalyst/tracers/agentic_tracing/{tool_tracer.py → tracers/tool_tracer.py} +3 -3
- ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py +0 -0
- ragaai_catalyst/tracers/agentic_tracing/{upload_agentic_traces.py → upload/upload_agentic_traces.py} +3 -0
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +229 -43
- ragaai_catalyst/tracers/tracer.py +11 -12
- {ragaai_catalyst-2.1b5.dist-info → ragaai_catalyst-2.1.1.dist-info}/METADATA +5 -5
- ragaai_catalyst-2.1.1.dist-info/RECORD +60 -0
- {ragaai_catalyst-2.1b5.dist-info → ragaai_catalyst-2.1.1.dist-info}/WHEEL +1 -1
- ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py +0 -61
- ragaai_catalyst-2.1b5.dist-info/RECORD +0 -56
- /ragaai_catalyst/tracers/agentic_tracing/{examples → tests}/FinancialAnalysisSystem.ipynb +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{examples → tests}/GameActivityEventPlanner.ipynb +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{examples → tests}/TravelPlanner.ipynb +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{sample.py → tests/ai_travel_agent.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{unique_decorator_test.py → tests/unique_decorator_test.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{network_tracer.py → tracers/network_tracer.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{user_interaction_tracer.py → tracers/user_interaction_tracer.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{upload_code.py → upload/upload_code.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{file_name_tracker.py → utils/file_name_tracker.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{unique_decorator.py → utils/unique_decorator.py} +0 -0
- /ragaai_catalyst/tracers/agentic_tracing/{zip_list_of_unique_files.py → utils/zip_list_of_unique_files.py} +0 -0
- {ragaai_catalyst-2.1b5.dist-info → ragaai_catalyst-2.1.1.dist-info}/top_level.txt +0 -0
@@ -14,7 +14,7 @@ from .agent_tracer import AgentTracerMixin
|
|
14
14
|
from .network_tracer import NetworkTracer
|
15
15
|
from .user_interaction_tracer import UserInteractionTracer
|
16
16
|
|
17
|
-
from .data_structure import (
|
17
|
+
from ..data.data_structure import (
|
18
18
|
Trace, Metadata, SystemInfo, OSInfo, EnvironmentInfo,
|
19
19
|
Resources, CPUResource, MemoryResource, DiskResource, NetworkResource,
|
20
20
|
ResourceInfo, MemoryInfo, DiskInfo, NetworkInfo,
|
@@ -22,9 +22,8 @@ from .data_structure import (
|
|
22
22
|
NetworkCall, Interaction, Error
|
23
23
|
)
|
24
24
|
|
25
|
-
|
26
|
-
from
|
27
|
-
from ..upload_traces import UploadTraces
|
25
|
+
from ....ragaai_catalyst import RagaAICatalyst
|
26
|
+
from ragaai_catalyst.tracers.upload_traces import UploadTraces
|
28
27
|
|
29
28
|
class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMixin):
|
30
29
|
def __init__(self, user_detail, auto_instrument_llm: bool = True):
|
@@ -164,12 +163,11 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
|
|
164
163
|
self.trace.metadata.total_cost = total_cost
|
165
164
|
self.trace.metadata.total_tokens = total_tokens
|
166
165
|
|
167
|
-
def add_component(self, component_data: dict):
|
166
|
+
def add_component(self, component_data: dict, is_error: bool = False):
|
168
167
|
"""Add a component to the trace data"""
|
169
168
|
# Convert dict to appropriate Component type
|
170
169
|
filtered_data = {k: v for k, v in component_data.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}
|
171
170
|
|
172
|
-
|
173
171
|
if component_data["type"] == "llm":
|
174
172
|
component = LLMComponent(**filtered_data)
|
175
173
|
elif component_data["type"] == "agent":
|
@@ -179,8 +177,6 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
|
|
179
177
|
else:
|
180
178
|
component = Component(**component_data)
|
181
179
|
|
182
|
-
# import pdb; pdb.set_trace()
|
183
|
-
|
184
180
|
# Check if there's an active agent context
|
185
181
|
current_agent_id = self.current_agent_id.get()
|
186
182
|
if current_agent_id and component_data["type"] in ["llm", "tool"]:
|
@@ -191,6 +187,43 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
|
|
191
187
|
else:
|
192
188
|
# Add component to the main trace
|
193
189
|
super().add_component(component)
|
190
|
+
|
191
|
+
# Handle error case
|
192
|
+
if is_error:
|
193
|
+
# Get the parent component if it exists
|
194
|
+
parent_id = component_data.get("parent_id")
|
195
|
+
children = self.agent_children.get()
|
196
|
+
|
197
|
+
# Set parent_id for all children
|
198
|
+
for child in children:
|
199
|
+
child["parent_id"] = parent_id
|
200
|
+
|
201
|
+
agent_tracer_mixin = AgentTracerMixin()
|
202
|
+
agent_tracer_mixin.component_network_calls = self.component_network_calls
|
203
|
+
agent_tracer_mixin.component_user_interaction = self.component_user_interaction
|
204
|
+
|
205
|
+
# Create parent component with error info
|
206
|
+
parent_component = agent_tracer_mixin.create_agent_component(
|
207
|
+
component_id=parent_id,
|
208
|
+
hash_id=str(uuid.uuid4()),
|
209
|
+
name=self.current_agent_name.get(),
|
210
|
+
agent_type=self.agent_type.get(),
|
211
|
+
version=self.version.get(),
|
212
|
+
capabilities=self.capabilities.get(),
|
213
|
+
start_time=self.start_time,
|
214
|
+
end_time=datetime.now(),
|
215
|
+
memory_used=0,
|
216
|
+
input_data=self.input_data,
|
217
|
+
output_data=None,
|
218
|
+
children=children,
|
219
|
+
parent_id=None # Add parent ID if exists
|
220
|
+
)
|
221
|
+
|
222
|
+
filtered_data = {k: v for k, v in parent_component.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}
|
223
|
+
parent_agent_component = AgentComponent(**filtered_data)
|
224
|
+
# Add the parent component to trace and stop tracing
|
225
|
+
super().add_component(parent_agent_component)
|
226
|
+
self.stop()
|
194
227
|
|
195
228
|
def __enter__(self):
|
196
229
|
"""Context manager entry"""
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import functools
|
2
1
|
import uuid
|
3
2
|
from datetime import datetime
|
4
3
|
import psutil
|
4
|
+
import functools
|
5
5
|
from typing import Optional, Any, Dict, List
|
6
|
-
from .unique_decorator import generate_unique_hash_simple
|
6
|
+
from ..utils.unique_decorator import generate_unique_hash_simple, mydecorator
|
7
7
|
import contextvars
|
8
8
|
import asyncio
|
9
|
-
from .file_name_tracker import TrackName
|
9
|
+
from ..utils.file_name_tracker import TrackName
|
10
10
|
|
11
11
|
|
12
12
|
class ToolTracerMixin:
|
File without changes
|
ragaai_catalyst/tracers/agentic_tracing/{upload_agentic_traces.py → upload/upload_agentic_traces.py}
RENAMED
@@ -131,6 +131,9 @@ class UploadAgenticTraces:
|
|
131
131
|
headers=headers,
|
132
132
|
data=payload,
|
133
133
|
timeout=self.timeout)
|
134
|
+
if response.status_code != 200:
|
135
|
+
print(f"Error inserting traces: {response.json()['message']}")
|
136
|
+
return None
|
134
137
|
except requests.exceptions.RequestException as e:
|
135
138
|
print(f"Error while inserting traces: {e}")
|
136
139
|
return None
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from .
|
1
|
+
from ..data.data_structure import LLMCall
|
2
2
|
from .trace_utils import (
|
3
3
|
calculate_cost,
|
4
4
|
convert_usage_to_dict,
|
@@ -7,22 +7,237 @@ from .trace_utils import (
|
|
7
7
|
from importlib import resources
|
8
8
|
import json
|
9
9
|
import os
|
10
|
+
import asyncio
|
11
|
+
import psutil
|
10
12
|
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def extract_model_name(args, kwargs, result):
|
15
|
+
"""Extract model name from kwargs or result"""
|
16
|
+
# First try direct model parameter
|
17
|
+
model = kwargs.get("model", "")
|
18
|
+
|
19
|
+
if not model:
|
20
|
+
# Try to get from instance
|
21
|
+
instance = kwargs.get("self", None)
|
22
|
+
if instance:
|
23
|
+
# Try model_name first (Google format)
|
24
|
+
if hasattr(instance, "model_name"):
|
25
|
+
model = instance.model_name
|
26
|
+
# Try model attribute
|
27
|
+
elif hasattr(instance, "model"):
|
28
|
+
model = instance.model
|
29
|
+
|
30
|
+
# Normalize Google model names
|
31
|
+
if model and isinstance(model, str):
|
32
|
+
model = model.lower()
|
33
|
+
if "gemini-1.5-flash" in model:
|
34
|
+
return "gemini-1.5-flash"
|
35
|
+
if "gemini-1.5-pro" in model:
|
36
|
+
return "gemini-1.5-pro"
|
37
|
+
if "gemini-pro" in model:
|
38
|
+
return "gemini-pro"
|
22
39
|
|
40
|
+
if 'to_dict' in dir(result):
|
41
|
+
result = result.to_dict()
|
42
|
+
if 'model_version' in result:
|
43
|
+
model = result['model_version']
|
44
|
+
|
45
|
+
return model or "default"
|
46
|
+
|
47
|
+
|
48
|
+
def extract_parameters(kwargs):
|
49
|
+
"""Extract all non-null parameters from kwargs"""
|
50
|
+
parameters = {k: v for k, v in kwargs.items() if v is not None}
|
51
|
+
|
52
|
+
# Remove contents key in parameters (Google LLM Response)
|
53
|
+
if 'contents' in parameters:
|
54
|
+
del parameters['contents']
|
55
|
+
|
56
|
+
# Remove messages key in parameters (OpenAI message)
|
57
|
+
if 'messages' in parameters:
|
58
|
+
del parameters['messages']
|
59
|
+
|
60
|
+
if 'generation_config' in parameters:
|
61
|
+
generation_config = parameters['generation_config']
|
62
|
+
# If generation_config is already a dict, use it directly
|
63
|
+
if isinstance(generation_config, dict):
|
64
|
+
config_dict = generation_config
|
65
|
+
else:
|
66
|
+
# Convert GenerationConfig to dictionary if it has a to_dict method, otherwise try to get its __dict__
|
67
|
+
config_dict = getattr(generation_config, 'to_dict', lambda: generation_config.__dict__)()
|
68
|
+
parameters.update(config_dict)
|
69
|
+
del parameters['generation_config']
|
70
|
+
|
71
|
+
return parameters
|
72
|
+
|
73
|
+
|
74
|
+
def extract_token_usage(result):
|
75
|
+
"""Extract token usage from result"""
|
76
|
+
# Handle coroutines
|
77
|
+
if asyncio.iscoroutine(result):
|
78
|
+
# Get the current event loop
|
79
|
+
loop = asyncio.get_event_loop()
|
80
|
+
# Run the coroutine in the current event loop
|
81
|
+
result = loop.run_until_complete(result)
|
82
|
+
|
83
|
+
# Handle standard OpenAI/Anthropic format
|
84
|
+
if hasattr(result, "usage"):
|
85
|
+
usage = result.usage
|
86
|
+
return {
|
87
|
+
"prompt_tokens": getattr(usage, "prompt_tokens", 0),
|
88
|
+
"completion_tokens": getattr(usage, "completion_tokens", 0),
|
89
|
+
"total_tokens": getattr(usage, "total_tokens", 0)
|
90
|
+
}
|
91
|
+
|
92
|
+
# Handle Google GenerativeAI format with usage_metadata
|
93
|
+
if hasattr(result, "usage_metadata"):
|
94
|
+
metadata = result.usage_metadata
|
95
|
+
return {
|
96
|
+
"prompt_tokens": getattr(metadata, "prompt_token_count", 0),
|
97
|
+
"completion_tokens": getattr(metadata, "candidates_token_count", 0),
|
98
|
+
"total_tokens": getattr(metadata, "total_token_count", 0)
|
99
|
+
}
|
100
|
+
|
101
|
+
# Handle Vertex AI format
|
102
|
+
if hasattr(result, "text"):
|
103
|
+
# For LangChain ChatVertexAI
|
104
|
+
total_tokens = getattr(result, "token_count", 0)
|
105
|
+
if not total_tokens and hasattr(result, "_raw_response"):
|
106
|
+
# Try to get from raw response
|
107
|
+
total_tokens = getattr(result._raw_response, "token_count", 0)
|
108
|
+
return {
|
109
|
+
"prompt_tokens": 0, # Vertex AI doesn't provide this breakdown
|
110
|
+
"completion_tokens": total_tokens,
|
111
|
+
"total_tokens": total_tokens
|
112
|
+
}
|
113
|
+
|
114
|
+
return {
|
115
|
+
"prompt_tokens": 0,
|
116
|
+
"completion_tokens": 0,
|
117
|
+
"total_tokens": 0
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
def extract_input_data(args, kwargs, result):
|
122
|
+
"""Extract input data from function call"""
|
123
|
+
return {
|
124
|
+
'args': args,
|
125
|
+
'kwargs': kwargs
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
def calculate_llm_cost(token_usage, model_name, model_costs):
|
130
|
+
"""Calculate cost based on token usage and model"""
|
131
|
+
if not isinstance(token_usage, dict):
|
132
|
+
token_usage = {
|
133
|
+
"prompt_tokens": 0,
|
134
|
+
"completion_tokens": 0,
|
135
|
+
"total_tokens": token_usage if isinstance(token_usage, (int, float)) else 0
|
136
|
+
}
|
137
|
+
|
138
|
+
# Get model costs, defaulting to default costs if unknown
|
139
|
+
model_cost = model_costs.get(model_name, {
|
140
|
+
"input_cost_per_token": 0.0,
|
141
|
+
"output_cost_per_token": 0.0
|
142
|
+
})
|
143
|
+
|
144
|
+
input_cost = (token_usage.get("prompt_tokens", 0)) * model_cost.get("input_cost_per_token", 0.0)
|
145
|
+
output_cost = (token_usage.get("completion_tokens", 0)) * model_cost.get("output_cost_per_token", 0.0)
|
146
|
+
total_cost = input_cost + output_cost
|
147
|
+
|
148
|
+
return {
|
149
|
+
"input_cost": round(input_cost, 10),
|
150
|
+
"output_cost": round(output_cost, 10),
|
151
|
+
"total_cost": round(total_cost, 10)
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
def sanitize_api_keys(data):
|
156
|
+
"""Remove sensitive information from data"""
|
157
|
+
if isinstance(data, dict):
|
158
|
+
return {k: sanitize_api_keys(v) for k, v in data.items()
|
159
|
+
if not any(sensitive in k.lower() for sensitive in ['key', 'token', 'secret', 'password'])}
|
160
|
+
elif isinstance(data, list):
|
161
|
+
return [sanitize_api_keys(item) for item in data]
|
162
|
+
elif isinstance(data, tuple):
|
163
|
+
return tuple(sanitize_api_keys(item) for item in data)
|
164
|
+
return data
|
165
|
+
|
166
|
+
|
167
|
+
def sanitize_input(args, kwargs):
|
168
|
+
"""Convert input arguments to text format.
|
169
|
+
|
170
|
+
Args:
|
171
|
+
args: Input arguments that may contain nested dictionaries
|
172
|
+
|
173
|
+
Returns:
|
174
|
+
str: Text representation of the input arguments
|
175
|
+
"""
|
176
|
+
if isinstance(args, dict):
|
177
|
+
return str({k: sanitize_input(v, {}) for k, v in args.items()})
|
178
|
+
elif isinstance(args, (list, tuple)):
|
179
|
+
return str([sanitize_input(item, {}) for item in args])
|
180
|
+
return str(args)
|
23
181
|
|
24
182
|
|
25
183
|
def extract_llm_output(result):
|
184
|
+
"""Extract output from LLM response"""
|
185
|
+
class OutputResponse:
|
186
|
+
def __init__(self, output_response):
|
187
|
+
self.output_response = output_response
|
188
|
+
|
189
|
+
# Handle coroutines
|
190
|
+
if asyncio.iscoroutine(result):
|
191
|
+
# For sync context, run the coroutine
|
192
|
+
if not asyncio.get_event_loop().is_running():
|
193
|
+
result = asyncio.run(result)
|
194
|
+
else:
|
195
|
+
# We're in an async context, but this function is called synchronously
|
196
|
+
# Return a placeholder and let the caller handle the coroutine
|
197
|
+
return OutputResponse("Coroutine result pending")
|
198
|
+
|
199
|
+
# Handle Google GenerativeAI format
|
200
|
+
if hasattr(result, "result"):
|
201
|
+
candidates = getattr(result.result, "candidates", [])
|
202
|
+
output = []
|
203
|
+
for candidate in candidates:
|
204
|
+
content = getattr(candidate, "content", None)
|
205
|
+
if content and hasattr(content, "parts"):
|
206
|
+
for part in content.parts:
|
207
|
+
if hasattr(part, "text"):
|
208
|
+
output.append({
|
209
|
+
"content": part.text,
|
210
|
+
"role": getattr(content, "role", "assistant"),
|
211
|
+
"finish_reason": getattr(candidate, "finish_reason", None)
|
212
|
+
})
|
213
|
+
return OutputResponse(output)
|
214
|
+
|
215
|
+
# Handle Vertex AI format
|
216
|
+
if hasattr(result, "text"):
|
217
|
+
return OutputResponse([{
|
218
|
+
"content": result.text,
|
219
|
+
"role": "assistant"
|
220
|
+
}])
|
221
|
+
|
222
|
+
# Handle OpenAI format
|
223
|
+
if hasattr(result, "choices"):
|
224
|
+
return OutputResponse([{
|
225
|
+
"content": choice.message.content,
|
226
|
+
"role": choice.message.role
|
227
|
+
} for choice in result.choices])
|
228
|
+
|
229
|
+
# Handle Anthropic format
|
230
|
+
if hasattr(result, "completion"):
|
231
|
+
return OutputResponse([{
|
232
|
+
"content": result.completion,
|
233
|
+
"role": "assistant"
|
234
|
+
}])
|
235
|
+
|
236
|
+
# Default case
|
237
|
+
return OutputResponse(str(result))
|
238
|
+
|
239
|
+
|
240
|
+
def extract_llm_data(args, kwargs, result):
|
26
241
|
# Initialize variables
|
27
242
|
model_name = None
|
28
243
|
output_response = ""
|
@@ -32,15 +247,7 @@ def extract_llm_output(result):
|
|
32
247
|
cost = {}
|
33
248
|
|
34
249
|
# Try to get model_name from result or result.content
|
35
|
-
model_name =
|
36
|
-
if hasattr(result, "model"):
|
37
|
-
model_name = result.model
|
38
|
-
elif hasattr(result, "content"):
|
39
|
-
try:
|
40
|
-
content_dict = json.loads(result.content)
|
41
|
-
model_name = content_dict.get("model", None)
|
42
|
-
except (json.JSONDecodeError, TypeError):
|
43
|
-
model_name = None
|
250
|
+
model_name = extract_model_name(args, kwargs, result)
|
44
251
|
|
45
252
|
# Try to get choices from result or result.content
|
46
253
|
choices = None
|
@@ -136,34 +343,13 @@ def extract_llm_output(result):
|
|
136
343
|
else:
|
137
344
|
usage = {}
|
138
345
|
|
139
|
-
token_usage =
|
346
|
+
token_usage = extract_token_usage(result)
|
140
347
|
|
141
348
|
# Load model costs
|
142
349
|
model_costs = load_model_costs()
|
143
350
|
|
144
351
|
# Calculate cost
|
145
|
-
|
146
|
-
model_config = model_costs[model_name]
|
147
|
-
input_cost_per_token = model_config.get("input_cost_per_token", 0.0)
|
148
|
-
output_cost_per_token = model_config.get("output_cost_per_token", 0.0)
|
149
|
-
reasoning_cost_per_token = model_config.get(
|
150
|
-
"reasoning_cost_per_token", output_cost_per_token
|
151
|
-
)
|
152
|
-
else:
|
153
|
-
# Default costs or log a warning
|
154
|
-
print(
|
155
|
-
f"Warning: Model '{model_name}' not found in config. Using default costs."
|
156
|
-
)
|
157
|
-
input_cost_per_token = 0.0
|
158
|
-
output_cost_per_token = 0.0
|
159
|
-
reasoning_cost_per_token = 0.0
|
160
|
-
|
161
|
-
cost = calculate_cost(
|
162
|
-
token_usage,
|
163
|
-
input_cost_per_token=input_cost_per_token,
|
164
|
-
output_cost_per_token=output_cost_per_token,
|
165
|
-
reasoning_cost_per_token=reasoning_cost_per_token,
|
166
|
-
)
|
352
|
+
cost = calculate_llm_cost(token_usage, model_name, model_costs)
|
167
353
|
|
168
354
|
llm_data = LLMCall(
|
169
355
|
name="",
|
@@ -9,19 +9,18 @@ from concurrent.futures import ThreadPoolExecutor
|
|
9
9
|
|
10
10
|
from opentelemetry.sdk import trace as trace_sdk
|
11
11
|
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
12
|
-
from .exporters.file_span_exporter import FileSpanExporter
|
13
|
-
from .exporters.raga_exporter import RagaExporter
|
14
|
-
from .instrumentators import (
|
12
|
+
from ragaai_catalyst.tracers.exporters.file_span_exporter import FileSpanExporter
|
13
|
+
from ragaai_catalyst.tracers.exporters.raga_exporter import RagaExporter
|
14
|
+
from ragaai_catalyst.tracers.instrumentators import (
|
15
15
|
LangchainInstrumentor,
|
16
16
|
OpenAIInstrumentor,
|
17
17
|
LlamaIndexInstrumentor,
|
18
18
|
)
|
19
|
-
from .utils import get_unique_key
|
20
|
-
# from .llamaindex_callback import LlamaIndexTracer
|
21
|
-
from
|
22
|
-
from .
|
23
|
-
from .agentic_tracing.
|
24
|
-
from .agentic_tracing.llm_tracer import LLMTracerMixin
|
19
|
+
from ragaai_catalyst.tracers.utils import get_unique_key
|
20
|
+
# from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
21
|
+
from ragaai_catalyst import RagaAICatalyst
|
22
|
+
from ragaai_catalyst.tracers.agentic_tracing import AgenticTracing, TrackName
|
23
|
+
from ragaai_catalyst.tracers.agentic_tracing.tracers.llm_tracer import LLMTracerMixin
|
25
24
|
|
26
25
|
logger = logging.getLogger(__name__)
|
27
26
|
|
@@ -114,7 +113,7 @@ class Tracer(AgenticTracing):
|
|
114
113
|
self._upload_task = None
|
115
114
|
elif tracer_type == "llamaindex":
|
116
115
|
self._upload_task = None
|
117
|
-
from .llamaindex_callback import LlamaIndexTracer
|
116
|
+
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
118
117
|
|
119
118
|
else:
|
120
119
|
self._upload_task = None
|
@@ -176,7 +175,7 @@ class Tracer(AgenticTracing):
|
|
176
175
|
print(f"Tracer started for project: {self.project_name}")
|
177
176
|
return self
|
178
177
|
elif self.tracer_type == "llamaindex":
|
179
|
-
from .llamaindex_callback import LlamaIndexTracer
|
178
|
+
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
180
179
|
return LlamaIndexTracer(self._pass_user_data()).start()
|
181
180
|
else:
|
182
181
|
super().start()
|
@@ -194,7 +193,7 @@ class Tracer(AgenticTracing):
|
|
194
193
|
self._upload_task = self._run_async(self._upload_traces())
|
195
194
|
return "Trace upload initiated. Use get_upload_status() to check the status."
|
196
195
|
elif self.tracer_type == "llamaindex":
|
197
|
-
from .llamaindex_callback import LlamaIndexTracer
|
196
|
+
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
198
197
|
return LlamaIndexTracer(self._pass_user_data()).stop()
|
199
198
|
else:
|
200
199
|
super().stop()
|
@@ -1,9 +1,9 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.1.1
|
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>
|
6
|
-
Requires-Python:
|
6
|
+
Requires-Python: <3.13,>=3.9
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
Requires-Dist: aiohttp>=3.10.2
|
9
9
|
Requires-Dist: opentelemetry-api==1.25.0
|
@@ -19,7 +19,7 @@ Requires-Dist: opentelemetry-instrumentation-openai~=0.24.0
|
|
19
19
|
Requires-Dist: langchain-core>=0.2.11
|
20
20
|
Requires-Dist: langchain>=0.2.11
|
21
21
|
Requires-Dist: openai>=1.57.0
|
22
|
-
Requires-Dist: pandas
|
22
|
+
Requires-Dist: pandas
|
23
23
|
Requires-Dist: groq>=0.11.0
|
24
24
|
Requires-Dist: PyPDF2>=3.0.1
|
25
25
|
Requires-Dist: google-generativeai>=0.8.2
|
@@ -27,7 +27,7 @@ Requires-Dist: Markdown>=3.7
|
|
27
27
|
Requires-Dist: litellm==1.51.1
|
28
28
|
Requires-Dist: tenacity==8.3.0
|
29
29
|
Requires-Dist: tqdm>=4.66.5
|
30
|
-
Requires-Dist: llama-index
|
30
|
+
Requires-Dist: llama-index<0.11.0,>=0.10.0
|
31
31
|
Requires-Dist: pyopenssl>=24.2.1
|
32
32
|
Requires-Dist: psutil~=6.0.0
|
33
33
|
Requires-Dist: py-cpuinfo~=9.0.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
ragaai_catalyst/__init__.py,sha256=BdIJ_UUre0uEnRTsLw_hE0C0muWk6XWNZqdVOel22R4,537
|
2
|
+
ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
|
3
|
+
ragaai_catalyst/dataset.py,sha256=On-iOhD5R7iLusph6dLAGS1dOnNtb1koiKxKjTH90pE,10660
|
4
|
+
ragaai_catalyst/evaluation.py,sha256=34H2bYZNSrcu0jMQgDZw1OLVbQU80PaVLo2avju8POM,20311
|
5
|
+
ragaai_catalyst/experiment.py,sha256=8KvqgJg5JVnt9ghhGDJvdb4mN7ETBX_E5gNxBT0Nsn8,19010
|
6
|
+
ragaai_catalyst/guard_executor.py,sha256=llPbE3DyVtrybojXknzBZj8-dtUrGBQwi9-ZiPJxGRo,3762
|
7
|
+
ragaai_catalyst/guardrails_manager.py,sha256=DILMOAASK57FH9BLq_8yC1AQzRJ8McMFLwCXgYwNAd4,11904
|
8
|
+
ragaai_catalyst/internal_api_completion.py,sha256=DdICI5yfEudiOAIC8L4oxH0Qz7kX-BZCdo9IWsi2gNo,2965
|
9
|
+
ragaai_catalyst/prompt_manager.py,sha256=W8ypramzOprrJ7-22d5vkBXIuIQ8v9XAzKDGxKsTK28,16550
|
10
|
+
ragaai_catalyst/proxy_call.py,sha256=CHxldeceZUaLU-to_hs_Kf1z_b2vHMssLS_cOBedu78,5499
|
11
|
+
ragaai_catalyst/ragaai_catalyst.py,sha256=FdqMzwuQLqS2-3JJDsTQ8uh2itllOxfPrRUjb8Kwmn0,17428
|
12
|
+
ragaai_catalyst/synthetic_data_generation.py,sha256=uDV9tNwto2xSkWg5XHXUvjErW-4P34CTrxaJpRfezyA,19250
|
13
|
+
ragaai_catalyst/utils.py,sha256=TlhEFwLyRU690HvANbyoRycR3nQ67lxVUQoUOfTPYQ0,3772
|
14
|
+
ragaai_catalyst/tracers/__init__.py,sha256=yxepo7iVjTNI_wFdk3Z6Ghu64SazVyszCPEHYrX5WQk,50
|
15
|
+
ragaai_catalyst/tracers/llamaindex_callback.py,sha256=vPE7MieKjfwLrLUnnPs20Df0xNYqoCCj-Mt2NbiuiKU,14023
|
16
|
+
ragaai_catalyst/tracers/tracer.py,sha256=ecr90nRvd6iHRc9HaVm79HM0fB875QwS6YNh6HHSCD8,12637
|
17
|
+
ragaai_catalyst/tracers/upload_traces.py,sha256=hs0PEmit3n3_uUqrdbwcBdyK5Nbkik3JQVwJMEwYTd4,4796
|
18
|
+
ragaai_catalyst/tracers/agentic_tracing/README.md,sha256=X4QwLb7-Jg7GQMIXj-SerZIgDETfw-7VgYlczOR8ZeQ,4508
|
19
|
+
ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=yf6SKvOPSpH-9LiKaoLKXwqj5sez8F_5wkOb91yp0oE,260
|
20
|
+
ragaai_catalyst/tracers/agentic_tracing/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
+
ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py,sha256=fv1h5IvVZDj7IYrozW2NL9tdoL2CWWWOPey_LTduNuI,7708
|
22
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/FinancialAnalysisSystem.ipynb,sha256=0qZxjWqYCTAVvdo3Tsp544D8Am48wfeMQ9RKpKgAL8g,34291
|
23
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/GameActivityEventPlanner.ipynb,sha256=QCMFJYbGX0fd9eMW4PqyQLZjyWuTXo7n1nqO_hMLf0s,4225
|
24
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/TravelPlanner.ipynb,sha256=fU3inXoemJbdTkGAQl_N1UwVEZ10LrKv4gCEpbQ4ISg,43481
|
25
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py,sha256=S4rCcKzU_5SB62BYEbNn_1VbbTdG4396N8rdZ3ZNGcE,5654
|
27
|
+
ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
|
28
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=_9yGrHLw9TnKkYaNkWHQaLFQgsi945CClDTpf6JhINk,21372
|
30
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=lxr62VIbULd9vqCT30nvuWfokvbm7LLWlsu84m0YQfk,14043
|
31
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=uAoUm2NyFL27FF6YExtNiXSYVRHTS1YpqmLHu6_eolE,23983
|
32
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=urY3AWI01JAlGe2rjg-K0EV0CFHti4_SUOAXp23ROk4,10246
|
33
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=6FTA15xMnum9omM_0Jd9cMIuWdKu1gR5Tc8fOXAkP8E,10068
|
34
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=RuxmiOT8DUzpy5oFNjImQDNjYDQ0kJO3Jkv-S1RukEE,8788
|
35
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha256=wsCwTK7tM_L3mdNrcg5Mq3D1k07XCHZkhOB26kz_rLY,1472
|
36
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/upload_agentic_traces.py,sha256=2Ab8odZXMpYFTh8a7tO53qx9RptF-xxyfgtFN0A6GzI,7690
|
38
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/upload_code.py,sha256=u9bRWcM5oDezJupEQoHUXrKz7YvZJK9IZf10ejBWoa4,4254
|
39
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py,sha256=XdB3X_ufe4RVvGorxSqAiB9dYv4UD7Hvvuw3bsDUppY,60
|
40
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py,sha256=JyNCbfpW-w4O9CjtemTqmor2Rh1WGpQwhRaDSRmBxw8,689
|
41
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py,sha256=515NNDQJTyy3O-2rdlUYUoWL9qSwLIfvV3sMB9BtHp8,1366
|
42
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/generic.py,sha256=WwXT01xmp8MSr7KinuDCSK9a1ifpLcT7ajFkvYviG_A,1190
|
43
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=7r9UrXEdftoMWsE0fy0ps9dcPq0o5M4pMYmr7VXs7yc,12238
|
44
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=6wnDtkBH-uwJeZm9FtyeXuUWux8u-skT3lmrtFwsReI,286298
|
45
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=9cFzfFqIA968bUG7LNTjdN7zbdEXUtcvRKg883ade2c,2586
|
46
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py,sha256=DQHjcEuqEKsNSWaNs7SoOaq50yK4Jsl966S7mBnV-zA,5723
|
47
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py,sha256=faFat_OAUnVJGnauMVo6yeHhTv-_njgyXGOtUwYJ8kE,7568
|
48
|
+
ragaai_catalyst/tracers/exporters/__init__.py,sha256=kVA8zp05h3phu4e-iHSlnznp_PzMRczB7LphSsZgUjg,138
|
49
|
+
ragaai_catalyst/tracers/exporters/file_span_exporter.py,sha256=RgGteu-NVGprXKkynvyIO5yOjpbtA41R3W_NzCjnkwE,6445
|
50
|
+
ragaai_catalyst/tracers/exporters/raga_exporter.py,sha256=pU9EH6Fn1Z757bpM3VaXPDHuJ5wyUrMObGaACiztvTU,18014
|
51
|
+
ragaai_catalyst/tracers/instrumentators/__init__.py,sha256=FgnMQupoRTzmVsG9YKsLQera2Pfs-AluZv8CxwavoyQ,253
|
52
|
+
ragaai_catalyst/tracers/instrumentators/langchain.py,sha256=yMN0qVF0pUVk6R5M1vJoUXezDo1ejs4klCFRlE8x4vE,574
|
53
|
+
ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hakE8rkrWHxMlmtmWD-AX6TeByc,416
|
54
|
+
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
55
|
+
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
56
|
+
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
57
|
+
ragaai_catalyst-2.1.1.dist-info/METADATA,sha256=PCjCVaeopFVu1f-SysTFHlQn0HYdDI5sI155hCXeHic,1802
|
58
|
+
ragaai_catalyst-2.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
59
|
+
ragaai_catalyst-2.1.1.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
60
|
+
ragaai_catalyst-2.1.1.dist-info/RECORD,,
|
@@ -1,61 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass, field
|
2
|
-
from typing import Dict, List, Any, Optional
|
3
|
-
|
4
|
-
|
5
|
-
@dataclass
|
6
|
-
class ProjectInfo:
|
7
|
-
project_name: str
|
8
|
-
start_time: float
|
9
|
-
end_time: float = field(default=0)
|
10
|
-
duration: float = field(default=0)
|
11
|
-
total_cost: float = field(default=0)
|
12
|
-
total_tokens: int = field(default=0)
|
13
|
-
|
14
|
-
|
15
|
-
@dataclass
|
16
|
-
class SystemInfo:
|
17
|
-
project_id: int
|
18
|
-
os_name: str
|
19
|
-
os_version: str
|
20
|
-
python_version: str
|
21
|
-
cpu_info: str
|
22
|
-
memory_total: float
|
23
|
-
installed_packages: str
|
24
|
-
|
25
|
-
|
26
|
-
@dataclass
|
27
|
-
class LLMCall:
|
28
|
-
name: str
|
29
|
-
model_name: str
|
30
|
-
input_prompt: str
|
31
|
-
output_response: str
|
32
|
-
tool_call: Dict
|
33
|
-
token_usage: Dict[str, int]
|
34
|
-
cost: Dict[str, float]
|
35
|
-
start_time: float = field(default=0)
|
36
|
-
end_time: float = field(default=0)
|
37
|
-
duration: float = field(default=0)
|
38
|
-
|
39
|
-
|
40
|
-
@dataclass
|
41
|
-
class ToolCall:
|
42
|
-
name: str
|
43
|
-
input_parameters: Dict[str, Any]
|
44
|
-
output: Any
|
45
|
-
start_time: float
|
46
|
-
end_time: float
|
47
|
-
duration: float
|
48
|
-
errors: Optional[str] = None
|
49
|
-
|
50
|
-
|
51
|
-
@dataclass
|
52
|
-
class AgentCall:
|
53
|
-
name: str
|
54
|
-
input_parameters: Dict[str, Any]
|
55
|
-
output: Any
|
56
|
-
start_time: float
|
57
|
-
end_time: float
|
58
|
-
duration: float
|
59
|
-
tool_calls: List[Dict[str, Any]]
|
60
|
-
llm_calls: List[Dict[str, Any]]
|
61
|
-
errors: Optional[str] = None
|