ragaai-catalyst 2.0.7.2b1__py3-none-any.whl → 2.1b1__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/dataset.py +0 -3
- ragaai_catalyst/evaluation.py +1 -2
- ragaai_catalyst/tracers/__init__.py +1 -1
- ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +217 -106
- ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py +27 -41
- ragaai_catalyst/tracers/agentic_tracing/base.py +127 -21
- ragaai_catalyst/tracers/agentic_tracing/data_structure.py +88 -79
- ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb +536 -0
- ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb +134 -0
- ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb +563 -0
- ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py +46 -0
- ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py +258 -356
- ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py +31 -19
- ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +61 -117
- ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py +187 -0
- ragaai_catalyst/tracers/agentic_tracing/upload_code.py +115 -0
- ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +35 -59
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +0 -4
- ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +2201 -324
- ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py +342 -0
- ragaai_catalyst/tracers/exporters/raga_exporter.py +1 -7
- ragaai_catalyst/tracers/llamaindex_callback.py +56 -60
- ragaai_catalyst/tracers/tracer.py +6 -2
- ragaai_catalyst/tracers/upload_traces.py +46 -57
- {ragaai_catalyst-2.0.7.2b1.dist-info → ragaai_catalyst-2.1b1.dist-info}/METADATA +6 -2
- {ragaai_catalyst-2.0.7.2b1.dist-info → ragaai_catalyst-2.1b1.dist-info}/RECORD +28 -22
- ragaai_catalyst/tracers/agentic_tracing/Untitled-1.json +0 -660
- {ragaai_catalyst-2.0.7.2b1.dist-info → ragaai_catalyst-2.1b1.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.0.7.2b1.dist-info → ragaai_catalyst-2.1b1.dist-info}/top_level.txt +0 -0
@@ -1,67 +1,43 @@
|
|
1
1
|
import builtins
|
2
|
-
from contextlib import contextmanager, asynccontextmanager
|
3
2
|
from datetime import datetime
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
import contextvars
|
4
|
+
import inspect
|
5
|
+
import uuid
|
7
6
|
|
8
7
|
class UserInteractionTracer:
|
9
|
-
def __init__(self,
|
10
|
-
self.
|
8
|
+
def __init__(self, *args, **kwargs):
|
9
|
+
self.project_id = contextvars.ContextVar("project_id", default=None)
|
10
|
+
self.trace_id = contextvars.ContextVar("trace_id", default=None)
|
11
|
+
self.tracer = contextvars.ContextVar("tracer", default=None)
|
12
|
+
self.component_id = contextvars.ContextVar("component_id", default=None)
|
11
13
|
self.original_input = builtins.input
|
12
14
|
self.original_print = builtins.print
|
15
|
+
self.interactions = []
|
13
16
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
return user_input
|
19
|
-
|
20
|
-
def print(self, *args, **kwargs):
|
21
|
-
content = " ".join(str(arg) for arg in args)
|
22
|
-
self._log_interaction("output", content)
|
23
|
-
self.original_print(*args, **kwargs)
|
24
|
-
|
25
|
-
def _log_interaction(self, interaction_type, content):
|
26
|
-
agent_id = self.tracer.current_agent_id.get()
|
27
|
-
user_interaction = UserInteractionModel(
|
28
|
-
project_id=self.tracer.project_id,
|
29
|
-
trace_id=self.tracer.trace_id,
|
30
|
-
agent_id=agent_id,
|
31
|
-
interaction_type=interaction_type,
|
32
|
-
content=content,
|
33
|
-
timestamp=datetime.now(),
|
34
|
-
)
|
35
|
-
with self.tracer.Session() as session:
|
36
|
-
session.add(user_interaction)
|
37
|
-
session.commit()
|
38
|
-
|
39
|
-
# Also add to trace data
|
40
|
-
self.tracer.trace_data.setdefault("user_interactions", []).append(
|
41
|
-
{
|
42
|
-
"interaction_type": interaction_type,
|
43
|
-
"content": content,
|
44
|
-
"timestamp": datetime.now(),
|
45
|
-
"agent_id": agent_id,
|
46
|
-
}
|
47
|
-
)
|
48
|
-
|
49
|
-
@contextmanager
|
50
|
-
def capture(self):
|
51
|
-
builtins.input = self.input
|
52
|
-
builtins.print = self.print
|
17
|
+
def traced_input(self, prompt=""):
|
18
|
+
# Get caller information
|
19
|
+
if prompt:
|
20
|
+
self.traced_print(prompt, end="")
|
53
21
|
try:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
22
|
+
content = self.original_input()
|
23
|
+
except EOFError:
|
24
|
+
content = "" # Return empty string on EOF
|
25
|
+
|
26
|
+
self.interactions.append({
|
27
|
+
"id": str(uuid.uuid4()),
|
28
|
+
"interaction_type": "input",
|
29
|
+
"content": content,
|
30
|
+
"timestamp": datetime.now().isoformat()
|
31
|
+
})
|
32
|
+
return content
|
33
|
+
|
34
|
+
def traced_print(self, *args, **kwargs):
|
35
|
+
content = " ".join(str(arg) for arg in args)
|
36
|
+
|
37
|
+
self.interactions.append({
|
38
|
+
"id": str(uuid.uuid4()),
|
39
|
+
"interaction_type": "output",
|
40
|
+
"content": content,
|
41
|
+
"timestamp": datetime.now().isoformat()
|
42
|
+
})
|
43
|
+
return self.original_print(*args, **kwargs)
|