Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,6 +54,7 @@ def crypto_analysis(crypto_name: str) -> str:
|
|
| 54 |
|
| 55 |
url = f"https://rest.coincap.io/v3/assets/{crypto_name}?apiKey={os.getenv(key='coincap_api')}"
|
| 56 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 57 |
try:
|
| 58 |
response = requests.get(url)
|
| 59 |
response.raise_for_status() # Raise exception for bad status codes
|
|
@@ -62,7 +63,9 @@ def crypto_analysis(crypto_name: str) -> str:
|
|
| 62 |
|
| 63 |
# get search results
|
| 64 |
search_query = f"Get the latest analysis trends for the following cryptocurrency: {crypto_info['name']}"
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
|
| 67 |
analysis = {
|
| 68 |
"crypto_data": {
|
|
@@ -74,7 +77,7 @@ def crypto_analysis(crypto_name: str) -> str:
|
|
| 74 |
"rank": int(crypto_info["rank"])
|
| 75 |
},
|
| 76 |
"market_sentiment": "positive" if float(crypto_info["changePercent24Hr"]) > 0 else "negative",
|
| 77 |
-
"related_information":
|
| 78 |
"data_source": crypto_info["explorer"]
|
| 79 |
}
|
| 80 |
|
|
|
|
| 54 |
|
| 55 |
url = f"https://rest.coincap.io/v3/assets/{crypto_name}?apiKey={os.getenv(key='coincap_api')}"
|
| 56 |
search_tool = DuckDuckGoSearchTool()
|
| 57 |
+
output = ""
|
| 58 |
try:
|
| 59 |
response = requests.get(url)
|
| 60 |
response.raise_for_status() # Raise exception for bad status codes
|
|
|
|
| 63 |
|
| 64 |
# get search results
|
| 65 |
search_query = f"Get the latest analysis trends for the following cryptocurrency: {crypto_info['name']}"
|
| 66 |
+
search_results = search_tool(search_query)
|
| 67 |
+
if search_results:
|
| 68 |
+
output = search_results
|
| 69 |
|
| 70 |
analysis = {
|
| 71 |
"crypto_data": {
|
|
|
|
| 77 |
"rank": int(crypto_info["rank"])
|
| 78 |
},
|
| 79 |
"market_sentiment": "positive" if float(crypto_info["changePercent24Hr"]) > 0 else "negative",
|
| 80 |
+
"related_information": output,
|
| 81 |
"data_source": crypto_info["explorer"]
|
| 82 |
}
|
| 83 |
|