Spaces:
Sleeping
Sleeping
Update crypto_analysis_agents.py
Browse files- crypto_analysis_agents.py +14 -14
crypto_analysis_agents.py
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
from crewai import Agent
|
2 |
-
from langchain.llms import
|
3 |
-
from
|
4 |
-
from langchain_community.llms import HuggingFaceHub
|
5 |
from crypto_tools import CryptoTools
|
6 |
from news_tools import NewsTools
|
7 |
from sentiment_tools import SentimentTools
|
8 |
-
import os
|
9 |
-
|
10 |
|
11 |
class CryptoAnalysisAgents:
|
12 |
def __init__(self):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
|
|
|
|
|
|
21 |
def market_analyst(self):
|
22 |
return Agent(
|
23 |
role='Crypto Market Analyst',
|
24 |
-
goal="Provide in-depth industry, market analysis and insights for cryptocurrencies. You also provide insight on
|
25 |
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.""",
|
26 |
verbose=True,
|
27 |
llm=self.llm,
|
@@ -60,4 +60,4 @@ class CryptoAnalysisAgents:
|
|
60 |
NewsTools.search_crypto_news,
|
61 |
SentimentTools.analyze_sentiment
|
62 |
]
|
63 |
-
)
|
|
|
1 |
from crewai import Agent
|
2 |
+
from langchain.llms import HuggingFacePipeline
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
|
|
4 |
from crypto_tools import CryptoTools
|
5 |
from news_tools import NewsTools
|
6 |
from sentiment_tools import SentimentTools
|
|
|
|
|
7 |
|
8 |
class CryptoAnalysisAgents:
|
9 |
def __init__(self):
|
10 |
+
# Load Phi-2 model and tokenizer
|
11 |
+
model_name = "microsoft/phi-2"
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
13 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
14 |
+
|
15 |
+
# Create a text-generation pipeline
|
16 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=512)
|
17 |
|
18 |
+
# Create a LangChain wrapper around the Hugging Face pipeline
|
19 |
+
self.llm = HuggingFacePipeline(pipeline=pipe)
|
20 |
+
|
21 |
def market_analyst(self):
|
22 |
return Agent(
|
23 |
role='Crypto Market Analyst',
|
24 |
+
goal="Provide in-depth industry, market analysis and insights for cryptocurrencies. You also provide insight on our geo-politics and economic policies impact on crypto",
|
25 |
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.""",
|
26 |
verbose=True,
|
27 |
llm=self.llm,
|
|
|
60 |
NewsTools.search_crypto_news,
|
61 |
SentimentTools.analyze_sentiment
|
62 |
]
|
63 |
+
)
|