File size: 1,795 Bytes
d9b1770
 
474299c
c9cc343
d9b1770
 
 
 
 
 
 
 
 
 
 
 
c7c19a5
d9b1770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7c19a5
 
 
 
d155549
 
 
 
c7c19a5
 
 
d9b1770
c7c19a5
d9b1770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from dotenv import load_dotenv, find_dotenv
from textwrap import dedent
import io, string
from contextlib import redirect_stdout

load_dotenv(find_dotenv())

from agents import CryptoAnalysisAgents
from tasks import CryptoAnalysisTasks
from crewai import Crew


class CryptoCrew:
    def __init__(self, coin):
        self.coin = coin

    def run(self, logging=False):
        agents = CryptoAnalysisAgents()
        tasks = CryptoAnalysisTasks()

        crypto_analyst = agents.crypto_analyst()
        content_writer = agents.content_writer()

        research_task = tasks.research(crypto_analyst, self.coin)
        recommend_task = tasks.recommend(content_writer, self.coin)

        crew = Crew(
            agents=[
                crypto_analyst,
                content_writer,
            ],
            tasks=[
                research_task,
                recommend_task,
            ],
            verbose=True
        )

        if logging:
            f = io.StringIO()
            with redirect_stdout(f):
                result = crew.kickoff()
            
            log = ''.join([str(char) for char in f.getvalue() if char in string.printable])

            result = log + "## Here is the Report\n\n" + result
        else:
            result = crew.kickoff()
        
        return result
 

# if __name__ == "__main__":
#     print("## Welcome to Crypto Analysis Crew")
#     print('-------------------------------')
#     company = input(
#         dedent("""
#             Which cryptocurrency are you looking to delve into?
#     """))

#     crypto_crew = CryptoCrew(company)
#     result = crypto_crew.run()
#     print("\n\n########################")
#     print("## Here is the Report")
#     print("########################\n")
    
# print(result)