|
import os |
|
from crewai import Agent, Task, Crew, Process |
|
from langchain.tools import Tool |
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
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): |
|
|
|
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, |
|
) |
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
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 |
|
|
|
|
|
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() |
|
|