|
import os |
|
from crewai import Agent, Task, Crew, Process |
|
from langchain.tools import DuckDuckGoSearchRun |
|
from langchain.agents import Tool |
|
import gradio as gr |
|
|
|
|
|
duckduckgo_search_tool = DuckDuckGoSearchRun() |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
def create_crewai_crypto_setup(crypto_symbol): |
|
|
|
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, |
|
) |
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
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, |
|
) |
|
|
|
|
|
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 |
|
|
|
|
|
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() |
|
|