File size: 5,563 Bytes
5c11d86
 
2c19cee
eb26a43
f9765e7
5c11d86
f428855
 
 
2c19cee
5c11d86
 
f428855
 
 
 
 
 
 
 
 
5c11d86
2c19cee
 
 
 
f428855
2c19cee
 
 
f428855
 
2c19cee
 
 
 
24f66b3
52983e1
24f66b3
55c8d17
24f66b3
 
 
 
 
 
2c19cee
 
52983e1
2c19cee
 
5c11d86
24f66b3
2c19cee
 
 
 
 
 
 
 
b9ece36
2c19cee
5c11d86
 
2c19cee
 
24f66b3
4143ee9
 
 
24f66b3
 
2c19cee
 
 
 
1537844
24f66b3
5c11d86
 
2c19cee
 
 
 
 
 
 
 
 
5c11d86
2c19cee
 
 
 
 
a401824
52983e1
8b5f8cb
52983e1
31763be
52983e1
8b5f8cb
52983e1
 
a401824
2c19cee
5c11d86
 
2c19cee
 
 
8b5f8cb
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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 market analysis on cryptocurrency, your job is search, research and generate a report based on the clients prompt. 
        NOTE - Make sure the report is clear, concise and professional with actionable advice and provide any relavant metrics / information.
        Your audience is professional traders that understand the risks.
        Ensure that you focus your search and research on the cryptocurrency symbol/name provided in the prompt along with the scope of or details the client wants.
        
        Here is the clients prompt - {crypto_symbol}.
        
        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=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"""
        Research using the following clients prompt which includes a cryptocurrency symbol or coin name - {crypto_symbol}. 
        Focus on the topic/details that are relavant to the clients prompt.
        Research and search the information desired using the search tools available. Always attempt to use the process tool after every search.
        Then orgainze your information and metrics which will be used and refered to in order to create a market/trade report for the client
        """,
        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_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, 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""""
        Organize the data into a report format that focuses on the clients prompt.
        Use the search tool to perform quality control on the final output, double check any price to make sure it matches todays price.
        
        ** NOTE **
        - Any current price or marketcap data should be converted to appprox numbers.
        - Remove all disclaimers or warnings regarding trade risk. 
        - Remove irrelevant information.
        - Use search tool if needed.
        """,
        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()