ragaai-catalyst 2.1.4.1b1__tar.gz → 2.1.5b0__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.
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/.gitignore +1 -0
- {ragaai_catalyst-2.1.4.1b1/ragaai_catalyst.egg-info → ragaai_catalyst-2.1.5b0}/PKG-INFO +1 -2
- ragaai_catalyst-2.1.5b0/examples/custom_tracer_example.py +125 -0
- ragaai_catalyst-2.1.5b0/examples/finance.py +161 -0
- ragaai_catalyst-2.1.5b0/examples/travel_agent/agents.py +50 -0
- ragaai_catalyst-2.1.5b0/examples/travel_agent/config.py +24 -0
- ragaai_catalyst-2.1.5b0/examples/travel_agent/main.py +115 -0
- ragaai_catalyst-2.1.5b0/examples/travel_agent/tools.py +88 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/pyproject.toml +1 -2
- ragaai_catalyst-2.1.5b0/ragaai_catalyst/__init__.py +30 -0
- ragaai_catalyst-2.1.5b0/ragaai_catalyst/tracers/__init__.py +19 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +69 -38
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +1 -1
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +16 -1
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py +3 -3
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py +6 -6
- ragaai_catalyst-2.1.5b0/ragaai_catalyst/tracers/distributed.py +286 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0/ragaai_catalyst.egg-info}/PKG-INFO +1 -2
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst.egg-info/SOURCES.txt +7 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst.egg-info/requires.txt +0 -1
- ragaai_catalyst-2.1.4.1b1/ragaai_catalyst/__init__.py +0 -13
- ragaai_catalyst-2.1.4.1b1/ragaai_catalyst/tracers/__init__.py +0 -3
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/LICENSE +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/README.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/docs/dataset_management.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/docs/prompt_management.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/examples/FinancialAnalysisSystem.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/examples/TravelPlanner.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/examples/prompt_management_litellm.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/examples/prompt_management_openai.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/_version.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/dataset.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/evaluation.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/experiment.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/guard_executor.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/guardrails_manager.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/internal_api_completion.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/prompt_manager.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/proxy_call.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/ragaai_catalyst.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/synthetic_data_generation.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/README.md +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/data/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/FinancialAnalysisSystem.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/GameActivityEventPlanner.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/TravelPlanner.ipynb +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/upload/upload_agentic_traces.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/upload/upload_code.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/exporters/raga_exporter.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/llamaindex_callback.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/tracer.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/upload_traces.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/tracers/utils/utils.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst/utils.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/ragaai_catalyst.egg-info/top_level.txt +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/requirements.txt +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/setup.cfg +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/test/test_catalyst/test_configuration.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/test/test_catalyst/test_dataset.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/test/test_catalyst/test_evaluation.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/test/test_catalyst/test_prompt_manager.py +0 -0
- {ragaai_catalyst-2.1.4.1b1 → ragaai_catalyst-2.1.5b0}/test/test_catalyst/test_synthetic_data_generation.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b0
|
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.13,>=3.9
|
@@ -34,7 +34,6 @@ Requires-Dist: psutil~=6.0.0
|
|
34
34
|
Requires-Dist: py-cpuinfo~=9.0.0
|
35
35
|
Requires-Dist: requests~=2.32.3
|
36
36
|
Requires-Dist: GPUtil~=1.4.0
|
37
|
-
Requires-Dist: astor>=0.8.1
|
38
37
|
Requires-Dist: ipynbname
|
39
38
|
Provides-Extra: dev
|
40
39
|
Requires-Dist: pytest; extra == "dev"
|
@@ -0,0 +1,125 @@
|
|
1
|
+
from ragaai_catalyst.tracers import Tracer
|
2
|
+
from ragaai_catalyst import RagaAICatalyst
|
3
|
+
import asyncio
|
4
|
+
import os
|
5
|
+
import requests
|
6
|
+
from dotenv import load_dotenv
|
7
|
+
load_dotenv()
|
8
|
+
from litellm import completion
|
9
|
+
import openai
|
10
|
+
from openai import OpenAI
|
11
|
+
import sys
|
12
|
+
from pathlib import Path
|
13
|
+
|
14
|
+
# Add the project root to sys.path
|
15
|
+
project_root = Path(__file__).resolve().parent
|
16
|
+
sys.path.append(str(project_root))
|
17
|
+
|
18
|
+
from ragaai_catalyst.tracers.agentic_tracing.tracers.main_tracer import AgenticTracing
|
19
|
+
import json
|
20
|
+
from typing import Dict, List, Any
|
21
|
+
import time
|
22
|
+
|
23
|
+
|
24
|
+
catalyst = RagaAICatalyst(
|
25
|
+
access_key=os.getenv("RAGAAI_CATALYST_ACCESS_KEY"),
|
26
|
+
secret_key=os.getenv("RAGAAI_CATALYST_SECRET_KEY"),
|
27
|
+
base_url=os.getenv("RAGAAI_CATALYST_BASE_URL"),
|
28
|
+
)
|
29
|
+
# Initialize tracer
|
30
|
+
tracer = Tracer(
|
31
|
+
project_name="cost_testing",
|
32
|
+
dataset_name="sync_sample_llm_testing_openai",
|
33
|
+
tracer_type="anything",
|
34
|
+
metadata={
|
35
|
+
"model": "gpt-3.5-turbo",
|
36
|
+
"environment": "production"
|
37
|
+
},
|
38
|
+
pipeline={
|
39
|
+
"llm_model": "gpt-3.5-turbo",
|
40
|
+
"vector_store": "faiss",
|
41
|
+
"embed_model": "text-embedding-ada-002",
|
42
|
+
}
|
43
|
+
)
|
44
|
+
load_dotenv()
|
45
|
+
|
46
|
+
tracer.start()
|
47
|
+
|
48
|
+
|
49
|
+
@tracer.trace_custom(name="process_data", custom_type="data_processor", trace_variables=False)
|
50
|
+
def process_data(data):
|
51
|
+
"""Example function showing custom function tracing with line traces"""
|
52
|
+
processed = []
|
53
|
+
total = 0
|
54
|
+
print('my name is khan1')
|
55
|
+
for i, item in enumerate(data):
|
56
|
+
value = item * 2
|
57
|
+
total += value
|
58
|
+
processed.append(value)
|
59
|
+
if i == len(data) - 1:
|
60
|
+
average = total / len(data)
|
61
|
+
print('average is', average)
|
62
|
+
|
63
|
+
return processed
|
64
|
+
|
65
|
+
@tracer.trace_custom(name="calculate_statistics", custom_type="data_processor", trace_variables=False)
|
66
|
+
def calculate_statistics(numbers):
|
67
|
+
"""Example function using the trace_custom decorator without line traces"""
|
68
|
+
stats = {}
|
69
|
+
|
70
|
+
# Calculate mean
|
71
|
+
total = sum(numbers)
|
72
|
+
count = len(numbers)
|
73
|
+
mean = total / count
|
74
|
+
stats['mean'] = mean
|
75
|
+
|
76
|
+
# Calculate range
|
77
|
+
min_val = min(numbers)
|
78
|
+
max_val = max(numbers)
|
79
|
+
diff = max_val - min_val
|
80
|
+
stats['range'] = diff
|
81
|
+
|
82
|
+
print('my name is khan2')
|
83
|
+
print('stats are', stats)
|
84
|
+
|
85
|
+
return stats
|
86
|
+
|
87
|
+
@tracer.trace_custom(name="network_call", custom_type="network_call", trace_variables=True)
|
88
|
+
def weather_tool(destination='kerela'):
|
89
|
+
api_key = os.environ.get("OPENWEATHERMAP_API_KEY")
|
90
|
+
base_url = "http://api.openweathermap.org/data/2.5/weather"
|
91
|
+
|
92
|
+
params = {"q": destination, "appid": api_key, "units": "metric"}
|
93
|
+
print("Calculating weather for:", destination)
|
94
|
+
try:
|
95
|
+
response = requests.get(base_url, params=params)
|
96
|
+
response.raise_for_status()
|
97
|
+
data = response.json()
|
98
|
+
|
99
|
+
weather_description = data["weather"][0]["description"]
|
100
|
+
temperature = data["main"]["temp"]
|
101
|
+
|
102
|
+
actual_result = f"{weather_description.capitalize()}, {temperature:.1f}°C"
|
103
|
+
|
104
|
+
return actual_result
|
105
|
+
except requests.RequestException:
|
106
|
+
return "Weather data not available."
|
107
|
+
|
108
|
+
|
109
|
+
def main():
|
110
|
+
try:
|
111
|
+
# Example data processing
|
112
|
+
data = [1, 2, 3, 4, 5]
|
113
|
+
processed_data = process_data(data)
|
114
|
+
print("Processed Data:", processed_data)
|
115
|
+
stats = calculate_statistics(processed_data)
|
116
|
+
print("Statistics:", stats)
|
117
|
+
weather_result = weather_tool()
|
118
|
+
print("Weather Result:", weather_result)
|
119
|
+
|
120
|
+
except Exception as e:
|
121
|
+
print(f"Error in main: {str(e)}")
|
122
|
+
|
123
|
+
if __name__ == "__main__":
|
124
|
+
main()
|
125
|
+
tracer.stop()
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import requests
|
2
|
+
from bs4 import BeautifulSoup
|
3
|
+
import yfinance as yf
|
4
|
+
from datetime import datetime
|
5
|
+
import pandas as pd
|
6
|
+
from litellm import completion
|
7
|
+
import os
|
8
|
+
from typing import List, Dict
|
9
|
+
import json
|
10
|
+
from urllib.parse import urlparse
|
11
|
+
from dotenv import load_dotenv
|
12
|
+
from ragaai_catalyst.tracers import Tracer
|
13
|
+
from ragaai_catalyst import RagaAICatalyst
|
14
|
+
load_dotenv()
|
15
|
+
|
16
|
+
catalyst = RagaAICatalyst(
|
17
|
+
access_key=os.getenv("RAGAAI_CATALYST_ACCESS_KEY"),
|
18
|
+
secret_key=os.getenv("RAGAAI_CATALYST_SECRET_KEY"),
|
19
|
+
base_url=os.getenv("RAGAAI_CATALYST_BASE_URL"),
|
20
|
+
)
|
21
|
+
|
22
|
+
# Initialize tracer
|
23
|
+
tracer = Tracer(
|
24
|
+
project_name="alteryx_copilot-tan",
|
25
|
+
dataset_name="testing-3",
|
26
|
+
tracer_type="Agentic",
|
27
|
+
)
|
28
|
+
|
29
|
+
tracer.start()
|
30
|
+
class FinancialReportGenerator:
|
31
|
+
@tracer.trace_tool("scrape_website")
|
32
|
+
def scrape_website(self, url: str) -> str:
|
33
|
+
"""
|
34
|
+
Scrape content from a given URL
|
35
|
+
"""
|
36
|
+
try:
|
37
|
+
headers = {
|
38
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
39
|
+
}
|
40
|
+
response = requests.get(url, headers=headers)
|
41
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
42
|
+
|
43
|
+
# Remove script and style elements
|
44
|
+
for script in soup(["script", "style"]):
|
45
|
+
script.decompose()
|
46
|
+
|
47
|
+
text = soup.get_text(separator=' ', strip=True)
|
48
|
+
return text
|
49
|
+
except Exception as e:
|
50
|
+
print(f"Error scraping {url}: {str(e)}")
|
51
|
+
return ""
|
52
|
+
|
53
|
+
@tracer.trace_llm(name="analyze_sentiment")
|
54
|
+
def analyze_sentiment(self, text: str) -> Dict:
|
55
|
+
"""
|
56
|
+
Analyze sentiment of text using LiteLLM
|
57
|
+
"""
|
58
|
+
try:
|
59
|
+
response = completion(
|
60
|
+
model="gpt-3.5-turbo",
|
61
|
+
messages=[{
|
62
|
+
"role": "system",
|
63
|
+
"content": "Analyze the following text and provide sentiment analysis focused on financial implications. Return a JSON with 'sentiment' (positive/negative/neutral), 'confidence' (0-1), and 'key_points'."
|
64
|
+
}, {
|
65
|
+
"role": "user",
|
66
|
+
"content": text
|
67
|
+
}],
|
68
|
+
max_tokens=500
|
69
|
+
)
|
70
|
+
|
71
|
+
return json.loads(response.choices[0].message.content)
|
72
|
+
except Exception as e:
|
73
|
+
print(f"Error in sentiment analysis: {str(e)}")
|
74
|
+
return {"sentiment": "neutral", "confidence": 0, "key_points": []}
|
75
|
+
|
76
|
+
@tracer.trace_llm(name="get_report")
|
77
|
+
def get_report(self, report_prompt: str) -> str:
|
78
|
+
response = completion(
|
79
|
+
model="gpt-3.5-turbo",
|
80
|
+
messages=[{
|
81
|
+
"role": "system",
|
82
|
+
"content": "You are a financial analyst. Generate a comprehensive financial report based on the provided data. Include market analysis, stock performance, and key insights."
|
83
|
+
}, {
|
84
|
+
"role": "user",
|
85
|
+
"content": report_prompt
|
86
|
+
}],
|
87
|
+
max_tokens=1500
|
88
|
+
)
|
89
|
+
print("Report generated successfully.")
|
90
|
+
return response.choices[0].message.content
|
91
|
+
|
92
|
+
@tracer.trace_agent(name="generate_report")
|
93
|
+
def generate_report(self, urls: List[str]) -> str:
|
94
|
+
"""
|
95
|
+
Generate a comprehensive financial report from multiple sources
|
96
|
+
"""
|
97
|
+
# Collect data from all sources
|
98
|
+
website_contents = []
|
99
|
+
sentiments = []
|
100
|
+
|
101
|
+
print("Processing URLs...")
|
102
|
+
# Process URLs
|
103
|
+
for url in urls:
|
104
|
+
content = self.scrape_website(url)
|
105
|
+
if content:
|
106
|
+
website_contents.append({
|
107
|
+
"url": url,
|
108
|
+
"content": content,
|
109
|
+
"domain": urlparse(url).netloc
|
110
|
+
})
|
111
|
+
print(f"Scraped content from {url}")
|
112
|
+
|
113
|
+
# Analyze sentiment
|
114
|
+
print("Analyzing sentiment...")
|
115
|
+
sentiments.append(self.analyze_sentiment(content))
|
116
|
+
|
117
|
+
print("Generating report...")
|
118
|
+
# Generate report using LiteLLM
|
119
|
+
report_prompt = self._create_report_prompt(website_contents, sentiments)
|
120
|
+
|
121
|
+
report = self.get_report(report_prompt)
|
122
|
+
return report
|
123
|
+
|
124
|
+
@tracer.trace_tool("create_report_prompt")
|
125
|
+
def _create_report_prompt(self, website_contents: List[Dict], sentiments: List[Dict]) -> str:
|
126
|
+
print("Creating report prompt...")
|
127
|
+
"""
|
128
|
+
Create a structured prompt for report generation
|
129
|
+
"""
|
130
|
+
prompt = "Generate a financial report based on the following data:\n\n"
|
131
|
+
|
132
|
+
# Add website content summaries
|
133
|
+
prompt += "News and Analysis:\n"
|
134
|
+
for content in website_contents:
|
135
|
+
prompt += f"Source: {content['domain']}\n"
|
136
|
+
prompt += f"Key points from sentiment analysis:\n"
|
137
|
+
for sentiment in sentiments:
|
138
|
+
prompt += f"- Sentiment: {sentiment['sentiment']}\n"
|
139
|
+
prompt += f"- Key points: {', '.join(sentiment['key_points'])}\n"
|
140
|
+
|
141
|
+
prompt += "\nPlease provide a comprehensive analysis including:\n"
|
142
|
+
prompt += "1. Market Overview\n"
|
143
|
+
prompt += "2. Stock Analysis\n"
|
144
|
+
prompt += "3. News Impact Analysis\n"
|
145
|
+
prompt += "4. Key Insights and Recommendations\n"
|
146
|
+
|
147
|
+
return prompt
|
148
|
+
|
149
|
+
# Example usage
|
150
|
+
if __name__ == "__main__":
|
151
|
+
generator = FinancialReportGenerator()
|
152
|
+
|
153
|
+
# Example URLs and stock symbols
|
154
|
+
urls = [
|
155
|
+
"https://money.rediff.com/news/market/rupee-hits-record-low-of-85-83-against-us-dollar/20623520250108",
|
156
|
+
"https://indianexpress.com/article/business/banking-and-finance/rbi-asks-credit-bureaus-banks-to-pay-rs-100-compensation-per-day-for-delay-in-data-updation-9765814/"
|
157
|
+
]
|
158
|
+
|
159
|
+
report = generator.generate_report(urls)
|
160
|
+
print(report)
|
161
|
+
tracer.stop()
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from tools import (
|
2
|
+
llm_call,
|
3
|
+
weather_tool,
|
4
|
+
currency_converter_tool,
|
5
|
+
flight_price_estimator_tool,
|
6
|
+
)
|
7
|
+
from ragaai_catalyst import trace_agent, current_span
|
8
|
+
|
9
|
+
class ItineraryAgent:
|
10
|
+
def __init__(self, persona="Itinerary Agent"):
|
11
|
+
self.persona = persona
|
12
|
+
|
13
|
+
@trace_agent(name="plan_itinerary", agent_type="travel_planner", version="1.0.0")
|
14
|
+
def plan_itinerary(self, user_preferences, duration=3):
|
15
|
+
# Add metrics for the planning process
|
16
|
+
current_span().add_metrics(
|
17
|
+
name="itinerary_planning",
|
18
|
+
score=0.8,
|
19
|
+
reasoning="Planning comprehensive travel itinerary",
|
20
|
+
cost=0.01,
|
21
|
+
latency=0.5,
|
22
|
+
)
|
23
|
+
|
24
|
+
# Get weather information
|
25
|
+
weather = weather_tool(user_preferences["destination"])
|
26
|
+
|
27
|
+
# Get currency conversion if needed
|
28
|
+
if "budget_currency" in user_preferences and user_preferences["budget_currency"] != "USD":
|
29
|
+
budget = currency_converter_tool(
|
30
|
+
user_preferences["budget"], user_preferences["budget_currency"], "USD"
|
31
|
+
)
|
32
|
+
else:
|
33
|
+
budget = user_preferences["budget"]
|
34
|
+
|
35
|
+
# Get flight price estimation
|
36
|
+
flight_price = flight_price_estimator_tool(
|
37
|
+
user_preferences["origin"], user_preferences["destination"]
|
38
|
+
)
|
39
|
+
|
40
|
+
# Prepare prompt for the LLM
|
41
|
+
prompt = f"""As a {self.persona}, create a {duration}-day itinerary for a trip to {user_preferences['destination']}.
|
42
|
+
Weather: {weather}
|
43
|
+
Budget: ${budget}
|
44
|
+
Flight Price: {flight_price}
|
45
|
+
Preferences: {user_preferences.get('preferences', 'No specific preferences')}
|
46
|
+
|
47
|
+
Please provide a detailed day-by-day itinerary."""
|
48
|
+
|
49
|
+
# Generate itinerary using LLM
|
50
|
+
return llm_call(prompt)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import sys
|
2
|
+
import os
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
|
5
|
+
from ragaai_catalyst import RagaAICatalyst, init_tracing
|
6
|
+
from ragaai_catalyst.tracers import Tracer
|
7
|
+
import uuid
|
8
|
+
|
9
|
+
|
10
|
+
def initialize_tracing():
|
11
|
+
catalyst = RagaAICatalyst(
|
12
|
+
access_key=os.getenv("RAGAAI_CATALYST_ACCESS_KEY"),
|
13
|
+
secret_key=os.getenv("RAGAAI_CATALYST_SECRET_KEY"),
|
14
|
+
# base_url=os.getenv("RAGAAI_CATALYST_BASE_URL"),
|
15
|
+
)
|
16
|
+
|
17
|
+
tracer = Tracer(
|
18
|
+
project_name="Trace_testing",
|
19
|
+
dataset_name="travel_agent_dataset",
|
20
|
+
tracer_type="Agentic",
|
21
|
+
)
|
22
|
+
|
23
|
+
init_tracing(catalyst=catalyst, tracer=tracer)
|
24
|
+
return tracer
|
@@ -0,0 +1,115 @@
|
|
1
|
+
from dotenv import load_dotenv
|
2
|
+
from tools import (
|
3
|
+
llm_call,
|
4
|
+
weather_tool,
|
5
|
+
currency_converter_tool,
|
6
|
+
flight_price_estimator_tool,
|
7
|
+
)
|
8
|
+
from agents import ItineraryAgent
|
9
|
+
from config import initialize_tracing
|
10
|
+
from ragaai_catalyst import trace_agent, current_span
|
11
|
+
|
12
|
+
# Load environment variables
|
13
|
+
load_dotenv()
|
14
|
+
|
15
|
+
# Initialize distributed tracing
|
16
|
+
tracer = initialize_tracing()
|
17
|
+
|
18
|
+
@trace_agent(name="travel_agent", agent_type="main", version="1.0.0")
|
19
|
+
def travel_agent():
|
20
|
+
# Add metrics for the main session
|
21
|
+
current_span().add_metrics(
|
22
|
+
name="travel_planning_session",
|
23
|
+
score=0.9,
|
24
|
+
reasoning="Main travel planning session",
|
25
|
+
cost=0.05,
|
26
|
+
latency=1.0,
|
27
|
+
)
|
28
|
+
|
29
|
+
print("Welcome to the Personalized Travel Planner!\n")
|
30
|
+
|
31
|
+
# Get user input
|
32
|
+
user_input = input("Please describe your ideal vacation: ")
|
33
|
+
|
34
|
+
# Extract preferences
|
35
|
+
preferences_prompt = f"""
|
36
|
+
Extract key travel preferences from the following user input:
|
37
|
+
"{user_input}"
|
38
|
+
|
39
|
+
Please provide the extracted information in this format:
|
40
|
+
Destination:
|
41
|
+
Activities:
|
42
|
+
Budget:
|
43
|
+
Duration (in days):
|
44
|
+
"""
|
45
|
+
extracted_preferences = llm_call(preferences_prompt, name="extract_preferences")
|
46
|
+
print("\nExtracted Preferences:")
|
47
|
+
print(extracted_preferences)
|
48
|
+
|
49
|
+
# Parse extracted preferences
|
50
|
+
preferences = {}
|
51
|
+
for line in extracted_preferences.split("\n"):
|
52
|
+
if ":" in line:
|
53
|
+
key, value = line.split(":", 1)
|
54
|
+
preferences[key.strip()] = value.strip()
|
55
|
+
|
56
|
+
# Validate extracted preferences
|
57
|
+
required_keys = ["Destination", "Activities", "Budget", "Duration (in days)"]
|
58
|
+
if not all(key in preferences for key in required_keys):
|
59
|
+
print("\nCould not extract all required preferences. Please try again.")
|
60
|
+
return
|
61
|
+
|
62
|
+
# Fetch additional information
|
63
|
+
weather = weather_tool(preferences["Destination"])
|
64
|
+
print(f"\nWeather in {preferences['Destination']}: {weather}")
|
65
|
+
|
66
|
+
# Get departure city
|
67
|
+
print("Please enter your departure city: ")
|
68
|
+
origin = input()
|
69
|
+
flight_price = flight_price_estimator_tool(origin, preferences["Destination"])
|
70
|
+
print(flight_price)
|
71
|
+
|
72
|
+
# Plan itinerary
|
73
|
+
itinerary_agent = ItineraryAgent()
|
74
|
+
itinerary = itinerary_agent.plan_itinerary(
|
75
|
+
{
|
76
|
+
"destination": preferences["Destination"],
|
77
|
+
"origin": origin,
|
78
|
+
"budget": float(preferences["Budget"].replace("$", "")),
|
79
|
+
"budget_currency": "USD",
|
80
|
+
},
|
81
|
+
int(preferences["Duration (in days)"]),
|
82
|
+
)
|
83
|
+
print("\nPlanned Itinerary:")
|
84
|
+
print(itinerary)
|
85
|
+
|
86
|
+
# Currency conversion
|
87
|
+
budget_amount = float(preferences["Budget"].replace("$", "").replace(",", ""))
|
88
|
+
converted_budget = currency_converter_tool(budget_amount, "USD", "INR")
|
89
|
+
if converted_budget:
|
90
|
+
print(f"\nBudget in INR: {converted_budget:.2f} INR")
|
91
|
+
else:
|
92
|
+
print("\nCurrency conversion not available.")
|
93
|
+
|
94
|
+
# Generate travel summary
|
95
|
+
summary_prompt = f"""
|
96
|
+
Summarize the following travel plan:
|
97
|
+
|
98
|
+
Destination: {preferences['Destination']}
|
99
|
+
Activities: {preferences['Activities']}
|
100
|
+
Budget: {preferences['Budget']}
|
101
|
+
Duration: {preferences['Duration (in days)']} days
|
102
|
+
Itinerary: {itinerary}
|
103
|
+
Weather: {weather}
|
104
|
+
Flight Price: {flight_price}
|
105
|
+
|
106
|
+
Travel Summary:
|
107
|
+
"""
|
108
|
+
travel_summary = llm_call(summary_prompt, name="generate_summary")
|
109
|
+
print("\nTravel Summary:")
|
110
|
+
print(travel_summary)
|
111
|
+
|
112
|
+
if __name__ == "__main__":
|
113
|
+
with tracer:
|
114
|
+
travel_agent()
|
115
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import os
|
2
|
+
import random
|
3
|
+
import requests
|
4
|
+
from dotenv import load_dotenv
|
5
|
+
from openai import OpenAI
|
6
|
+
|
7
|
+
from ragaai_catalyst import trace_llm, trace_tool, current_span
|
8
|
+
|
9
|
+
# Load environment variables
|
10
|
+
load_dotenv()
|
11
|
+
|
12
|
+
@trace_llm(name="llm_call", model="gpt-4o-mini")
|
13
|
+
def llm_call(prompt, max_tokens=512, model="gpt-4o-mini", name="default"):
|
14
|
+
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
15
|
+
current_span().add_metrics(
|
16
|
+
name=f"Q/A_v3_{random.randint(1, 10000)}",
|
17
|
+
score=0.3,
|
18
|
+
reasoning="Some Reason 1",
|
19
|
+
cost=0.0003,
|
20
|
+
latency=0.002
|
21
|
+
)
|
22
|
+
|
23
|
+
response = client.chat.completions.create(
|
24
|
+
model=model,
|
25
|
+
messages=[{"role": "user", "content": prompt}],
|
26
|
+
max_tokens=max_tokens,
|
27
|
+
temperature=0.7,
|
28
|
+
)
|
29
|
+
|
30
|
+
return response.choices[0].message.content.strip()
|
31
|
+
|
32
|
+
@trace_tool(name="weather_tool", tool_type="api")
|
33
|
+
def weather_tool(destination):
|
34
|
+
api_key = os.environ.get("OPENWEATHERMAP_API_KEY")
|
35
|
+
base_url = "http://api.openweathermap.org/data/2.5/weather"
|
36
|
+
current_span().add_metrics(
|
37
|
+
name="Q/A_v2",
|
38
|
+
score=0.3,
|
39
|
+
reasoning="Some Reason 2",
|
40
|
+
cost=0.00036,
|
41
|
+
latency=0.0021,
|
42
|
+
)
|
43
|
+
params = {"q": destination, "appid": api_key, "units": "metric"}
|
44
|
+
print("Calculating weather for:", destination)
|
45
|
+
try:
|
46
|
+
response = requests.get(base_url, params=params)
|
47
|
+
response.raise_for_status()
|
48
|
+
data = response.json()
|
49
|
+
return f"{data['weather'][0]['description'].capitalize()}, {data['main']['temp']:.1f}°C"
|
50
|
+
except requests.RequestException:
|
51
|
+
return "Weather data not available."
|
52
|
+
|
53
|
+
@trace_tool(name="currency_converter", tool_type="api")
|
54
|
+
def currency_converter_tool(amount, from_currency, to_currency):
|
55
|
+
api_key = os.environ.get("EXCHANGERATE_API_KEY")
|
56
|
+
base_url = f"https://v6.exchangerate-api.com/v6/{api_key}/pair/{from_currency}/{to_currency}"
|
57
|
+
current_span().add_metrics(
|
58
|
+
name="Q/A_v2",
|
59
|
+
score=0.11,
|
60
|
+
reasoning="Some Reason 4",
|
61
|
+
cost=0.0009,
|
62
|
+
latency=0.0089,
|
63
|
+
)
|
64
|
+
|
65
|
+
try:
|
66
|
+
response = requests.get(base_url)
|
67
|
+
response.raise_for_status()
|
68
|
+
data = response.json()
|
69
|
+
|
70
|
+
if data["result"] == "success":
|
71
|
+
rate = data["conversion_rate"]
|
72
|
+
return amount * rate
|
73
|
+
else:
|
74
|
+
return None
|
75
|
+
except requests.RequestException:
|
76
|
+
return None
|
77
|
+
|
78
|
+
@trace_tool(name="flight_price_estimator", tool_type="mock")
|
79
|
+
def flight_price_estimator_tool(origin, destination):
|
80
|
+
current_span().add_metrics(
|
81
|
+
name="Q/A_v1",
|
82
|
+
score=0.67,
|
83
|
+
reasoning="Some Reason 3",
|
84
|
+
cost=0.0067,
|
85
|
+
latency=0.0011,
|
86
|
+
)
|
87
|
+
# This is a mock function. In a real scenario, you'd integrate with a flight API.
|
88
|
+
return f"Estimated price from {origin} to {destination}: $500-$1000"
|
@@ -9,7 +9,7 @@ readme = "README.md"
|
|
9
9
|
requires-python = ">=3.9,<3.13"
|
10
10
|
# license = {file = "LICENSE"}
|
11
11
|
|
12
|
-
version = "2.1.
|
12
|
+
version = "2.1.5.beta.0"
|
13
13
|
authors = [
|
14
14
|
{name = "Kiran Scaria", email = "kiran.scaria@raga.ai"},
|
15
15
|
{name = "Kedar Gaikwad", email = "kedar.gaikwad@raga.ai"},
|
@@ -48,7 +48,6 @@ dependencies = [
|
|
48
48
|
"py-cpuinfo~=9.0.0",
|
49
49
|
"requests~=2.32.3",
|
50
50
|
"GPUtil~=1.4.0",
|
51
|
-
"astor>=0.8.1",
|
52
51
|
"ipynbname",
|
53
52
|
]
|
54
53
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from .experiment import Experiment
|
2
|
+
from .ragaai_catalyst import RagaAICatalyst
|
3
|
+
from .utils import response_checker
|
4
|
+
from .dataset import Dataset
|
5
|
+
from .prompt_manager import PromptManager
|
6
|
+
from .evaluation import Evaluation
|
7
|
+
from .synthetic_data_generation import SyntheticDataGeneration
|
8
|
+
from .guardrails_manager import GuardrailsManager
|
9
|
+
from .guard_executor import GuardExecutor
|
10
|
+
from .tracers import Tracer, init_tracing, trace_agent, trace_llm, trace_tool, current_span, trace_custom
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
__all__ = [
|
16
|
+
"Experiment",
|
17
|
+
"RagaAICatalyst",
|
18
|
+
"Tracer",
|
19
|
+
"PromptManager",
|
20
|
+
"Evaluation",
|
21
|
+
"SyntheticDataGeneration",
|
22
|
+
"GuardrailsManager",
|
23
|
+
"GuardExecutor",
|
24
|
+
"init_tracing",
|
25
|
+
"trace_agent",
|
26
|
+
"trace_llm",
|
27
|
+
"trace_tool",
|
28
|
+
"current_span",
|
29
|
+
"trace_custom"
|
30
|
+
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from .tracer import Tracer
|
2
|
+
from .distributed import (
|
3
|
+
init_tracing,
|
4
|
+
trace_agent,
|
5
|
+
trace_llm,
|
6
|
+
trace_tool,
|
7
|
+
current_span,
|
8
|
+
trace_custom,
|
9
|
+
)
|
10
|
+
|
11
|
+
__all__ = [
|
12
|
+
"Tracer",
|
13
|
+
"init_tracing",
|
14
|
+
"trace_agent",
|
15
|
+
"trace_llm",
|
16
|
+
"trace_tool",
|
17
|
+
"current_span",
|
18
|
+
"trace_custom"
|
19
|
+
]
|