Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 42 |
@tool
|
| 43 |
def crypto_analysis(crypto_name: str) -> str:
|
| 44 |
"""
|
| 45 |
-
Fetches current cryptocurrency data for a given crypto currency name use the data extracted
|
| 46 |
|
| 47 |
Args:
|
| 48 |
crypto_name: The crypto currency id (e.g., 'bitcoin')
|
|
@@ -57,65 +57,65 @@ def crypto_analysis(crypto_name: str) -> str:
|
|
| 57 |
response = requests.get(url)
|
| 58 |
response.raise_for_status() # Raise exception for bad status codes
|
| 59 |
data = response.json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
# Search for news related to crypto
|
| 62 |
-
search_tool = DuckDuckGoSearchTool()
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
change_24h = float(crypto_info["changePercent24Hr"])
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
except ValueError as error:
|
| 115 |
-
return f"Error: Failed to process values in cryptocurrency data: {str(error)}"
|
| 116 |
|
| 117 |
-
except requests.exceptions.RequestException as e:
|
| 118 |
-
|
| 119 |
|
| 120 |
final_answer = FinalAnswerTool()
|
| 121 |
|
|
|
|
| 42 |
@tool
|
| 43 |
def crypto_analysis(crypto_name: str) -> str:
|
| 44 |
"""
|
| 45 |
+
Fetches current cryptocurrency data for a given crypto currency name use the data extracted to perform crypto analysis.
|
| 46 |
|
| 47 |
Args:
|
| 48 |
crypto_name: The crypto currency id (e.g., 'bitcoin')
|
|
|
|
| 57 |
response = requests.get(url)
|
| 58 |
response.raise_for_status() # Raise exception for bad status codes
|
| 59 |
data = response.json()
|
| 60 |
+
return data
|
| 61 |
+
|
| 62 |
+
except requests.exceptions.RequestException as e:
|
| 63 |
+
raise f"Error: {str(e)}"
|
| 64 |
+
|
| 65 |
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
# crypto_info = data['data']
|
| 68 |
+
# # Extract key metrics for analysis
|
| 69 |
+
# price = float(crypto_info["priceUsd"])
|
| 70 |
+
# market_cap = float(crypto_info["marketCapUsd"])
|
| 71 |
+
# volume_24h = float(crypto_info["volumeUsd24Hr"])
|
| 72 |
+
# change_24h = float(crypto_info["changePercent24Hr"])
|
|
|
|
| 73 |
|
| 74 |
+
# # Targeted search for information
|
| 75 |
+
# queries = [
|
| 76 |
+
# f"{crypto_info['name']} price movement reasons",
|
| 77 |
+
# f"{crypto_info['name']} market analysis",
|
| 78 |
+
# f"{crypto_info['name']} future predictions",
|
| 79 |
+
# f"{crypto_info['name']} recent developments"
|
| 80 |
+
# ]
|
| 81 |
|
| 82 |
+
# # Fetch relevant information from search
|
| 83 |
+
# search_results = {}
|
| 84 |
+
# for query in queries:
|
| 85 |
+
# search_results[query] = search_tool(query)
|
| 86 |
|
| 87 |
+
# # Compile final results
|
| 88 |
+
# analysis = {
|
| 89 |
+
# "basic_info": {
|
| 90 |
+
# "name": crypto_info["name"],
|
| 91 |
+
# "symbol": crypto_info["symbol"],
|
| 92 |
+
# "current_price_usd": price,
|
| 93 |
+
# "market_cap_usd": market_cap,
|
| 94 |
+
# "rank": int(crypto_info["rank"]),
|
| 95 |
+
# },
|
| 96 |
+
# "technical_indicators": {
|
| 97 |
+
# "24h_change_percent": change_24h,
|
| 98 |
+
# "24h_volume_usd": volume_24h,
|
| 99 |
+
# "supply_info": {
|
| 100 |
+
# "current_supply": float(crypto_info["supply"]),
|
| 101 |
+
# "max_supply": float(crypto_info["maxSupply"]) if crypto_info.get("maxSupply") else None,
|
| 102 |
+
# "percent_of_max_issued": (float(crypto_info["supply"]) / float(crypto_info["maxSupply"]) * 100)
|
| 103 |
+
# if crypto_info.get("maxSupply") else None
|
| 104 |
+
# }
|
| 105 |
+
# },
|
| 106 |
+
# "market_sentiment": {
|
| 107 |
+
# "recent_news": search_results,
|
| 108 |
+
# "sentiment_indicator": "positive" if change_24h > 0 else "negative",
|
| 109 |
+
# }
|
| 110 |
+
# }
|
| 111 |
|
| 112 |
+
# return json.dumps(analysis)
|
| 113 |
|
| 114 |
+
# except ValueError as error:
|
| 115 |
+
# return f"Error: Failed to process values in cryptocurrency data: {str(error)}"
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
# except requests.exceptions.RequestException as e:
|
| 118 |
+
# return f"Error: API request failed: {str(e)}"
|
| 119 |
|
| 120 |
final_answer = FinalAnswerTool()
|
| 121 |
|