File size: 3,990 Bytes
477fe02
ee38f27
 
 
05e3323
59f9859
ee38f27
 
 
fdc602b
 
ee38f27
fdc602b
 
ee38f27
fdc602b
 
ee38f27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7db1227
ee38f27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7db1227
 
 
 
 
 
 
 
ee38f27
 
 
 
 
 
75d553b
ee38f27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477fe02
ee38f27
 
12e86bb
e3a1646
ee38f27
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
from crewai import Agent, Task, Crew, Process
from langchain.tools import DuckDuckGoSearchRun
from langchain.agents import Tool
import gradio as gr

# Initialize CoinGecko API for cryptocurrency data
duckduckgo_search_tool = DuckDuckGoSearchRun()


##################################  -  GOOGLE LLM  -  ##################################
from langchain_google_genai import ChatGoogleGenerativeAI

api_gemini = os.environ["api_gemini"]
llm = ChatGoogleGenerativeAI(model="gemini-pro", verbose=True, temperature=0.1, google_api_key=api_gemini)
##################################  -  GOOGLE LLM  -  ##################################


def create_crewai_crypto_setup(crypto_symbol):
    # Define the Main Research Agent for cryptocurrency analysis
    research_agent = Agent(
        role="Main Research Agent",
        goal=f"Conduct thorough research on {crypto_symbol}, covering its market performance, technical analysis, and recent developments.",
        backstory="An expert in cryptocurrency analysis, skilled in evaluating digital currencies based on technical indicators, market trends, and blockchain developments.",
        verbose=True,
        allow_delegation=False,
        tools=[duckduckgo_search_tool],
        llm=llm,
    )

    # Define the Report Formatting Agent for creating investment plans
    report_formatting_agent = Agent(
        role="Investment Plan Creator",
        goal="Compile and format the researched information into a structured and actionable investment plan for the cryptocurrency.",
        backstory="Specializes in synthesizing market analysis into clear, actionable investment strategies for cryptocurrency investors.",
        verbose=True,
        allow_delegation=False,
        llm=llm,
    )

    # Define Tasks for the Main Research Agent focused on cryptocurrency
    task1 = Task(
        description=f"Analyze the price history and current market trends of {crypto_symbol}.",
        agent=research_agent,
    )

    task2 = Task(
        description=f"Conduct technical analysis on {crypto_symbol} cryptocurrency using up to date data, focusing on key indicators like RSI, MACD, and support/resistance levels.",
        agent=research_agent,
    )

    task3 = Task(
        description=f"Review recent news, developments, and community sentiment around {crypto_symbol}.",
        agent=research_agent,
    )

    task4 = Task(
        description=f"Identify potential investment opportunities and risks for {crypto_symbol}.",
        agent=research_agent,
    )

    # Define Task for the Report Formatting Agent to create a comprehensive investment plan
    task5 = Task(
        description=f"""Create a detailed investment plan for {crypto_symbol}, incorporating price targets, technical analysis, investment strategies, and timelines. 
        Ensure the plan includes actionable advice on when to buy, sell, and hold, along with risk management strategies. 
        
        NOTES:
        The report is for advanced cryptocurrency experts.
        Do note include disclamiers.
        Output should be 2000 characters or less.
        I will tip you 10,000 dollars if you report great.
        """,
        agent=report_formatting_agent,
    )

    # Update the Crew to include the new condensing task
    crypto_crew = Crew(
        agents=[research_agent, report_formatting_agent],
        tasks=[task1, task2, task3, task4, task5],
        verbose=2,
        process=Process.sequential,
    )


    crew_result = crypto_crew.kickoff()
    return crew_result

# Gradio Interface for the cryptocurrency investment plan app
def run_crewai_crypto_app(crypto_symbol):
    crew_result = create_crewai_crypto_setup(crypto_symbol)
    return crew_result

iface = gr.Interface(
    fn=run_crewai_crypto_app, 
    inputs="text", 
    outputs="text",
    title="CrewAI Cryptocurrency Investment Plan",
    description="Enter a cryptocurrency symbol to analyze and generate a comprehensive investment plan."
)

iface.launch()