ragaai-catalyst 2.1b1__tar.gz → 2.1b3__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 (84) hide show
  1. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/PKG-INFO +1 -1
  2. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ai_travel_agent.py +19 -33
  3. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/pyproject.toml +1 -1
  4. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py +1 -0
  5. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/base.py +7 -11
  6. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py +6 -6
  7. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py +4 -0
  8. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py +5 -161
  9. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst.egg-info/PKG-INFO +1 -1
  10. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst.egg-info/SOURCES.txt +8 -1
  11. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/requirements.txt +0 -1
  12. ragaai_catalyst-2.1b3/traces/2439beda-8f3a-45c3-82de-4f72624c6ce9.json +309 -0
  13. ragaai_catalyst-2.1b3/traces/cd571931-29fe-4d57-9523-71381c97abb1.json +302 -0
  14. ragaai_catalyst-2.1b3/traces/d3d5ad2d-6a98-40d6-8b69-8b082eab1bc2.json +1018 -0
  15. ragaai_catalyst-2.1b3/traces/ed050fde-8705-4635-8570-3aa7f6e4b286.json +334 -0
  16. ragaai_catalyst-2.1b3/traces/f2d41172-f89e-47e4-9523-1c1fe6ce20eb.json +302 -0
  17. ragaai_catalyst-2.1b3/traces/prompt_metric_dataset_finance.json +827 -0
  18. ragaai_catalyst-2.1b3/traces/prompt_metric_dataset_travel.json +829 -0
  19. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/.gitignore +0 -0
  20. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/__init__.py +0 -0
  21. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/catalyst_v2.ipynb +0 -0
  22. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/docs/dataset_management.md +0 -0
  23. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/docs/prompt_management.md +0 -0
  24. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/examples/prompt_management_litellm.ipynb +0 -0
  25. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/examples/prompt_management_openai.ipynb +0 -0
  26. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/finance_agent_catalyst.ipynb +0 -0
  27. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/financial_analysis_agent.py +0 -0
  28. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/__init__.py +0 -0
  29. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/_version.py +0 -0
  30. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/dataset.py +0 -0
  31. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/evaluation.py +0 -0
  32. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/experiment.py +0 -0
  33. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/guard_executor.py +0 -0
  34. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/guardrails_manager.py +0 -0
  35. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/internal_api_completion.py +0 -0
  36. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/prompt_manager.py +0 -0
  37. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/proxy_call.py +0 -0
  38. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/ragaai_catalyst.py +0 -0
  39. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/synthetic_data_generation.py +0 -0
  40. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/__init__.py +0 -0
  41. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/__init__.py +0 -0
  42. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +0 -0
  43. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/data_structure.py +0 -0
  44. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb +0 -0
  45. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb +0 -0
  46. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb +0 -0
  47. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/network_tracer.py +0 -0
  48. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/sample.py +0 -0
  49. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py +0 -0
  50. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +0 -0
  51. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py +0 -0
  52. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py +0 -0
  53. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/upload_code.py +0 -0
  54. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +0 -0
  55. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +0 -0
  56. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +0 -0
  57. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py +0 -0
  58. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +0 -0
  59. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +0 -0
  60. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +0 -0
  61. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +0 -0
  62. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
  63. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
  64. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/exporters/raga_exporter.py +0 -0
  65. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
  66. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
  67. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
  68. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
  69. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/llamaindex_callback.py +0 -0
  70. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/tracer.py +0 -0
  71. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/upload_traces.py +0 -0
  72. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
  73. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/tracers/utils/utils.py +0 -0
  74. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst/utils.py +0 -0
  75. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
  76. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst.egg-info/requires.txt +0 -0
  77. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/ragaai_catalyst.egg-info/top_level.txt +0 -0
  78. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/setup.cfg +0 -0
  79. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/sync_sample_llm_testing.py +0 -0
  80. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/test/test_catalyst/test_configuration.py +0 -0
  81. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/test/test_catalyst/test_dataset.py +0 -0
  82. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/test/test_catalyst/test_evaluation.py +0 -0
  83. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/test/test_catalyst/test_prompt_manager.py +0 -0
  84. {ragaai_catalyst-2.1b1 → ragaai_catalyst-2.1b3}/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.1b1
3
+ Version: 2.1b3
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
@@ -14,26 +14,23 @@ load_dotenv()
14
14
  from litellm import completion
15
15
  import openai
16
16
  from openai import AsyncOpenAI
17
- import vertexai
18
- from vertexai.generative_models import GenerativeModel
19
-
20
17
 
21
18
  catalyst = RagaAICatalyst(
22
- access_key="mp4NjrgFqjavNti38Uh4",
23
- secret_key="9OC0ZIiVZQRA4sYsb4025cfUbRPD3s5RTl3iho2U",
24
- base_url="https://llm-dev5.ragaai.ai/api"
19
+ access_key="saLy6KmMVlfAzunuQGS9",
20
+ secret_key="lm39fd4KXffM6gzLjnY9G7QReffhH4RGZPursp3A",
21
+ base_url="http://52.172.168.127/api"
25
22
  )
26
23
  # Initialize tracer
27
24
  tracer = Tracer(
28
- project_name="Alteryx_Copilot_DS",
29
- dataset_name="AITravelAgent",
30
- tracer_type="AgenticTracing",
25
+ project_name="prompt_metric_dataset",
26
+ dataset_name="ChatOpenAI_tan",
27
+ tracer_type="anything",
31
28
  metadata={
32
- "model": "google/gemini-1.5-flash-002",
29
+ "model": "gpt-3.5-turbo",
33
30
  "environment": "production"
34
31
  },
35
32
  pipeline={
36
- "llm_model": "google/gemini-1.5-flash-002",
33
+ "llm_model": "gpt-3.5-turbo",
37
34
  "vector_store": "faiss",
38
35
  "embed_model": "text-embedding-ada-002",
39
36
  }
@@ -45,28 +42,17 @@ tracer.start()
45
42
 
46
43
 
47
44
  @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
- }
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,
67
53
  )
68
54
 
69
- actual_response = response.text.strip()
55
+ actual_response = response.choices[0].message.content.strip()
70
56
 
71
57
  return actual_response
72
58
 
@@ -170,8 +156,8 @@ def travel_agent():
170
156
 
171
157
  # Get user input
172
158
  # 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"
159
+ user_input = input("Please describe your ideal vacation: ")
160
+ #"karela, 10 days, $100, nature"
175
161
 
176
162
  # Extract preferences
177
163
  preferences_prompt = f"""
@@ -8,7 +8,7 @@ description = "RAGA AI CATALYST"
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.9"
10
10
  # license = {file = "LICENSE"}
11
- version = "2.1.beta.1"
11
+ version = "2.1.beta.3"
12
12
  authors = [
13
13
  {name = "Kiran Scaria", email = "kiran.scaria@raga.ai"},
14
14
  {name = "Kedar Gaikwad", email = "kedar.gaikwad@raga.ai"},
@@ -112,6 +112,7 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
112
112
 
113
113
  # Cleanup
114
114
  self.unpatch_llm_calls()
115
+ self.user_interaction_tracer.interactions = [] # Clear interactions list
115
116
  self.is_active = False
116
117
 
117
118
 
@@ -1,27 +1,24 @@
1
1
  import json
2
2
  import os
3
3
  import platform
4
- import re
5
4
  import psutil
6
5
  import pkg_resources
7
6
  from datetime import datetime
8
7
  from pathlib import Path
9
- from typing import Optional, Dict, Any, List
8
+ from typing import List
10
9
  import uuid
11
10
  import sys
11
+ import tempfile
12
12
 
13
13
  from .data_structure import (
14
14
  Trace, Metadata, SystemInfo, OSInfo, EnvironmentInfo,
15
15
  Resources, CPUResource, MemoryResource, DiskResource, NetworkResource,
16
16
  ResourceInfo, MemoryInfo, DiskInfo, NetworkInfo,
17
- Component, LLMComponent, AgentComponent, ToolComponent,
18
- NetworkCall, Interaction, Error
17
+ Component,
19
18
  )
20
19
 
21
- from ..upload_traces import UploadTraces
22
20
  from .upload_agentic_traces import UploadAgenticTraces
23
21
  from .upload_code import upload_code
24
- from ...ragaai_catalyst import RagaAICatalyst
25
22
 
26
23
  from .file_name_tracker import TrackName
27
24
  from .zip_list_of_unique_files import zip_list_of_unique_files
@@ -182,14 +179,13 @@ class BaseTracer:
182
179
  self.trace = self._extract_cost_tokens(self.trace)
183
180
 
184
181
  # Create traces directory if it doesn't exist
185
- self.traces_dir = Path("traces")
186
- self.traces_dir.mkdir(exist_ok=True)
182
+ self.traces_dir = tempfile.gettempdir()
187
183
  filename = self.trace.id + ".json"
188
- filepath = self.traces_dir / filename
184
+ filepath = f"{self.traces_dir}/{filename}"
189
185
 
190
186
  #get unique files and zip it. Generate a unique hash ID for the contents of the files
191
187
  list_of_unique_files = self.file_tracker.get_unique_files()
192
- hash_id, zip_path = zip_list_of_unique_files(list_of_unique_files)
188
+ hash_id, zip_path = zip_list_of_unique_files(list_of_unique_files, output_dir=self.traces_dir)
193
189
 
194
190
  #replace source code with zip_path
195
191
  self.trace.metadata.system_info.source_code = hash_id
@@ -230,7 +226,7 @@ class BaseTracer:
230
226
 
231
227
  # Cleanup
232
228
  self.components = []
233
- self.file_tracker = TrackName()
229
+ self.file_tracker.reset()
234
230
 
235
231
  def add_component(self, component: Component):
236
232
  """Add a component to the trace"""
@@ -8,13 +8,9 @@ class TrackName:
8
8
  def trace_decorator(self, func):
9
9
  @wraps(func)
10
10
  def wrapper(*args, **kwargs):
11
- # frame = inspect.stack()[1]
12
- # file_name = frame.filename
13
11
  file_name = self._get_file_name()
14
- # print(f"Called from file: {frame.filename}")
15
- # print(f"Called from line: {frame.lineno}")
16
- # print(f"Called from function: {frame.function}")
17
12
  self.files.add(file_name)
13
+
18
14
  return func(*args, **kwargs)
19
15
  return wrapper
20
16
 
@@ -43,4 +39,8 @@ class TrackName:
43
39
 
44
40
 
45
41
  def get_unique_files(self):
46
- return list(self.files)
42
+ return list(self.files)
43
+
44
+ def reset(self):
45
+ """Reset the file tracker by clearing all tracked files."""
46
+ self.files.clear()
@@ -654,6 +654,10 @@ class LLMTracerMixin:
654
654
  finally:
655
655
 
656
656
  llm_component = self.llm_data
657
+ llm_component['name'] = name
658
+
659
+ if self.gt:
660
+ llm_component["data"]["gt"] = self.gt
657
661
 
658
662
  if error_info:
659
663
  llm_component["error"] = error_info["error"]
@@ -1,161 +1,3 @@
1
- # import os
2
- # import hashlib
3
- # import zipfile
4
- # import re
5
- # import ast
6
- # import importlib.util
7
- # import json
8
- # from pathlib import Path
9
-
10
- # class TraceDependencyTracker:
11
- # def __init__(self, output_dir=None):
12
- # self.tracked_files = set()
13
- # self.python_imports = set()
14
- # self.output_dir = output_dir or os.getcwd()
15
-
16
- # def track_file_access(self, filepath):
17
- # """Track a file that's been accessed."""
18
- # if os.path.exists(filepath):
19
- # self.tracked_files.add(os.path.abspath(filepath))
20
-
21
- # def find_config_files(self, content, base_path):
22
- # """Find configuration files referenced in the content."""
23
- # patterns = [
24
- # r'(?:open|read|load|with\s+open)\s*\([\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
25
- # r'(?:config|cfg|conf|settings|file|path)(?:_file|_path)?\s*=\s*[\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
26
- # r'[\'"]([^\'"]*\.txt)[\'"]',
27
- # r'[\'"]([^\'"]*\.(?:yaml|yml))[\'"]',
28
- # r'from\s+(\S+)\s+import',
29
- # r'import\s+(\S+)'
30
- # ]
31
-
32
- # for pattern in patterns:
33
- # matches = re.finditer(pattern, content)
34
- # for match in matches:
35
- # filepath = match.group(1)
36
- # if not os.path.isabs(filepath):
37
- # full_path = os.path.join(os.path.dirname(base_path), filepath)
38
- # else:
39
- # full_path = filepath
40
-
41
- # if os.path.exists(full_path):
42
- # self.track_file_access(full_path)
43
- # try:
44
- # with open(full_path, 'r', encoding='utf-8') as f:
45
- # self.find_config_files(f.read(), full_path)
46
- # except (UnicodeDecodeError, IOError):
47
- # pass
48
-
49
- # def analyze_python_imports(self, filepath):
50
- # """Analyze Python file for imports and track imported files."""
51
- # try:
52
- # with open(filepath, 'r', encoding='utf-8') as file:
53
- # tree = ast.parse(file.read(), filename=filepath)
54
-
55
- # for node in ast.walk(tree):
56
- # if isinstance(node, (ast.Import, ast.ImportFrom)):
57
- # if isinstance(node, ast.ImportFrom) and node.module:
58
- # module_name = node.module
59
- # else:
60
- # for name in node.names:
61
- # module_name = name.name.split('.')[0]
62
-
63
- # try:
64
- # spec = importlib.util.find_spec(module_name)
65
- # if spec and spec.origin and not spec.origin.startswith(os.path.dirname(importlib.__file__)):
66
- # self.python_imports.add(spec.origin)
67
- # except (ImportError, AttributeError):
68
- # pass
69
- # except Exception as e:
70
- # print(f"Warning: Could not analyze imports in {filepath}: {str(e)}")
71
-
72
- # def create_zip(self, filepaths):
73
- # """
74
- # Process files and create a single zip with all dependencies.
75
-
76
- # Args:
77
- # filepaths (list): List of file paths to process.
78
-
79
- # Returns:
80
- # tuple: A tuple containing the hash ID (str) and the path to the saved .zip file (str).
81
- # """
82
- # # Process all files and their dependencies
83
- # for filepath in filepaths:
84
- # abs_path = os.path.abspath(filepath)
85
- # self.track_file_access(abs_path)
86
-
87
- # try:
88
- # with open(abs_path, 'r', encoding='utf-8') as file:
89
- # content = file.read()
90
-
91
- # self.find_config_files(content, abs_path)
92
-
93
- # if filepath.endswith('.py'):
94
- # self.analyze_python_imports(abs_path)
95
- # except Exception as e:
96
- # print(f"Warning: Could not process {filepath}: {str(e)}")
97
-
98
- # # Add Python imports to tracked files
99
- # self.tracked_files.update(self.python_imports)
100
-
101
- # # Generate hash from all files
102
- # hash_contents = []
103
- # for filepath in sorted(self.tracked_files):
104
- # # Skip any file paths that contain 'env'
105
- # if 'env' in filepath:
106
- # continue # Skip env folder
107
- # try:
108
- # with open(filepath, 'rb') as file:
109
- # content = file.read()
110
- # hash_contents.append(content)
111
- # except Exception as e:
112
- # print(f"Warning: Could not read {filepath} for hash calculation: {str(e)}")
113
-
114
- # combined_content = b''.join(hash_contents)
115
- # hash_id = hashlib.sha256(combined_content).hexdigest()
116
-
117
- # # Create zip file
118
- # zip_filename = os.path.join(self.output_dir, f'{hash_id}.zip')
119
-
120
- # # Determine base path excluding 'env' folders
121
- # base_path = os.path.commonpath([os.path.abspath(p) for p in self.tracked_files if 'env' not in p])
122
-
123
- # with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
124
- # for filepath in sorted(self.tracked_files):
125
- # # Skip any file paths that contain 'env'
126
- # if 'env' in filepath:
127
- # continue # Skip env folder
128
- # try:
129
- # relative_path = os.path.relpath(filepath, base_path)
130
- # zipf.write(filepath, relative_path)
131
- # print(f"Added to zip: {relative_path}")
132
- # except Exception as e:
133
- # print(f"Warning: Could not add {filepath} to zip: {str(e)}")
134
-
135
- # return hash_id, zip_filename
136
-
137
- # def zip_list_of_unique_files(filepaths):
138
- # """
139
- # Enhanced version of the original function that tracks all dependencies.
140
-
141
- # Args:
142
- # filepaths (list): List of file paths to process.
143
-
144
- # Returns:
145
- # tuple: A tuple containing the hash ID (str) and the path to the saved .zip file (str).
146
- # """
147
- # tracker = TraceDependencyTracker()
148
- # return tracker.create_zip(filepaths)
149
-
150
- # if __name__ == "__main__":
151
- # filepaths = ["script1.py", "script2.py"]
152
- # hash_id, zip_path = zip_list_of_unique_files(filepaths)
153
- # print(f"Created zip file: {zip_path}")
154
- # print(f"Hash ID: {hash_id}")
155
-
156
-
157
-
158
-
159
1
  import os
160
2
  import hashlib
161
3
  import zipfile
@@ -165,6 +7,8 @@ import importlib.util
165
7
  import json
166
8
  import astor
167
9
  from pathlib import Path
10
+ import logging
11
+ logger = logging.getLogger(__name__)
168
12
 
169
13
  # Define the PackageUsageRemover class
170
14
  class PackageUsageRemover(ast.NodeTransformer):
@@ -323,15 +167,15 @@ class TraceDependencyTracker:
323
167
  try:
324
168
  relative_path = os.path.relpath(filepath, base_path)
325
169
  zipf.write(filepath, relative_path)
326
- print(f"Added to zip: {relative_path}")
170
+ # logger.info(f"Added to zip: {relative_path}")
327
171
  except Exception as e:
328
172
  print(f"Warning: Could not add {filepath} to zip: {str(e)}")
329
173
 
330
174
  return hash_id, zip_filename
331
175
 
332
176
  # Main function for creating a zip of unique files
333
- def zip_list_of_unique_files(filepaths):
334
- tracker = TraceDependencyTracker()
177
+ def zip_list_of_unique_files(filepaths, output_dir):
178
+ tracker = TraceDependencyTracker(output_dir)
335
179
  return tracker.create_zip(filepaths)
336
180
 
337
181
  # Example usage
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 2.1b1
3
+ Version: 2.1b3
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
@@ -72,4 +72,11 @@ test/test_catalyst/test_configuration.py
72
72
  test/test_catalyst/test_dataset.py
73
73
  test/test_catalyst/test_evaluation.py
74
74
  test/test_catalyst/test_prompt_manager.py
75
- test/test_catalyst/test_synthetic_data_generation.py
75
+ test/test_catalyst/test_synthetic_data_generation.py
76
+ traces/2439beda-8f3a-45c3-82de-4f72624c6ce9.json
77
+ traces/cd571931-29fe-4d57-9523-71381c97abb1.json
78
+ traces/d3d5ad2d-6a98-40d6-8b69-8b082eab1bc2.json
79
+ traces/ed050fde-8705-4635-8570-3aa7f6e4b286.json
80
+ traces/f2d41172-f89e-47e4-9523-1c1fe6ce20eb.json
81
+ traces/prompt_metric_dataset_finance.json
82
+ traces/prompt_metric_dataset_travel.json
@@ -20,7 +20,6 @@ google-api-core==2.24.0
20
20
  google-api-python-client==2.156.0
21
21
  google-auth==2.37.0
22
22
  google-auth-httplib2==0.2.0
23
- google-cloud-aiplatform==1.45.0
24
23
  google-generativeai==0.8.3
25
24
  googleapis-common-protos==1.66.0
26
25
  groq==0.13.1