Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -9,7 +9,7 @@ class CryptoCrew:
|
|
| 9 |
def __init__(self, crypto):
|
| 10 |
self.crypto = crypto
|
| 11 |
|
| 12 |
-
async def
|
| 13 |
agents = CryptoAnalysisAgents()
|
| 14 |
tasks = CryptoAnalysisTasks()
|
| 15 |
|
|
@@ -47,13 +47,18 @@ class CryptoCrew:
|
|
| 47 |
parsed_result = self.parse_result(result)
|
| 48 |
return parsed_result
|
| 49 |
|
|
|
|
|
|
|
|
|
|
| 50 |
def parse_result(self, result):
|
| 51 |
-
#
|
| 52 |
try:
|
| 53 |
-
result_text = result.get_summary()
|
| 54 |
except AttributeError:
|
| 55 |
-
|
|
|
|
| 56 |
|
|
|
|
| 57 |
parsed = {
|
| 58 |
"summary": result_text,
|
| 59 |
"sentiment": {
|
|
@@ -64,6 +69,7 @@ class CryptoCrew:
|
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
|
|
|
| 67 |
if "sentiment score" in result_text.lower():
|
| 68 |
sentiment_section = result_text.split("sentiment score")[1].split("\n")[0]
|
| 69 |
try:
|
|
@@ -73,7 +79,7 @@ class CryptoCrew:
|
|
| 73 |
elif sentiment_score < -0.5:
|
| 74 |
parsed["sentiment"]["overall"] = "Negative"
|
| 75 |
except ValueError:
|
| 76 |
-
pass
|
| 77 |
|
| 78 |
return parsed
|
| 79 |
|
|
@@ -84,8 +90,8 @@ if __name__ == "__main__":
|
|
| 84 |
What is the cryptocurrency you want to analyze?
|
| 85 |
"""))
|
| 86 |
crypto_crew = CryptoCrew(crypto)
|
| 87 |
-
result =
|
| 88 |
print("\n\n########################")
|
| 89 |
print("## Here is the Report")
|
| 90 |
print("########################\n")
|
| 91 |
-
print(json.dumps(result, indent=2))
|
|
|
|
| 9 |
def __init__(self, crypto):
|
| 10 |
self.crypto = crypto
|
| 11 |
|
| 12 |
+
async def run_async(self):
|
| 13 |
agents = CryptoAnalysisAgents()
|
| 14 |
tasks = CryptoAnalysisTasks()
|
| 15 |
|
|
|
|
| 47 |
parsed_result = self.parse_result(result)
|
| 48 |
return parsed_result
|
| 49 |
|
| 50 |
+
def run(self):
|
| 51 |
+
return asyncio.run(self.run_async())
|
| 52 |
+
|
| 53 |
def parse_result(self, result):
|
| 54 |
+
# Attempt to extract a text summary from the result
|
| 55 |
try:
|
| 56 |
+
result_text = result.get_summary() # Hypothetical method; replace with actual method/attribute
|
| 57 |
except AttributeError:
|
| 58 |
+
# If the method or attribute doesn't exist, fall back to another way
|
| 59 |
+
result_text = str(result) # Convert to string if necessary
|
| 60 |
|
| 61 |
+
# Initialize the parsed result structure
|
| 62 |
parsed = {
|
| 63 |
"summary": result_text,
|
| 64 |
"sentiment": {
|
|
|
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
+
# Perform sentiment extraction on the result_text
|
| 73 |
if "sentiment score" in result_text.lower():
|
| 74 |
sentiment_section = result_text.split("sentiment score")[1].split("\n")[0]
|
| 75 |
try:
|
|
|
|
| 79 |
elif sentiment_score < -0.5:
|
| 80 |
parsed["sentiment"]["overall"] = "Negative"
|
| 81 |
except ValueError:
|
| 82 |
+
pass # Handle the case where conversion to float fails
|
| 83 |
|
| 84 |
return parsed
|
| 85 |
|
|
|
|
| 90 |
What is the cryptocurrency you want to analyze?
|
| 91 |
"""))
|
| 92 |
crypto_crew = CryptoCrew(crypto)
|
| 93 |
+
result = crypto_crew.run()
|
| 94 |
print("\n\n########################")
|
| 95 |
print("## Here is the Report")
|
| 96 |
print("########################\n")
|
| 97 |
+
print(json.dumps(result, indent=2))
|