File size: 3,331 Bytes
d35a027
05c68e2
c622aa3
91d4052
 
 
d35a027
 
 
6ddb968
9a5fd8b
 
d0e626d
a991115
 
 
d0e626d
 
05c68e2
 
 
 
 
d0e626d
 
05c68e2
d0e626d
651f036
b129245
 
 
 
d0e626d
b129245
 
05c68e2
651f036
b129245
9a5fd8b
b7c204b
 
 
651f036
b7c204b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3698588
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from crewai import Agent
from langchain_huggingface import HuggingFacePipeline
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, GenerationConfig
from crypto_tools import CryptoTools
from news_tools import NewsTools
from sentiment_tools import SentimentTools

class CryptoAnalysisAgents:
    def __init__(self):
        model_name = "microsoft/phi-2"  # A smaller, open-source model
        tokenizer = AutoTokenizer.from_pretrained(model_name)
        model = AutoModelForCausalLM.from_pretrained(model_name)

        # Set pad_token_id to eos_token_id if pad_token_id is not defined
        model.config.pad_token_id = tokenizer.eos_token_id

        # Create a custom generation config
        generation_config = GenerationConfig(
            max_new_tokens=512,
            do_sample=True,
            temperature=0.7,
            top_p=0.95,
            max_length=2048
        )

         # Update the model' config
        model.config.max_length = 2048
        
        pipe = pipeline(
            "text-generation",
            model=model,
            tokenizer=tokenizer,
            generation_config=generation_config,
            repetition_penalty=1.1
        )

        
        self.llm = HuggingFacePipeline(pipeline=pipe)

    def market_analyst(self):
        return Agent(
            role='Crypto Market Analyst',
            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",
            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.""",
            verbose=True,
            llm=self.llm,
            tools=[
                CryptoTools.get_crypto_price,
                CryptoTools.get_market_cap,
                NewsTools.search_crypto_news,
                SentimentTools.analyze_sentiment
            ]
        )
    def technical_analyst(self):
        return Agent(
            role='Crypto Technical Analyst',
            goal="Analyze cryptocurrency price patterns and provide technical insights",
            backstory="""You are an expert in technical analysis, specializing in cryptocurrency markets. Your chart reading skills and understanding of technical indicators are unparalleled.""",
            verbose=True,
            llm=self.llm,
            tools=[
                CryptoTools.get_crypto_price,
                CryptoTools.calculate_rsi,
                CryptoTools.calculate_moving_average
            ]
        )

    def crypto_advisor(self):
        return Agent(
            role='Cryptocurrency Investment Advisor',
            goal="Provide comprehensive investment advice for cryptocurrency portfolios",
            backstory="""You are a trusted cryptocurrency investment advisor with a deep understanding of blockchain technology, market dynamics, and risk management in the crypto space.""",
            verbose=True,
            llm=self.llm,
            tools=[
                CryptoTools.get_crypto_price,
                CryptoTools.get_market_cap,
                NewsTools.search_crypto_news,
                SentimentTools.analyze_sentiment
            ]
        )