ragaai-catalyst 2.0.7.2b1__tar.gz → 2.1__tar.gz

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 (91) hide show
  1. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/PKG-INFO +8 -4
  2. ragaai_catalyst-2.1/ai_travel_agent.py +239 -0
  3. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/catalyst_v2.ipynb +655 -463
  4. ragaai_catalyst-2.1/finance_agent_catalyst.ipynb +323 -0
  5. ragaai_catalyst-2.1/financial_analysis_agent.py +152 -0
  6. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/pyproject.toml +8 -5
  7. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/dataset.py +0 -3
  8. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/evaluation.py +1 -2
  9. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/__init__.py +1 -1
  10. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +468 -0
  11. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py +32 -42
  12. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/base.py +132 -30
  13. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/data_structure.py +251 -0
  14. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb +536 -0
  15. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb +134 -0
  16. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb +563 -0
  17. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py +46 -0
  18. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py +262 -356
  19. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py +31 -19
  20. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +165 -0
  21. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py +187 -0
  22. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/upload_code.py +115 -0
  23. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +43 -0
  24. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +0 -4
  25. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +2201 -324
  26. ragaai_catalyst-2.1/ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py +186 -0
  27. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/exporters/raga_exporter.py +1 -7
  28. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/llamaindex_callback.py +56 -60
  29. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/tracer.py +6 -2
  30. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/upload_traces.py +46 -57
  31. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst.egg-info/PKG-INFO +8 -4
  32. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst.egg-info/SOURCES.txt +18 -2
  33. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst.egg-info/requires.txt +7 -3
  34. ragaai_catalyst-2.1/requirements.txt +95 -0
  35. ragaai_catalyst-2.1/sync_sample_llm_testing.py +65 -0
  36. ragaai_catalyst-2.1/traces/2439beda-8f3a-45c3-82de-4f72624c6ce9.json +309 -0
  37. ragaai_catalyst-2.1/traces/cd571931-29fe-4d57-9523-71381c97abb1.json +302 -0
  38. ragaai_catalyst-2.1/traces/d3d5ad2d-6a98-40d6-8b69-8b082eab1bc2.json +1018 -0
  39. ragaai_catalyst-2.1/traces/ed050fde-8705-4635-8570-3aa7f6e4b286.json +334 -0
  40. ragaai_catalyst-2.1/traces/f2d41172-f89e-47e4-9523-1c1fe6ce20eb.json +302 -0
  41. ragaai_catalyst-2.1/traces/prompt_metric_dataset_finance.json +827 -0
  42. ragaai_catalyst-2.1/traces/prompt_metric_dataset_travel.json +829 -0
  43. ragaai_catalyst-2.0.7.2b1/ragaai_catalyst/tracers/agentic_tracing/Untitled-1.json +0 -660
  44. ragaai_catalyst-2.0.7.2b1/ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +0 -311
  45. ragaai_catalyst-2.0.7.2b1/ragaai_catalyst/tracers/agentic_tracing/data_structure.py +0 -239
  46. ragaai_catalyst-2.0.7.2b1/ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +0 -221
  47. ragaai_catalyst-2.0.7.2b1/ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +0 -67
  48. ragaai_catalyst-2.0.7.2b1/requirements.txt +0 -10
  49. ragaai_catalyst-2.0.7.2b1/traces/prompt_metric_dataset_20241216_135809.json +0 -1368
  50. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/.gitignore +0 -0
  51. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/__init__.py +0 -0
  52. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/docs/dataset_management.md +0 -0
  53. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/docs/prompt_management.md +0 -0
  54. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/examples/prompt_management_litellm.ipynb +0 -0
  55. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/examples/prompt_management_openai.ipynb +0 -0
  56. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/__init__.py +0 -0
  57. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/_version.py +0 -0
  58. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/experiment.py +0 -0
  59. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/guard_executor.py +0 -0
  60. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/guardrails_manager.py +0 -0
  61. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/internal_api_completion.py +0 -0
  62. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/prompt_manager.py +0 -0
  63. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/proxy_call.py +0 -0
  64. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/ragaai_catalyst.py +0 -0
  65. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/synthetic_data_generation.py +0 -0
  66. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/__init__.py +0 -0
  67. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/network_tracer.py +0 -0
  68. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/sample.py +0 -0
  69. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py +0 -0
  70. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +0 -0
  71. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +0 -0
  72. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py +0 -0
  73. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +0 -0
  74. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +0 -0
  75. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
  76. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
  77. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
  78. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
  79. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
  80. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
  81. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
  82. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/tracers/utils/utils.py +0 -0
  83. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst/utils.py +0 -0
  84. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
  85. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/ragaai_catalyst.egg-info/top_level.txt +0 -0
  86. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/setup.cfg +0 -0
  87. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/test/test_catalyst/test_configuration.py +0 -0
  88. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/test/test_catalyst/test_dataset.py +0 -0
  89. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/test/test_catalyst/test_evaluation.py +0 -0
  90. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/test/test_catalyst/test_prompt_manager.py +0 -0
  91. {ragaai_catalyst-2.0.7.2b1 → ragaai_catalyst-2.1}/test/test_catalyst/test_synthetic_data_generation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 2.0.7.2b1
3
+ Version: 2.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
6
  Requires-Python: >=3.9
@@ -27,9 +27,13 @@ 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==0.10.0
31
- Requires-Dist: pyopenssl==24.2.1
32
- Requires-Dist: psutil>=5.9.5
30
+ Requires-Dist: llama-index>=0.10.0
31
+ Requires-Dist: pyopenssl>=24.2.1
32
+ Requires-Dist: psutil~=6.0.0
33
+ Requires-Dist: py-cpuinfo~=9.0.0
34
+ Requires-Dist: requests~=2.32.3
35
+ Requires-Dist: GPUtil~=1.4.0
36
+ Requires-Dist: astor>=0.8.1
33
37
  Provides-Extra: dev
34
38
  Requires-Dist: pytest; extra == "dev"
35
39
  Requires-Dist: pytest-cov; extra == "dev"
@@ -0,0 +1,239 @@
1
+ import os
2
+ import requests
3
+ from dotenv import load_dotenv
4
+ from litellm import completion
5
+ from openai import OpenAI
6
+
7
+ from ragaai_catalyst.tracers import Tracer
8
+ from ragaai_catalyst import RagaAICatalyst
9
+ import asyncio
10
+ import os
11
+ import requests
12
+ from dotenv import load_dotenv
13
+ load_dotenv()
14
+ from litellm import completion
15
+ import openai
16
+ from openai import AsyncOpenAI
17
+
18
+ catalyst = RagaAICatalyst(
19
+ access_key="saLy6KmMVlfAzunuQGS9",
20
+ secret_key="lm39fd4KXffM6gzLjnY9G7QReffhH4RGZPursp3A",
21
+ base_url="http://52.172.168.127/api"
22
+ )
23
+ # Initialize tracer
24
+ tracer = Tracer(
25
+ project_name="prompt_metric_dataset",
26
+ dataset_name="ChatOpenAI_tan",
27
+ tracer_type="anything",
28
+ metadata={
29
+ "model": "gpt-3.5-turbo",
30
+ "environment": "production"
31
+ },
32
+ pipeline={
33
+ "llm_model": "gpt-3.5-turbo",
34
+ "vector_store": "faiss",
35
+ "embed_model": "text-embedding-ada-002",
36
+ }
37
+ )
38
+ load_dotenv()
39
+
40
+
41
+ tracer.start()
42
+
43
+
44
+ @tracer.trace_llm(name="llm_call")
45
+ def llm_call(prompt, max_tokens=512, model="gpt-4o-mini", name="default"):
46
+ client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
47
+
48
+ response = client.chat.completions.create(
49
+ model=model,
50
+ messages=[{"role": "user", "content": prompt}],
51
+ max_tokens=max_tokens,
52
+ temperature=0.7,
53
+ )
54
+
55
+ actual_response = response.choices[0].message.content.strip()
56
+
57
+ return actual_response
58
+
59
+
60
+ # Tools outside agents
61
+ @tracer.trace_tool(name="weather_tool")
62
+ def weather_tool(destination):
63
+ api_key = os.environ.get("OPENWEATHERMAP_API_KEY")
64
+ base_url = "http://api.openweathermap.org/data/2.5/weather"
65
+
66
+ params = {"q": destination, "appid": api_key, "units": "metric"}
67
+ print("Calculating weather for:", destination)
68
+ try:
69
+ response = requests.get(base_url, params=params)
70
+ response.raise_for_status()
71
+ data = response.json()
72
+
73
+ weather_description = data["weather"][0]["description"]
74
+ temperature = data["main"]["temp"]
75
+
76
+ actual_result = f"{weather_description.capitalize()}, {temperature:.1f}°C"
77
+
78
+ return actual_result
79
+ except requests.RequestException:
80
+ return "Weather data not available."
81
+
82
+
83
+ @tracer.trace_tool(name="currency_converter_tool")
84
+ def currency_converter_tool(amount, from_currency, to_currency):
85
+ api_key = os.environ.get("EXCHANGERATE_API_KEY")
86
+ base_url = f"https://v6.exchangerate-api.com/v6/{api_key}/pair/{from_currency}/{to_currency}"
87
+
88
+ try:
89
+ response = requests.get(base_url)
90
+ response.raise_for_status()
91
+ data = response.json()
92
+
93
+ if data["result"] == "success":
94
+ rate = data["conversion_rate"]
95
+ actual_result = amount * rate
96
+
97
+ return actual_result
98
+ else:
99
+ return None
100
+ except requests.RequestException:
101
+ return None
102
+
103
+
104
+ @tracer.trace_tool(name="flight_price_estimator_tool")
105
+ def flight_price_estimator_tool(origin, destination):
106
+ # This is a mock function. In a real scenario, you'd integrate with a flight API.
107
+ actual_result = f"Estimated price from {origin} to {destination}: $500-$1000"
108
+
109
+ return actual_result
110
+
111
+
112
+ # Agent with persona
113
+ class ItineraryAgent:
114
+ def __init__(self, persona="Itinerary Agent"):
115
+ self.persona = persona
116
+
117
+ @tracer.trace_llm(name="plan_itinerary")
118
+ def plan_itinerary(self, user_preferences, duration=3):
119
+ # Get weather information
120
+ weather = weather_tool(user_preferences["destination"])
121
+
122
+ # Get currency conversion if needed
123
+ if "budget_currency" in user_preferences and user_preferences["budget_currency"] != "USD":
124
+ budget = currency_converter_tool(
125
+ user_preferences["budget"],
126
+ user_preferences["budget_currency"],
127
+ "USD"
128
+ )
129
+ else:
130
+ budget = user_preferences["budget"]
131
+
132
+ # Get flight price estimation
133
+ flight_price = flight_price_estimator_tool(
134
+ user_preferences["origin"],
135
+ user_preferences["destination"]
136
+ )
137
+
138
+ # Prepare prompt for the LLM
139
+ prompt = f"""As a {self.persona}, create a {duration}-day itinerary for a trip to {user_preferences['destination']}.
140
+ Weather: {weather}
141
+ Budget: ${budget}
142
+ Flight Price: {flight_price}
143
+ Preferences: {user_preferences.get('preferences', 'No specific preferences')}
144
+
145
+ Please provide a detailed day-by-day itinerary."""
146
+
147
+ # Get itinerary from LLM
148
+ itinerary = llm_call(prompt)
149
+ return itinerary
150
+
151
+
152
+ # Main function
153
+ @tracer.trace_agent(name="travel_agent")
154
+ def travel_agent():
155
+ print("Welcome to the Personalized Travel Planner!\n")
156
+
157
+ # Get user input
158
+ # user_input = input("Please describe your ideal vacation: ")
159
+ user_input = input("Please describe your ideal vacation: ")
160
+ #"karela, 10 days, $100, nature"
161
+
162
+ # Extract preferences
163
+ preferences_prompt = f"""
164
+ Extract key travel preferences from the following user input:
165
+ "{user_input}"
166
+
167
+ Please provide the extracted information in this format:
168
+ Destination:
169
+ Activities:
170
+ Budget:
171
+ Duration (in days):
172
+ """
173
+ extracted_preferences = llm_call(preferences_prompt, name="extract_preferences")
174
+ print("\nExtracted Preferences:")
175
+ print(extracted_preferences)
176
+
177
+ # Parse extracted preferences
178
+ preferences = {}
179
+ for line in extracted_preferences.split("\n"):
180
+ if ":" in line:
181
+ key, value = line.split(":", 1)
182
+ preferences[key.strip()] = value.strip()
183
+
184
+ # Validate extracted preferences
185
+ required_keys = ["Destination", "Activities", "Budget", "Duration (in days)"]
186
+ if not all(key in preferences for key in required_keys):
187
+ print("\nCould not extract all required preferences. Please try again.")
188
+ return
189
+
190
+ # Fetch additional information
191
+ weather = weather_tool(preferences["Destination"])
192
+ print(f"\nWeather in {preferences['Destination']}: {weather}")
193
+
194
+ # origin = input("Please enter your departure city: ")
195
+ print("Please enter your departure city: ")
196
+ origin = input("Please enter your departure city: ")
197
+ # "delhi"
198
+ flight_price = flight_price_estimator_tool(origin, preferences["Destination"])
199
+ print(flight_price)
200
+
201
+ # Plan itinerary
202
+ itinerary_agent = ItineraryAgent()
203
+ itinerary = itinerary_agent.plan_itinerary(
204
+ {"destination": preferences["Destination"], "origin": origin, "budget": float(preferences["Budget"].replace("$", "")), "budget_currency": "USD"},
205
+ int(preferences["Duration (in days)"])
206
+ )
207
+ print("\nPlanned Itinerary:")
208
+ print(itinerary)
209
+
210
+ # Currency conversion
211
+ budget_amount = float(preferences["Budget"].replace("$", "").replace(",", ""))
212
+ converted_budget = currency_converter_tool(budget_amount, "USD", "INR")
213
+ if converted_budget:
214
+ print(f"\nBudget in INR: {converted_budget:.2f} INR")
215
+ else:
216
+ print("\nCurrency conversion not available.")
217
+
218
+ # Generate travel summary
219
+ summary_prompt = f"""
220
+ Summarize the following travel plan:
221
+
222
+ Destination: {preferences['Destination']}
223
+ Activities: {preferences['Activities']}
224
+ Budget: {preferences['Budget']}
225
+ Duration: {preferences['Duration (in days)']} days
226
+ Itinerary: {itinerary}
227
+ Weather: {weather}
228
+ Flight Price: {flight_price}
229
+
230
+ Travel Summary:
231
+ """
232
+ travel_summary = llm_call(summary_prompt, name="generate_summary")
233
+ print("\nTravel Summary:")
234
+ print(travel_summary)
235
+
236
+
237
+ if __name__ == "__main__":
238
+ travel_agent()
239
+ tracer.stop()