File size: 2,926 Bytes
476759f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from dotenv import load_dotenv

load_dotenv()
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
TAVILY_API_KEY = os.getenv('TAVILY_API_KEY')

from langchain_openai import ChatOpenAI
from crewai import Agent, Task, Crew, Process

llm = ChatOpenAI(model='gpt-3.5-turbo', temperature=0, api_key=OPENAI_API_KEY)

from langchain_community.tools.tavily_search import TavilySearchResults

search_tool = TavilySearchResults(api_key = TAVILY_API_KEY)

def rus_crypto_crew(topic):
    researcher = Agent(
        role = 'Market Researcher',
        goal = f'Uncover emerging trend and investment opportunities in the cryptocurrency market in 2024. Focus on topic {topic}',
        backstory = 'Identify groundbreaking trend and actionable insights.',
        verbose = True,
        tools = [search_tool],
        allow_delegation = False,
        llm = llm,
        max_iter = 3,
        max_rpm = 10
    )

    analyst = Agent(
        role = 'investment analyst',
        goal = f'Analyze cryptocurrency market data to extract actionable insights and investment leads. Focus on topic {topic}',
        backstory = 'Draw meaningful conclusion from market data.',
        verbose = True,
        allow_delegation = False,
        llm = llm
    )

    translator = Agent(
        role = 'translator',
        goal = 'Translate report about cryptocurrency market data into korean',
        backstory = 'Translate this sentence into very natural Korean.',
        verbose = True,
        allow_delegation = False,
        llm = llm
    )


    research_task = Task(
        description = 'Explore the internet to pinpoint emerging trends and potential investment opportunities.',
        agent = researcher,
        expected_output='A detailed summary of the reserch results in string format'
    )

    analyze_task = Task(
        description = 'Analyze the provided cryptocurrency market data to extract key insights and compile a concise report.',
        agent = analyst,
        expected_output='A refined finalized version of the report in string format'
    )

    translate_task = Task(
        description = 'Translate documents written by analyst into korean.',
        agent = translator,
        expected_output = 'A translated report written by analyst(english into korean).'
    )

    crypto_crew = Crew(
        agents = [researcher, analyst, translator],
        tasks = [research_task, analyze_task, translate_task],
        process = Process.sequential
    )

    result = crypto_crew.kickoff()
    return result

import gradio as gr

def process_query(message, history):
    return rus_crypto_crew(message)

app = gr.ChatInterface(
    fn = process_query,
    title = 'Crypto Investment Advisor Bot',
    description = '์•”ํ˜ธํ™”ํ ๊ด€๋ จ ํŠธ๋ Œ๋“œ๋ฅผ ํŒŒ์•…ํ•˜์—ฌ ํˆฌ์ž ์ธ์‚ฌ์ดํŠธ๋ฅผ ์ œ๊ณตํ•ด๋“œ๋ฆฝ๋‹ˆ๋‹ค.'
)
app.launch()