File size: 5,632 Bytes
197ae2a
7c10474
 
197ae2a
 
7c10474
197ae2a
1df8563
7c10474
197ae2a
 
 
7c10474
197ae2a
7c10474
 
 
 
 
 
 
197ae2a
1df8563
7c10474
 
 
 
 
 
 
ac47988
 
1df8563
197ae2a
 
ac47988
 
197ae2a
 
a535fe4
 
 
 
197ae2a
 
 
 
 
 
 
c08c614
 
 
 
a535fe4
c08c614
 
197ae2a
 
c08c614
4729a1e
c08c614
197ae2a
 
 
bb5ac29
197ae2a
bb5ac29
7bb3191
a535fe4
197ae2a
 
 
 
 
9076694
 
567dffa
 
7bb3191
a535fe4
197ae2a
 
 
 
 
 
9076694
197ae2a
 
 
 
 
 
 
c08c614
197ae2a
 
 
 
ac47988
 
 
 
197ae2a
 
 
 
 
 
 
 
ac47988
 
 
197ae2a
 
 
 
 
 
 
 
 
1df8563
 
197ae2a
 
 
ac47988
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from crewai import Agent, Task, Crew, Process
from langchain.tools import Tool

import gradio as gr



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


api_gemini = os.environ["api_gemini"] 

# Define the Large Language Model (LLM)
llm = ChatGoogleGenerativeAI(
    model="gemini-pro",
    verbose=True,
    temperature=0.1,
    google_api_key=api_gemini)
##################################  -  GOOGLE LLM  -  ##################################


from langchain.tools import DuckDuckGoSearchRun
duckduckgo_search_tool = DuckDuckGoSearchRun()
    
from WebScape_TOOL import WebSearchTools
search = WebSearchTools()
process = WebSearchTools().process_search_results
    

##################################  -  CREW and TASKS   -  ##################################

def create_crewai_crypto_setup(crypto_symbol):
    # Main Research Agent for technical and market analysis

    
    research_agent = Agent(
        role="Crypto Analysis Expert",
        goal=f"""
        Perform in-depth market analysis on cryptocurrency - {crypto_symbol}, focusing on market outlook, investment strategies, technical/trade signals, and risks.
        Note: Always use the process tool after the search to get futher data.
        """,
        backstory="Expert in technical analysis, market sentiment, and investment strategy for cryptocurrencies.",
        verbose=True,
        allow_delegation=False,
        tools=[duckduckgo_search_tool],
        llm=llm,
    )


        # Task 1: Market Outlook
    market_outlook_t0 = Task(
        description=f"Research cryptocurrency - {crypto_symbol} focus on 2024 and beyond price trends, including timeline of price targets, price action, and short, medium, long term predictions.",
        tools=[search.forecast_search, process],
        agent=research_agent,
    )
    # Task 1: Market Outlook
    market_outlook_t1 = Task(
        description=f"Create a report based on the last task output on cryptocurrency - {crypto_symbol} focus on 2024 and beyond price trends, including timeline of price targets, price action, and short, medium, long term predictions.",
        expected_output="Summary of important information and actionale insights focusing on any numbers or metrics. Final ouput strictly equal to or less than 600 chars.",
        context=[market_outlook_t0],
        agent=research_agent,
    )

    # Task 2: Investment Strategies   - Doesnt use tool most of the time??
    investment_strategies_t2 = Task(
        description=f"Using the search tools avaliable, develop investment strategies for {crypto_symbol}, including price levels to buy/sell/hold based on current market analysis and or recent support and resistance level.",
        expected_output="Summary of important information and data focusing on any numbers or metrics. Final Ouput strictly equal to or less than 550 chars.",
        tools=[search.pricetargets_search, process],
        agent=research_agent,
    )

    # Task 3: Technical/Trade Signals
    technical_signals_t3 = Task(
        description=f""""Research and perform technical analysis on cryptocurrency - {crypto_symbol}, 
        identify recent trade and techincal signals, Look for daily timeframe, trend type (Bullish, neutral, bearish), 
        and type of indicator like moving averages, RSI, MACD, or other related signars if present during search.
        note - Use only the crypto symbol to perfom your search""",
        expected_output="Summary of information highlighting metrics or numbers if present. Final Ouput strictly equal to or less than 600 chars.",
        tools=[search.technicalsignals_search, process],
        agent=research_agent,
    )

    # Task 4: Risks
    risks_t4 = Task(
        description=f"Research recent sentiment, news, volatility and other risks associcated with cryptocurrency - {crypto_symbol}.",
        expected_output="Summary of identified risks. Final Ouput strictly 300 chars. or less",
        tools=[duckduckgo_search_tool],
        agent=research_agent,
    )

    # Crew setup for processing the tasks sequentially
    crypto_crew = Crew(
        agents=[research_agent],
        tasks=[market_outlook_t0, market_outlook_t1, investment_strategies_t2, technical_signals_t3, risks_t4],
        verbose=2,
        process=Process.sequential,
    )
    crew_result = crypto_crew.kickoff()

##################################  -  CREW and TASKS   -  ##################################
 
##################################  -  REPORT   -  ##################################
    section_titles = {
        "Market Outlook": market_outlook_t1.output.result,
        "Invesment Report": investment_strategies_t2.output.result,
        "Technical Analysis": technical_signals_t3.output.result,
        "Risk Analysis": risks_t4.output.result,
    }

    return section_titles
##################################  -  REPORT   -  ##################################
    
##################################  -  GRADIO   -  ##################################
def run_crewai_app(coin_name):
    results = create_crewai_crypto_setup(coin_name)
    output = '\n\n'.join([f"{title}:\n{result}" for title, result in results.items()])
    return output

iface = gr.Interface(
    fn=run_crewai_app,
    inputs="text",
    outputs="text",
    title="CryptoScout - CrewAI - Cryptocurrency Trade Advisor",
    description="Enter a cryptocurrency name to analyze and generate a comprehensive trade report."
)

iface.launch()
##################################  -  GRADIO   -  ##################################