CryptoScoutv1's picture
Rename app.py to app_V0.py
ad449a8 verified
import os
from crewai import Agent, Task, Crew, Process
from langchain.tools import DuckDuckGoSearchRun
from langchain.agents import Tool
import gradio as gr
# Initialize CoinGecko API for cryptocurrency data
duckduckgo_search_tool = DuckDuckGoSearchRun()
################################## - GOOGLE LLM - ##################################
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 - ##################################
def create_crewai_crypto_setup(crypto_symbol):
# Define the Main Research Agent for cryptocurrency analysis
research_agent = Agent(
role="Main Research Agent",
goal=f"Conduct thorough research on {crypto_symbol}, covering its market performance, technical analysis, and recent developments.",
backstory="An expert in cryptocurrency analysis, skilled in evaluating digital currencies based on technical indicators, market trends, and blockchain developments.",
verbose=True,
allow_delegation=False,
tools=[duckduckgo_search_tool],
llm=llm,
)
# Define the Report Formatting Agent for creating investment plans
report_formatting_agent = Agent(
role="Investment Plan Creator",
goal="Compile and format the researched information into a structured and actionable investment plan for the cryptocurrency.",
backstory="Specializes in synthesizing market analysis into clear, actionable investment strategies for cryptocurrency investors.",
verbose=True,
allow_delegation=False,
llm=llm,
)
# Define Tasks for the Main Research Agent focused on cryptocurrency
task1 = Task(
description=f"Analyze the price history and current market trends of {crypto_symbol}.",
agent=research_agent,
)
task2 = Task(
description=f"Conduct technical analysis on {crypto_symbol} cryptocurrency using up to date data, focusing on key indicators like RSI, MACD, and support/resistance levels.",
agent=research_agent,
)
task3 = Task(
description=f"Review recent news, developments, and community sentiment around {crypto_symbol}.",
agent=research_agent,
)
task4 = Task(
description=f"Identify potential investment opportunities and risks for {crypto_symbol}.",
agent=research_agent,
)
# Define Task for the Report Formatting Agent to create a comprehensive investment plan
task5 = Task(
description=f"""Create a detailed investment plan for {crypto_symbol}, incorporating price targets, technical analysis, investment strategies, and timelines.
Ensure the plan includes actionable advice on when to buy, sell, and hold, along with risk management strategies.
NOTES:
The report is for advanced cryptocurrency experts.
Do note include disclamiers.
Output should be 2000 characters or less.
I will tip you 10,000 dollars if you report great.
""",
agent=report_formatting_agent,
)
# Update the Crew to include the new condensing task
crypto_crew = Crew(
agents=[research_agent, report_formatting_agent],
tasks=[task1, task2, task3, task4, task5],
verbose=2,
process=Process.sequential,
)
crew_result = crypto_crew.kickoff()
return crew_result
# Gradio Interface for the cryptocurrency investment plan app
def run_crewai_crypto_app(crypto_symbol):
crew_result = create_crewai_crypto_setup(crypto_symbol)
return crew_result
iface = gr.Interface(
fn=run_crewai_crypto_app,
inputs="text",
outputs="text",
title="CrewAI Cryptocurrency Investment Plan",
description="Enter a cryptocurrency symbol to analyze and generate a comprehensive investment plan."
)
iface.launch()