ragaai-catalyst 2.2.4b5__py3-none-any.whl → 2.2.5b2__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 (45) 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 +5 -285
  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-2.2.4b5.dist-info → ragaai_catalyst-2.2.5b2.dist-info}/METADATA +1 -1
  11. {ragaai_catalyst-2.2.4b5.dist-info → ragaai_catalyst-2.2.5b2.dist-info}/RECORD +14 -45
  12. ragaai_catalyst/experiment.py +0 -486
  13. ragaai_catalyst/tracers/agentic_tracing/tests/FinancialAnalysisSystem.ipynb +0 -536
  14. ragaai_catalyst/tracers/agentic_tracing/tests/GameActivityEventPlanner.ipynb +0 -134
  15. ragaai_catalyst/tracers/agentic_tracing/tests/TravelPlanner.ipynb +0 -563
  16. ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py +0 -0
  17. ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py +0 -197
  18. ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py +0 -172
  19. ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +0 -687
  20. ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +0 -1319
  21. ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +0 -347
  22. ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py +0 -0
  23. ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +0 -1182
  24. ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py +0 -288
  25. ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +0 -557
  26. ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py +0 -129
  27. ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py +0 -74
  28. ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +0 -21
  29. ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +0 -32
  30. ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py +0 -28
  31. ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py +0 -133
  32. ragaai_catalyst/tracers/agentic_tracing/utils/supported_llm_provider.toml +0 -34
  33. ragaai_catalyst/tracers/exporters/raga_exporter.py +0 -467
  34. ragaai_catalyst/tracers/langchain_callback.py +0 -821
  35. ragaai_catalyst/tracers/llamaindex_callback.py +0 -361
  36. ragaai_catalyst/tracers/llamaindex_instrumentation.py +0 -424
  37. ragaai_catalyst/tracers/upload_traces.py +0 -170
  38. ragaai_catalyst/tracers/utils/convert_langchain_callbacks_output.py +0 -62
  39. ragaai_catalyst/tracers/utils/convert_llama_instru_callback.py +0 -69
  40. ragaai_catalyst/tracers/utils/extraction_logic_llama_index.py +0 -74
  41. ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py +0 -82
  42. ragaai_catalyst/tracers/utils/rag_trace_json_converter.py +0 -403
  43. {ragaai_catalyst-2.2.4b5.dist-info → ragaai_catalyst-2.2.5b2.dist-info}/WHEEL +0 -0
  44. {ragaai_catalyst-2.2.4b5.dist-info → ragaai_catalyst-2.2.5b2.dist-info}/licenses/LICENSE +0 -0
  45. {ragaai_catalyst-2.2.4b5.dist-info → ragaai_catalyst-2.2.5b2.dist-info}/top_level.txt +0 -0
@@ -1,197 +0,0 @@
1
- import os
2
- import json
3
- from openai import OpenAI
4
- import requests
5
- from datetime import datetime
6
- from dotenv import load_dotenv
7
- import sys
8
-
9
- # Load environment variables
10
- load_dotenv()
11
-
12
- # Initialize OpenAI client
13
- client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
14
-
15
- # Initialize tracer
16
- from tracer import Tracer
17
- tracer = Tracer(
18
- project_name="travel_agent_demo",
19
- output_dir="./traces"
20
- )
21
-
22
- # Start tracing
23
- tracer.start()
24
-
25
- @tracer.trace_tool(
26
- name="llm_call",
27
- tool_type="llm",
28
- version="1.0.0"
29
- )
30
- def llm_call(prompt, max_tokens=512, model="gpt-3.5-turbo"):
31
- response = client.chat.completions.create(
32
- model=model,
33
- messages=[{"role": "user", "content": prompt}],
34
- max_tokens=max_tokens,
35
- temperature=0.7,
36
- )
37
- return response.choices[0].message.content.strip()
38
-
39
- @tracer.trace_tool(
40
- name="weather_tool",
41
- tool_type="api",
42
- version="1.0.0"
43
- )
44
- def weather_tool(destination):
45
- api_key = os.environ.get("OPENWEATHERMAP_API_KEY")
46
- base_url = "http://api.openweathermap.org/data/2.5/weather"
47
- params = {"q": destination, "appid": api_key, "units": "metric"}
48
-
49
- try:
50
- response = requests.get(base_url, params=params)
51
- response.raise_for_status()
52
- data = response.json()
53
- weather_description = data["weather"][0]["description"]
54
- temperature = data["main"]["temp"]
55
- return f"{weather_description.capitalize()}, {temperature:.1f}°C"
56
- except requests.RequestException:
57
- return "Weather data not available."
58
-
59
- @tracer.trace_tool(
60
- name="currency_converter_tool",
61
- tool_type="api",
62
- version="1.0.0"
63
- )
64
- def currency_converter_tool(amount, from_currency, to_currency):
65
- api_key = os.environ.get("EXCHANGERATE_API_KEY")
66
- base_url = f"https://v6.exchangerate-api.com/v6/{api_key}/pair/{from_currency}/{to_currency}"
67
-
68
- try:
69
- response = requests.get(base_url)
70
- response.raise_for_status()
71
- data = response.json()
72
- if data["result"] == "success":
73
- rate = data["conversion_rate"]
74
- return amount * rate
75
- return None
76
- except requests.RequestException:
77
- return None
78
-
79
- @tracer.trace_tool(
80
- name="flight_price_estimator_tool",
81
- tool_type="mock",
82
- version="1.0.0"
83
- )
84
- def flight_price_estimator_tool(origin, destination):
85
- return f"Estimated price from {origin} to {destination}: $500-$1000"
86
-
87
- @tracer.trace_agent(
88
- name="itinerary_agent",
89
- agent_type="planner",
90
- capabilities=["itinerary_planning", "llm_interaction"]
91
- )
92
- class ItineraryAgent:
93
- def __init__(self, persona="Itinerary Agent"):
94
- self.persona = persona
95
-
96
- def plan_itinerary(self, user_preferences, duration=3):
97
- itinerary_prompt = f"""
98
- You are a travel expert named {self.persona}.
99
- Based on the following user preferences, create a {duration}-day travel itinerary.
100
-
101
- User Preferences:
102
- {user_preferences}
103
-
104
- Itinerary:
105
- """
106
- return llm_call(itinerary_prompt, max_tokens=512)
107
-
108
- @tracer.trace_agent(
109
- name="travel_agent",
110
- agent_type="orchestrator",
111
- capabilities=["preference_extraction", "travel_planning", "information_gathering"]
112
- )
113
- def travel_agent():
114
- print("Welcome to the Personalized Travel Planner!\n")
115
-
116
- # Get user input
117
- user_input = "karela, 10 days, $100, nature"
118
-
119
- # Extract preferences
120
- preferences_prompt = f"""
121
- Extract key travel preferences from the following user input:
122
- "{user_input}"
123
-
124
- Please provide the extracted information in this format:
125
- Destination:
126
- Activities:
127
- Budget:
128
- Duration (in days):
129
- """
130
- extracted_preferences = llm_call(preferences_prompt)
131
- print("\nExtracted Preferences:")
132
- print(extracted_preferences)
133
-
134
- # Parse extracted preferences
135
- preferences = {}
136
- for line in extracted_preferences.split("\n"):
137
- if ":" in line:
138
- key, value = line.split(":", 1)
139
- preferences[key.strip()] = value.strip()
140
-
141
- # Validate extracted preferences
142
- required_keys = ["Destination", "Activities", "Budget", "Duration (in days)"]
143
- if not all(key in preferences for key in required_keys):
144
- print("\nCould not extract all required preferences. Please try again.")
145
- return
146
-
147
- # Fetch additional information
148
- weather = weather_tool(preferences["Destination"])
149
- print(f"\nWeather in {preferences['Destination']}: {weather}")
150
-
151
- origin = "delhi"
152
- flight_price = flight_price_estimator_tool(origin, preferences["Destination"])
153
- print(flight_price)
154
-
155
- # Plan itinerary
156
- itinerary_agent = ItineraryAgent()
157
- itinerary = itinerary_agent.plan_itinerary(
158
- extracted_preferences, int(preferences["Duration (in days)"])
159
- )
160
- print("\nPlanned Itinerary:")
161
- print(itinerary)
162
-
163
- # Currency conversion
164
- budget_amount = float(preferences["Budget"].replace("$", "").replace(",", ""))
165
- converted_budget = currency_converter_tool(budget_amount, "USD", "INR")
166
- if converted_budget:
167
- print(f"\nBudget in INR: {converted_budget:.2f} INR")
168
- else:
169
- print("\nCurrency conversion not available.")
170
-
171
- # Generate travel summary
172
- summary_prompt = f"""
173
- Summarize the following travel plan:
174
-
175
- Destination: {preferences['Destination']}
176
- Activities: {preferences['Activities']}
177
- Budget: {preferences['Budget']}
178
- Duration: {preferences['Duration (in days)']} days
179
- Itinerary: {itinerary}
180
- Weather: {weather}
181
- Flight Price: {flight_price}
182
-
183
- Travel Summary:
184
- """
185
- travel_summary = llm_call(summary_prompt, max_tokens=2048)
186
- print("\nTravel Summary:")
187
- print(travel_summary)
188
-
189
- def main():
190
- try:
191
- travel_agent()
192
- finally:
193
- # Stop tracing and save results
194
- tracer.stop()
195
-
196
- if __name__ == "__main__":
197
- main()
@@ -1,172 +0,0 @@
1
- from unique_decorator import mydecorator
2
- from unique_decorator import generate_unique_hash
3
- import inspect
4
-
5
- def print_test_case(case_num, description, expected_behavior, hash1, hash2=None):
6
- print(f"\n{'='*100}")
7
- print(f"Test Case #{case_num}: {description}")
8
- print(f"Expected Behavior: {expected_behavior}")
9
- print(f"{'='*100}")
10
- if hash2 is not None:
11
- print(f"Hash ID 1: {hash1}")
12
- print(f"Hash ID 2: {hash2}")
13
- print(f"Hash IDs are {'EQUAL' if hash1 == hash2 else 'DIFFERENT'} (Expected: {expected_behavior})")
14
- else:
15
- print(f"Hash ID: {hash1}")
16
- print(f"{'='*100}\n")
17
-
18
- # Test Case 1: Same function with different formatting
19
- # Expected: Same hash_id
20
- @mydecorator
21
- def example_function():
22
- x = 1
23
- return x
24
-
25
- hash1 = example_function.hash_id
26
-
27
- @mydecorator
28
- def example_function():
29
- # This is a comment
30
- x = 1 # Another comment
31
- return x # More spacing
32
-
33
- hash2 = example_function.hash_id
34
-
35
- print_test_case(1,
36
- "Same function with different formatting and comments",
37
- "Hash IDs should be EQUAL",
38
- hash1, hash2)
39
-
40
- # Test Case 2: Function with parameters - different argument orders
41
- # Expected: Same hash_id for same arguments in different order
42
- @mydecorator
43
- def function_with_params(a: int, b: int = 10):
44
- return a + b
45
-
46
- result1 = function_with_params(a=2, b=3)
47
- hash1 = function_with_params.hash_id
48
-
49
- result2 = function_with_params(b=3, a=2)
50
- hash2 = function_with_params.hash_id
51
-
52
- print_test_case(2,
53
- "Same function call with different argument order (a=2, b=3 vs b=3, a=2)",
54
- "Hash IDs should be EQUAL",
55
- hash1, hash2)
56
-
57
- # Test Case 3: Function with different default value
58
- # Expected: Different hash_id
59
- @mydecorator
60
- def function_with_params(a: int, b: int = 5): # Different default value
61
- return a + b
62
-
63
- hash3 = function_with_params.hash_id
64
-
65
- print_test_case(3,
66
- "Same function name but different default parameter value",
67
- "Hash IDs should be DIFFERENT",
68
- hash2, hash3)
69
-
70
- # Test Case 4: Class methods with different formatting
71
- # Expected: Same hash_id
72
- @mydecorator
73
- class ExampleClass:
74
- @mydecorator
75
- def method1(self):
76
- x = 1
77
- return x
78
-
79
- hash1 = ExampleClass().method1.hash_id
80
-
81
- @mydecorator
82
- class ExampleClass:
83
- @mydecorator
84
- def method1(self):
85
- # Comment here
86
- x = 1
87
- return x
88
-
89
- hash2 = ExampleClass().method1.hash_id
90
-
91
- print_test_case(4,
92
- "Class method with different formatting",
93
- "Hash IDs should be EQUAL",
94
- hash1, hash2)
95
-
96
- # Test Case 5: Functions with different argument types but same content
97
- # Expected: Same hash_id
98
- @mydecorator
99
- def complex_function(a: dict, b: list = [1, 2]):
100
- return a, b
101
-
102
- test_dict1 = {"a": 1, "b": 2}
103
- test_dict2 = {"b": 2, "a": 1} # Same content, different order
104
- test_list1 = [1, 2, 3]
105
- test_list2 = [1, 2, 3] # Identical list
106
-
107
- result1 = complex_function(test_dict1, test_list1)
108
- hash1 = complex_function.hash_id
109
-
110
- result2 = complex_function(test_dict2, test_list2)
111
- hash2 = complex_function.hash_id
112
-
113
- print_test_case(5,
114
- "Complex function with same content in different order",
115
- "Hash IDs should be EQUAL",
116
- hash1, hash2)
117
-
118
- # Test Case 6: Function with docstring - different formatting
119
- # Expected: Same hash_id
120
- @mydecorator
121
- def documented_function(x: int):
122
- """
123
- This is a docstring.
124
- It should be preserved in the hash.
125
- """
126
- # This is a comment that should be ignored
127
- return x * 2 # This comment should also be ignored
128
-
129
- hash1 = documented_function.hash_id
130
-
131
- @mydecorator
132
- def documented_function(x:int):
133
- """
134
- This is a docstring.
135
- It should be preserved in the hash.
136
- """
137
- return x*2
138
-
139
- hash2 = documented_function.hash_id
140
-
141
- print_test_case(6,
142
- "Function with docstring - different formatting",
143
- "Hash IDs should be EQUAL",
144
- hash1, hash2)
145
-
146
- # Test Case 7: Different functions with same structure
147
- # Expected: Different hash_id
148
- @mydecorator
149
- def function_a(x):
150
- return x + 1
151
-
152
- @mydecorator
153
- def function_b(x):
154
- return x + 1
155
-
156
- print_test_case(7,
157
- "Different function names with same implementation",
158
- "Hash IDs should be DIFFERENT",
159
- function_a.hash_id, function_b.hash_id)
160
-
161
- # Test Case 8: Same function with different argument values
162
- # Expected: Different hash_id
163
- result1 = function_with_params(a=1, b=2)
164
- hash1 = function_with_params.hash_id
165
-
166
- result2 = function_with_params(a=3, b=4)
167
- hash2 = function_with_params.hash_id
168
-
169
- print_test_case(8,
170
- "Same function with different argument values",
171
- "Hash IDs should be DIFFERENT",
172
- hash1, hash2)