patopla commited on
Commit
e7a5658
·
verified ·
1 Parent(s): f73cbc5

Delete tools.py

Browse files
Files changed (1) hide show
  1. tools.py +0 -61
tools.py DELETED
@@ -1,61 +0,0 @@
1
- from smolagents import DuckDuckGoSearchTool
2
- from smolagents import Tool
3
- import random
4
-
5
- # Initialize the DuckDuckGo search tool
6
- search_tool = DuckDuckGoSearchTool()
7
-
8
-
9
-
10
-
11
- class CurrencyConverterTool(Tool):
12
- name = "currency_converter"
13
- description = "Converts amounts between different currencies using dummy exchange rates."
14
- inputs = {
15
- "amount": {
16
- "type": "number", # Cambiado de "float" a "number"
17
- "description": "The amount to convert."
18
- },
19
- "from_currency": {
20
- "type": "string",
21
- "description": "The source currency code (e.g., USD, EUR, CLP)."
22
- },
23
- "to_currency": {
24
- "type": "string",
25
- "description": "The target currency code (e.g., USD, EUR, CLP)."
26
- }
27
- }
28
- output_type = "string"
29
-
30
- def forward(self, amount: float, from_currency: str, to_currency: str):
31
- # Dummy exchange rates (base: USD)
32
- exchange_rates = {
33
- "USD": 1.0,
34
- "EUR": 0.85,
35
- "CLP": 800.0,
36
- "ARS": 350.0,
37
- "BRL": 5.2,
38
- "MXN": 18.5,
39
- "GBP": 0.75,
40
- "JPY": 110.0,
41
- "CAD": 1.25
42
- }
43
-
44
- # Validate currencies
45
- if from_currency not in exchange_rates or to_currency not in exchange_rates:
46
- available_currencies = ", ".join(exchange_rates.keys())
47
- return f"Error: Moneda no soportada. Divisas disponibles: {available_currencies}"
48
-
49
- # Same currency conversion
50
- if from_currency == to_currency:
51
- return f"{amount:.2f} {from_currency} = {amount:.2f} {to_currency} (misma divisa)"
52
-
53
- # Convert to USD first, then to target currency
54
- usd_amount = amount / exchange_rates[from_currency]
55
- converted_amount = usd_amount * exchange_rates[to_currency]
56
-
57
- # Add small random variation to simulate real market fluctuations (±2%)
58
- variation = random.uniform(-0.02, 0.02)
59
- converted_amount *= (1 + variation)
60
-
61
- return f"{amount:.2f} {from_currency} = {converted_amount:.2f} {to_currency} (tasa simulada)"