File size: 5,020 Bytes
5c11d86
 
2c19cee
eb26a43
f9765e7
5c11d86
f428855
 
 
2c19cee
5c11d86
 
f428855
 
 
 
 
 
 
 
 
5c11d86
2c19cee
 
 
 
f428855
2c19cee
 
 
f428855
 
2c19cee
 
 
 
b071fa6
2c19cee
 
 
 
 
5c11d86
2c19cee
 
 
 
 
 
 
 
b9ece36
2c19cee
5c11d86
 
2c19cee
 
 
 
 
 
 
 
 
 
 
5c11d86
 
2c19cee
 
 
 
 
 
 
 
 
5c11d86
2c19cee
 
 
 
 
a401824
 
 
 
 
 
2c19cee
 
5c11d86
 
2c19cee
 
 
 
 
5c11d86
 
2c19cee
5c11d86
2c19cee
5c11d86
2c19cee
 
 
 
5c11d86
2c19cee
 
 
5c11d86
2c19cee
 
5c11d86
 
2c19cee
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
import os
from crewai import Agent, Task, Crew, Process
from langchain.tools import Tool  # Assuming DuckDuckGoSearchRun or equivalent tool is available
import gradio as gr



#############################################  -  GOOGLE LLM  -  #############################################
import os
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  -  #############################################


from langchain.tools import DuckDuckGoSearchRun
duckduckgo_search_tool = DuckDuckGoSearchRun()


from WebScape_TOOL import WebSearchTools
search = WebSearchTools()
process = WebSearchTools().process_search_results



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 analysis on cryptocurrency realted queries, focusing on market outlook, trading metrics, information and metrics.",
        backstory="Expert in technical analysis, market sentiment, and investment strategy for cryptocurrencies.",
        verbose=True,
        allow_delegation=True,
        tools=[duckduckgo_search_tool],
        llm=llm,
    )
    research_agent2 = Agent(
        role="Crypto Analysis Expert",
        goal=f"""Using the websearchtools perform in-depth research for the cryptocurrency - {crypto_symbol}, 
        focusing on market outlook, investment strategies, technical/trade signals, etc
        NOTE: Use the Search tool to search and the process tool to scape the url for additonal data, every serch much be followed by a process (webscrape)
        """,
        backstory="Expert in technical analysis, market sentiment, and investment strategy for cryptocurrencies.",
        verbose=True,
        allow_delegation=False,
        llm=llm,
    )

    # Task 1: Market Outlook
    market_data_t0 = Task(
        description=f"""Search and gather market data and metrics for cryptocurrency - {crypto_symbol} - Only focus on the crypto name and symbol.
        focus on 2024 and beyond price trends, including timeline of price targets, key price points, buy/sell/hold levels,
        techincal triggers and metrics, price action, and short, medium, long term predictions along with any other relavant information, metrics and or datapoints.""",
        expected_output="Group similar data into sections, with information and data metrics presented in a clear and concise manner",
        tools=[search.pricetargets_search,
               search.forecast_search,
               search.technicalsignals_search,
               process],
        agent=research_agent2,
    )

    # 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, report over various timeframes, 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="Information in list with summary grouped if possible",
        tools=[search.technicalsignals_search, process],
        agent=research_agent,
    )
    
    ### Gather information and structure it? or not ?
    #### DEFINE What sections we need in the report for t3 
    
    Summary_t3 = Task(
        description=f""""
        Create a report based on the request {crypto_symbol} (Focus on talioring the info,metrics, and data that are relavant to the query). 
        Summarize any data and information and provide actionable advice when you can. 
        List key informaiton.
        You have access to all the information you need and can delegate research if needed
        """,
        expected_output="Report based on query with summary followed by sections with similar datapoints grouped including relavant data and metrics. The report should be organized, easy to read, clear and concise",
        agent=research_agent,
    )

    # Crew setup for processing the tasks sequentially
    crypto_crew = Crew(
        agents=[research_agent, research_agent2],
        tasks=[market_data_t0,Summary_t3],
        verbose=2,
        process=Process.sequential,
    )
    crew_result = crypto_crew.kickoff()

    return crew_result

# Gradio Interface
def run_crewai_app(crypto_symbol):
    crew_result = create_crewai_crypto_setup(crypto_symbol)
    return crew_result

iface = gr.Interface(
    fn=run_crewai_app, 
    inputs="text", 
    outputs="text",
    title="CrewAI Trade Analysis",
    description="Enter a Cryptocurrency Ticker + (optional) Techincal/trading signals, price predictions, price targets, buy/sell/hold prices."
)

iface.launch()