Spaces:
Sleeping
Sleeping
Update crypto_analysis_agents.py
Browse files- crypto_analysis_agents.py +53 -62
crypto_analysis_agents.py
CHANGED
@@ -1,66 +1,57 @@
|
|
1 |
-
import
|
2 |
-
from
|
3 |
-
from
|
4 |
-
import
|
5 |
-
from
|
6 |
-
from
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
market_research_task = tasks.market_research(market_analyst_agent, self.crypto)
|
21 |
-
technical_analysis_task = tasks.technical_analysis(technical_analyst_agent)
|
22 |
-
sentiment_analysis_task = tasks.sentiment_analysis(market_analyst_agent)
|
23 |
-
recommend_task = tasks.recommend(crypto_advisor_agent)
|
24 |
-
|
25 |
-
crew = Crew(
|
26 |
-
agents=[
|
27 |
-
market_analyst_agent,
|
28 |
-
technical_analyst_agent,
|
29 |
-
crypto_advisor_agent
|
30 |
-
],
|
31 |
-
tasks=[
|
32 |
-
market_research_task,
|
33 |
-
technical_analysis_task,
|
34 |
-
sentiment_analysis_task,
|
35 |
-
recommend_task
|
36 |
-
],
|
37 |
verbose=True,
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
1 |
+
from crewai import Agent
|
2 |
+
from langchain.llms import HuggingFaceHub
|
3 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
4 |
+
from langchain_community.llms import HuggingFaceHub
|
5 |
+
from tools.crypto_tools import CryptoTools
|
6 |
+
from tools.news_tools import NewsTools
|
7 |
+
from tools.sentiment_tools import SentimentTools
|
8 |
+
|
9 |
+
class CryptoAnalysisAgents:
|
10 |
+
def __init__(self):
|
11 |
+
self.llm = HuggingFaceHub(repo_id="bigscience/bloom", model_kwargs={"temperature": 0.7, "max_length": 1024})
|
12 |
+
self.embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
13 |
+
huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN"
|
14 |
+
|
15 |
+
def market_analyst(self):
|
16 |
+
return Agent(
|
17 |
+
role='Crypto Market Analyst',
|
18 |
+
goal="Provide in-depth industry, market analysis and insights for cryptocurrencies. You also provide insight on on our geo-politics and economic policies impact on crypto",
|
19 |
+
backstory="""You are a seasoned crypto market analyst with years of experience in blockchain technology and cryptocurrency markets. Your expertise helps clients navigate the volatile crypto landscape.""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
verbose=True,
|
21 |
+
llm=self.llm,
|
22 |
+
tools=[
|
23 |
+
CryptoTools.get_crypto_price,
|
24 |
+
CryptoTools.get_market_cap,
|
25 |
+
NewsTools.search_crypto_news,
|
26 |
+
SentimentTools.analyze_sentiment
|
27 |
+
]
|
28 |
)
|
29 |
|
30 |
+
def technical_analyst(self):
|
31 |
+
return Agent(
|
32 |
+
role='Crypto Technical Analyst',
|
33 |
+
goal="Analyze cryptocurrency price patterns and provide technical insights",
|
34 |
+
backstory="""You are an expert in technical analysis, specializing in cryptocurrency markets. Your chart reading skills and understanding of technical indicators are unparalleled.""",
|
35 |
+
verbose=True,
|
36 |
+
llm=self.llm,
|
37 |
+
tools=[
|
38 |
+
CryptoTools.get_crypto_price,
|
39 |
+
CryptoTools.calculate_rsi,
|
40 |
+
CryptoTools.calculate_moving_average
|
41 |
+
]
|
42 |
+
)
|
43 |
|
44 |
+
def crypto_advisor(self):
|
45 |
+
return Agent(
|
46 |
+
role='Cryptocurrency Investment Advisor',
|
47 |
+
goal="Provide comprehensive investment advice for cryptocurrency portfolios",
|
48 |
+
backstory="""You are a trusted cryptocurrency investment advisor with a deep understanding of blockchain technology, market dynamics, and risk management in the crypto space.""",
|
49 |
+
verbose=True,
|
50 |
+
llm=self.llm,
|
51 |
+
tools=[
|
52 |
+
CryptoTools.get_crypto_price,
|
53 |
+
CryptoTools.get_market_cap,
|
54 |
+
NewsTools.search_crypto_news,
|
55 |
+
SentimentTools.analyze_sentiment
|
56 |
+
]
|
57 |
+
)
|