menikev commited on
Commit
9a5fd8b
·
verified ·
1 Parent(s): 9494f5a

Update crypto_analysis_agents.py

Browse files
Files changed (1) hide show
  1. 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 HuggingFaceHub
3
- from langchain_community.embeddings import HuggingFaceEmbeddings
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
- self.llm = HuggingFaceHub(
14
- repo_id="facebook/opt-125m",
15
- model_kwargs={"temperature": 0.7, "max_length": 512},
16
- task="text-generation"
17
- )
18
- self.embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
19
- huggingfacehub_api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
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 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,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
+ )