Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,40 @@ llm = ChatGoogleGenerativeAI(model="gemini-pro", verbose=True, temperature=0.1,
|
|
15 |
################################## - GOOGLE LLM - ##################################
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def create_crewai_crypto_setup(crypto_symbol):
|
20 |
# Main Research Agent for technical and market analysis
|
@@ -23,8 +57,9 @@ def create_crewai_crypto_setup(crypto_symbol):
|
|
23 |
goal=f"Perform in-depth analysis on {crypto_symbol}, focusing on technical indicators, market trends, and recent news.",
|
24 |
backstory="Expert in technical analysis and market sentiment for cryptocurrencies, capable of identifying investment opportunities and risks.",
|
25 |
verbose=True,
|
|
|
26 |
allow_delegation=False,
|
27 |
-
tools=[duckduckgo_search_tool],
|
28 |
llm=llm,
|
29 |
)
|
30 |
|
@@ -41,37 +76,48 @@ def create_crewai_crypto_setup(crypto_symbol):
|
|
41 |
|
42 |
# Market Trends and Price History Analysis
|
43 |
MarketTrends_T1 = Task(
|
44 |
-
description=f"Examine {crypto_symbol}
|
45 |
expected_output="Summary of market trends and historical price analysis, list of key datapoints including price outlook short, medium, longterm",
|
|
|
46 |
agent=research_agent,
|
47 |
)
|
48 |
|
49 |
# Technical Analysis with Key Indicators
|
50 |
TechnicalAnalysis_T2 = Task(
|
51 |
-
description=f"Apply technical analysis on {crypto_symbol}, focusing on RSI, MACD, support/resistance levels, and other relevant indicators.",
|
52 |
expected_output="Technical analysis summary with key indicator findings, techincal setups, and numerical datapoints",
|
|
|
53 |
agent=research_agent,
|
54 |
)
|
55 |
|
56 |
# Sentiment and News Analysis
|
57 |
SentimentNews_T3 = Task(
|
58 |
-
description=f"Gather and analyze recent news and community sentiment regarding {crypto_symbol} to gauge market sentiment.",
|
59 |
expected_output="Summary of recent developments, news impact, and community sentiment",
|
|
|
60 |
agent=research_agent,
|
61 |
)
|
62 |
|
63 |
# Investment Opportunities and Risks Identification
|
64 |
OpportunitiesRisks_T4 = Task(
|
65 |
-
description=f"Identify and evaluate potential investment opportunities and risks associated with {crypto_symbol}.",
|
66 |
expected_output="List of investment opportunities and risks",
|
|
|
67 |
agent=research_agent,
|
68 |
)
|
69 |
|
70 |
# Comprehensive Investment Strategy Report
|
71 |
StrategyReport_T5 = Task(
|
72 |
-
description=f"""
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
context=[MarketTrends_T1,TechnicalAnalysis_T2,SentimentNews_T3,OpportunitiesRisks_T4],
|
76 |
agent=report_formatting_agent,
|
77 |
)
|
@@ -96,7 +142,7 @@ iface = gr.Interface(
|
|
96 |
fn=run_crewai_crypto_app,
|
97 |
inputs="text",
|
98 |
outputs="text",
|
99 |
-
title="CrewAI Cryptocurrency Investment
|
100 |
description="Enter a cryptocurrency symbol to analyze and generate a comprehensive investment plan."
|
101 |
)
|
102 |
|
|
|
15 |
################################## - GOOGLE LLM - ##################################
|
16 |
|
17 |
|
18 |
+
##################################### DDG Crypto Search ######################################
|
19 |
+
from langchain.tools import DuckDuckGoSearchRun
|
20 |
+
from langchain.agents import Tool
|
21 |
+
# Define wrapper functions for specific searches
|
22 |
+
ddg_search = DuckDuckGoSearchRun()
|
23 |
+
|
24 |
+
def coingecko_search_wrapper(input_text):
|
25 |
+
return ddg_search.run(f"site:coingecko.com {input_text}")
|
26 |
+
|
27 |
+
def coinmarketcap_search_wrapper(input_text):
|
28 |
+
return ddg_search.run(f"site:coinmarketcap.com {input_text}")
|
29 |
+
|
30 |
+
def general_search_wrapper(input_text):
|
31 |
+
return ddg_search.run(f'cryptocurrency {input_text}')
|
32 |
+
|
33 |
+
# Initialize tools with specific functions
|
34 |
+
GeneralSearch = Tool(
|
35 |
+
name="GeneralSearch",
|
36 |
+
func=general_search_wrapper,
|
37 |
+
description="General search for cryptocurrencies"
|
38 |
+
)
|
39 |
+
|
40 |
+
CoinGeckoSearch = Tool(
|
41 |
+
name="CoingeckoSearch",
|
42 |
+
func=coingecko_search_wrapper,
|
43 |
+
description="Searches on Coingecko"
|
44 |
+
)
|
45 |
+
|
46 |
+
CoinMarketCapSearch = Tool(
|
47 |
+
name="CoinmarketcapSearch",
|
48 |
+
func=coinmarketcap_search_wrapper,
|
49 |
+
description="Searches on CoinMarketCap"
|
50 |
+
)
|
51 |
+
##################################### DDG Crypto Search ######################################
|
52 |
|
53 |
def create_crewai_crypto_setup(crypto_symbol):
|
54 |
# Main Research Agent for technical and market analysis
|
|
|
57 |
goal=f"Perform in-depth analysis on {crypto_symbol}, focusing on technical indicators, market trends, and recent news.",
|
58 |
backstory="Expert in technical analysis and market sentiment for cryptocurrencies, capable of identifying investment opportunities and risks.",
|
59 |
verbose=True,
|
60 |
+
max_iter=40,
|
61 |
allow_delegation=False,
|
62 |
+
tools=[duckduckgo_search_tool, CoinGeckoSearch, CoinMarketCapSearch],
|
63 |
llm=llm,
|
64 |
)
|
65 |
|
|
|
76 |
|
77 |
# Market Trends and Price History Analysis
|
78 |
MarketTrends_T1 = Task(
|
79 |
+
description=f"Examine cryptocurrency coin - {crypto_symbol} price history to identify current market trends and potential future movements.",
|
80 |
expected_output="Summary of market trends and historical price analysis, list of key datapoints including price outlook short, medium, longterm",
|
81 |
+
async_execution=True,
|
82 |
agent=research_agent,
|
83 |
)
|
84 |
|
85 |
# Technical Analysis with Key Indicators
|
86 |
TechnicalAnalysis_T2 = Task(
|
87 |
+
description=f"Apply technical analysis on the cryptocurrency {crypto_symbol}, focusing on RSI, MACD, support/resistance levels, and other relevant indicators.",
|
88 |
expected_output="Technical analysis summary with key indicator findings, techincal setups, and numerical datapoints",
|
89 |
+
async_execution=True,
|
90 |
agent=research_agent,
|
91 |
)
|
92 |
|
93 |
# Sentiment and News Analysis
|
94 |
SentimentNews_T3 = Task(
|
95 |
+
description=f"Gather and analyze recent news and community sentiment regarding cryptocurrency - {crypto_symbol} to gauge market sentiment.",
|
96 |
expected_output="Summary of recent developments, news impact, and community sentiment",
|
97 |
+
async_execution=True,
|
98 |
agent=research_agent,
|
99 |
)
|
100 |
|
101 |
# Investment Opportunities and Risks Identification
|
102 |
OpportunitiesRisks_T4 = Task(
|
103 |
+
description=f"Identify and evaluate potential investment opportunities and risks associated with cryptocurrency - {crypto_symbol}.",
|
104 |
expected_output="List of investment opportunities and risks",
|
105 |
+
async_execution=True,
|
106 |
agent=research_agent,
|
107 |
)
|
108 |
|
109 |
# Comprehensive Investment Strategy Report
|
110 |
StrategyReport_T5 = Task(
|
111 |
+
description=f"""Create a detailed investment plan for the cryptocurrency - {crypto_symbol}, incorporating price targets, technical analysis, investment strategies, and timelines.
|
112 |
+
Ensure the plan includes actionable advice on when to buy, sell, and hold, along with risk management strategies.
|
113 |
+
|
114 |
+
NOTES:
|
115 |
+
The report is for advanced cryptocurrency experts.
|
116 |
+
Do note include disclamiers.
|
117 |
+
Output should be strictly 2000 characters or less.
|
118 |
+
I will tip you 10,000 dollars if you report great.
|
119 |
+
""",
|
120 |
+
expected_output="Sectioned report that focuses on breif bullet points and notes and key data points, Investment strategy report with actionable insights and strategies",
|
121 |
context=[MarketTrends_T1,TechnicalAnalysis_T2,SentimentNews_T3,OpportunitiesRisks_T4],
|
122 |
agent=report_formatting_agent,
|
123 |
)
|
|
|
142 |
fn=run_crewai_crypto_app,
|
143 |
inputs="text",
|
144 |
outputs="text",
|
145 |
+
title="CryptoScout - CrewAI - Cryptocurrency Investment Advisor",
|
146 |
description="Enter a cryptocurrency symbol to analyze and generate a comprehensive investment plan."
|
147 |
)
|
148 |
|