ragaai-catalyst 2.1b0__tar.gz → 2.1b2__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 (82) hide show
  1. ragaai_catalyst-2.1b2/PKG-INFO +43 -0
  2. ragaai_catalyst-2.1b2/ai_travel_agent.py +253 -0
  3. ragaai_catalyst-2.1b2/catalyst_v2.ipynb +3071 -0
  4. ragaai_catalyst-2.1b2/finance_agent_catalyst.ipynb +323 -0
  5. ragaai_catalyst-2.1b2/financial_analysis_agent.py +152 -0
  6. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/pyproject.toml +9 -3
  7. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/__init__.py +1 -0
  8. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/dataset.py +1 -4
  9. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/evaluation.py +4 -5
  10. ragaai_catalyst-2.1b2/ragaai_catalyst/guard_executor.py +97 -0
  11. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/guardrails_manager.py +41 -15
  12. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/internal_api_completion.py +1 -1
  13. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/prompt_manager.py +7 -2
  14. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/ragaai_catalyst.py +1 -1
  15. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/synthetic_data_generation.py +7 -0
  16. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/__init__.py +1 -1
  17. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/__init__.py +3 -0
  18. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +422 -0
  19. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py +198 -0
  20. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/base.py +376 -0
  21. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/data_structure.py +248 -0
  22. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb +536 -0
  23. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb +134 -0
  24. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb +563 -0
  25. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py +46 -0
  26. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py +808 -0
  27. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/network_tracer.py +286 -0
  28. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/sample.py +197 -0
  29. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py +247 -0
  30. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +165 -0
  31. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py +172 -0
  32. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py +187 -0
  33. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/upload_code.py +115 -0
  34. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +43 -0
  35. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +3 -0
  36. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +18 -0
  37. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py +61 -0
  38. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +32 -0
  39. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +177 -0
  40. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +7823 -0
  41. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +74 -0
  42. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py +184 -0
  43. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/exporters/raga_exporter.py +1 -7
  44. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/tracer.py +30 -4
  45. ragaai_catalyst-2.1b2/ragaai_catalyst/tracers/upload_traces.py +127 -0
  46. ragaai_catalyst-2.1b2/ragaai_catalyst.egg-info/PKG-INFO +43 -0
  47. ragaai_catalyst-2.1b2/ragaai_catalyst.egg-info/SOURCES.txt +75 -0
  48. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst.egg-info/requires.txt +7 -1
  49. ragaai_catalyst-2.1b2/requirements.txt +96 -0
  50. ragaai_catalyst-2.1b2/sync_sample_llm_testing.py +65 -0
  51. ragaai_catalyst-2.1b2/test/test_catalyst/test_configuration.py +199 -0
  52. ragaai_catalyst-2.1b2/test/test_catalyst/test_dataset.py +170 -0
  53. ragaai_catalyst-2.1b2/test/test_catalyst/test_evaluation.py +503 -0
  54. ragaai_catalyst-2.1b2/test/test_catalyst/test_prompt_manager.py +88 -0
  55. ragaai_catalyst-2.1b2/test/test_catalyst/test_synthetic_data_generation.py +151 -0
  56. ragaai_catalyst-2.1b0/PKG-INFO +0 -295
  57. ragaai_catalyst-2.1b0/README.md +0 -257
  58. ragaai_catalyst-2.1b0/ragaai_catalyst.egg-info/PKG-INFO +0 -295
  59. ragaai_catalyst-2.1b0/ragaai_catalyst.egg-info/SOURCES.txt +0 -38
  60. ragaai_catalyst-2.1b0/requirements.txt +0 -9
  61. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/.gitignore +0 -0
  62. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/__init__.py +0 -0
  63. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/docs/dataset_management.md +0 -0
  64. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/docs/prompt_management.md +0 -0
  65. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/examples/prompt_management_litellm.ipynb +0 -0
  66. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/examples/prompt_management_openai.ipynb +0 -0
  67. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/_version.py +0 -0
  68. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/experiment.py +0 -0
  69. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/proxy_call.py +0 -0
  70. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
  71. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
  72. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
  73. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
  74. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
  75. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
  76. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/llamaindex_callback.py +0 -0
  77. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
  78. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/tracers/utils/utils.py +0 -0
  79. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst/utils.py +0 -0
  80. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
  81. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/ragaai_catalyst.egg-info/top_level.txt +0 -0
  82. {ragaai_catalyst-2.1b0 → ragaai_catalyst-2.1b2}/setup.cfg +0 -0
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.1
2
+ Name: ragaai_catalyst
3
+ Version: 2.1b2
4
+ Summary: RAGA AI CATALYST
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: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: aiohttp>=3.10.2
9
+ Requires-Dist: opentelemetry-api==1.25.0
10
+ Requires-Dist: opentelemetry-sdk==1.25.0
11
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc==1.25.0
12
+ Requires-Dist: opentelemetry-instrumentation==0.46b0
13
+ Requires-Dist: opentelemetry-instrumentation-fastapi==0.46b0
14
+ Requires-Dist: opentelemetry-instrumentation-asgi==0.46b0
15
+ Requires-Dist: opentelemetry-semantic-conventions==0.46b0
16
+ Requires-Dist: opentelemetry-util-http==0.46b0
17
+ Requires-Dist: opentelemetry-instrumentation-langchain~=0.24.0
18
+ Requires-Dist: opentelemetry-instrumentation-openai~=0.24.0
19
+ Requires-Dist: langchain-core>=0.2.11
20
+ Requires-Dist: langchain>=0.2.11
21
+ Requires-Dist: openai>=1.57.0
22
+ Requires-Dist: pandas>=2.1.1
23
+ Requires-Dist: groq>=0.11.0
24
+ Requires-Dist: PyPDF2>=3.0.1
25
+ Requires-Dist: google-generativeai>=0.8.2
26
+ Requires-Dist: Markdown>=3.7
27
+ Requires-Dist: litellm==1.51.1
28
+ Requires-Dist: tenacity==8.3.0
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~=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
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest; extra == "dev"
39
+ Requires-Dist: pytest-cov; extra == "dev"
40
+ Requires-Dist: black; extra == "dev"
41
+ Requires-Dist: isort; extra == "dev"
42
+ Requires-Dist: mypy; extra == "dev"
43
+ Requires-Dist: flake8; extra == "dev"
@@ -0,0 +1,253 @@
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
+ import vertexai
18
+ from vertexai.generative_models import GenerativeModel
19
+
20
+
21
+ catalyst = RagaAICatalyst(
22
+ access_key="mp4NjrgFqjavNti38Uh4",
23
+ secret_key="9OC0ZIiVZQRA4sYsb4025cfUbRPD3s5RTl3iho2U",
24
+ base_url="https://llm-dev5.ragaai.ai/api"
25
+ )
26
+ # Initialize tracer
27
+ tracer = Tracer(
28
+ project_name="Alteryx_Copilot_DS",
29
+ dataset_name="AITravelAgent",
30
+ tracer_type="AgenticTracing",
31
+ metadata={
32
+ "model": "google/gemini-1.5-flash-002",
33
+ "environment": "production"
34
+ },
35
+ pipeline={
36
+ "llm_model": "google/gemini-1.5-flash-002",
37
+ "vector_store": "faiss",
38
+ "embed_model": "text-embedding-ada-002",
39
+ }
40
+ )
41
+ load_dotenv()
42
+
43
+
44
+ tracer.start()
45
+
46
+
47
+ @tracer.trace_llm(name="llm_call")
48
+ def llm_call(prompt, max_tokens=512, model="gemini-1.5-flash-002", name="default"):
49
+ import vertexai
50
+ from vertexai.generative_models import GenerativeModel
51
+
52
+ # Initialize Vertex AI
53
+ project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
54
+ location = os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
55
+ vertexai.init(project=project_id, location=location)
56
+
57
+ # Create model instance
58
+ model = GenerativeModel(model)
59
+
60
+ # Generate content
61
+ response = model.generate_content(
62
+ prompt,
63
+ generation_config={
64
+ "max_output_tokens": max_tokens,
65
+ "temperature": 0.7,
66
+ }
67
+ )
68
+
69
+ actual_response = response.text.strip()
70
+
71
+ return actual_response
72
+
73
+
74
+ # Tools outside agents
75
+ @tracer.trace_tool(name="weather_tool")
76
+ def weather_tool(destination):
77
+ api_key = os.environ.get("OPENWEATHERMAP_API_KEY")
78
+ base_url = "http://api.openweathermap.org/data/2.5/weather"
79
+
80
+ params = {"q": destination, "appid": api_key, "units": "metric"}
81
+ print("Calculating weather for:", destination)
82
+ try:
83
+ response = requests.get(base_url, params=params)
84
+ response.raise_for_status()
85
+ data = response.json()
86
+
87
+ weather_description = data["weather"][0]["description"]
88
+ temperature = data["main"]["temp"]
89
+
90
+ actual_result = f"{weather_description.capitalize()}, {temperature:.1f}°C"
91
+
92
+ return actual_result
93
+ except requests.RequestException:
94
+ return "Weather data not available."
95
+
96
+
97
+ @tracer.trace_tool(name="currency_converter_tool")
98
+ def currency_converter_tool(amount, from_currency, to_currency):
99
+ api_key = os.environ.get("EXCHANGERATE_API_KEY")
100
+ base_url = f"https://v6.exchangerate-api.com/v6/{api_key}/pair/{from_currency}/{to_currency}"
101
+
102
+ try:
103
+ response = requests.get(base_url)
104
+ response.raise_for_status()
105
+ data = response.json()
106
+
107
+ if data["result"] == "success":
108
+ rate = data["conversion_rate"]
109
+ actual_result = amount * rate
110
+
111
+ return actual_result
112
+ else:
113
+ return None
114
+ except requests.RequestException:
115
+ return None
116
+
117
+
118
+ @tracer.trace_tool(name="flight_price_estimator_tool")
119
+ def flight_price_estimator_tool(origin, destination):
120
+ # This is a mock function. In a real scenario, you'd integrate with a flight API.
121
+ actual_result = f"Estimated price from {origin} to {destination}: $500-$1000"
122
+
123
+ return actual_result
124
+
125
+
126
+ # Agent with persona
127
+ class ItineraryAgent:
128
+ def __init__(self, persona="Itinerary Agent"):
129
+ self.persona = persona
130
+
131
+ @tracer.trace_llm(name="plan_itinerary")
132
+ def plan_itinerary(self, user_preferences, duration=3):
133
+ # Get weather information
134
+ weather = weather_tool(user_preferences["destination"])
135
+
136
+ # Get currency conversion if needed
137
+ if "budget_currency" in user_preferences and user_preferences["budget_currency"] != "USD":
138
+ budget = currency_converter_tool(
139
+ user_preferences["budget"],
140
+ user_preferences["budget_currency"],
141
+ "USD"
142
+ )
143
+ else:
144
+ budget = user_preferences["budget"]
145
+
146
+ # Get flight price estimation
147
+ flight_price = flight_price_estimator_tool(
148
+ user_preferences["origin"],
149
+ user_preferences["destination"]
150
+ )
151
+
152
+ # Prepare prompt for the LLM
153
+ prompt = f"""As a {self.persona}, create a {duration}-day itinerary for a trip to {user_preferences['destination']}.
154
+ Weather: {weather}
155
+ Budget: ${budget}
156
+ Flight Price: {flight_price}
157
+ Preferences: {user_preferences.get('preferences', 'No specific preferences')}
158
+
159
+ Please provide a detailed day-by-day itinerary."""
160
+
161
+ # Get itinerary from LLM
162
+ itinerary = llm_call(prompt)
163
+ return itinerary
164
+
165
+
166
+ # Main function
167
+ @tracer.trace_agent(name="travel_agent")
168
+ def travel_agent():
169
+ print("Welcome to the Personalized Travel Planner!\n")
170
+
171
+ # Get user input
172
+ # user_input = input("Please describe your ideal vacation: ")
173
+ # user_input = input("Please describe your ideal vacation: ")
174
+ user_input = "Antartica, 2 days, $10000, scientific"
175
+
176
+ # Extract preferences
177
+ preferences_prompt = f"""
178
+ Extract key travel preferences from the following user input:
179
+ "{user_input}"
180
+
181
+ Please provide the extracted information in this format:
182
+ Destination:
183
+ Activities:
184
+ Budget:
185
+ Duration (in days):
186
+ """
187
+ extracted_preferences = llm_call(preferences_prompt, name="extract_preferences")
188
+ print("\nExtracted Preferences:")
189
+ print(extracted_preferences)
190
+
191
+ # Parse extracted preferences
192
+ preferences = {}
193
+ for line in extracted_preferences.split("\n"):
194
+ if ":" in line:
195
+ key, value = line.split(":", 1)
196
+ preferences[key.strip()] = value.strip()
197
+
198
+ # Validate extracted preferences
199
+ required_keys = ["Destination", "Activities", "Budget", "Duration (in days)"]
200
+ if not all(key in preferences for key in required_keys):
201
+ print("\nCould not extract all required preferences. Please try again.")
202
+ return
203
+
204
+ # Fetch additional information
205
+ weather = weather_tool(preferences["Destination"])
206
+ print(f"\nWeather in {preferences['Destination']}: {weather}")
207
+
208
+ # origin = input("Please enter your departure city: ")
209
+ print("Please enter your departure city: ")
210
+ origin = input("Please enter your departure city: ")
211
+ # "delhi"
212
+ flight_price = flight_price_estimator_tool(origin, preferences["Destination"])
213
+ print(flight_price)
214
+
215
+ # Plan itinerary
216
+ itinerary_agent = ItineraryAgent()
217
+ itinerary = itinerary_agent.plan_itinerary(
218
+ {"destination": preferences["Destination"], "origin": origin, "budget": float(preferences["Budget"].replace("$", "")), "budget_currency": "USD"},
219
+ int(preferences["Duration (in days)"])
220
+ )
221
+ print("\nPlanned Itinerary:")
222
+ print(itinerary)
223
+
224
+ # Currency conversion
225
+ budget_amount = float(preferences["Budget"].replace("$", "").replace(",", ""))
226
+ converted_budget = currency_converter_tool(budget_amount, "USD", "INR")
227
+ if converted_budget:
228
+ print(f"\nBudget in INR: {converted_budget:.2f} INR")
229
+ else:
230
+ print("\nCurrency conversion not available.")
231
+
232
+ # Generate travel summary
233
+ summary_prompt = f"""
234
+ Summarize the following travel plan:
235
+
236
+ Destination: {preferences['Destination']}
237
+ Activities: {preferences['Activities']}
238
+ Budget: {preferences['Budget']}
239
+ Duration: {preferences['Duration (in days)']} days
240
+ Itinerary: {itinerary}
241
+ Weather: {weather}
242
+ Flight Price: {flight_price}
243
+
244
+ Travel Summary:
245
+ """
246
+ travel_summary = llm_call(summary_prompt, name="generate_summary")
247
+ print("\nTravel Summary:")
248
+ print(travel_summary)
249
+
250
+
251
+ if __name__ == "__main__":
252
+ travel_agent()
253
+ tracer.stop()