Upload 2 files
Browse filesmaking cryptocurrency report based on internet research with korean Hangul.
- app.py +86 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
|
4 |
+
load_dotenv()
|
5 |
+
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
6 |
+
TAVILY_API_KEY = os.getenv('TAVILY_API_KEY')
|
7 |
+
|
8 |
+
from langchain_openai import ChatOpenAI
|
9 |
+
from crewai import Agent, Task, Crew, Process
|
10 |
+
|
11 |
+
llm = ChatOpenAI(model='gpt-3.5-turbo', temperature=0, api_key=OPENAI_API_KEY)
|
12 |
+
|
13 |
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
14 |
+
|
15 |
+
search_tool = TavilySearchResults(api_key = TAVILY_API_KEY)
|
16 |
+
|
17 |
+
def rus_crypto_crew(topic):
|
18 |
+
researcher = Agent(
|
19 |
+
role = 'Market Researcher',
|
20 |
+
goal = f'Uncover emerging trend and investment opportunities in the cryptocurrency market in 2024. Focus on topic {topic}',
|
21 |
+
backstory = 'Identify groundbreaking trend and actionable insights.',
|
22 |
+
verbose = True,
|
23 |
+
tools = [search_tool],
|
24 |
+
allow_delegation = False,
|
25 |
+
llm = llm,
|
26 |
+
max_iter = 3,
|
27 |
+
max_rpm = 10
|
28 |
+
)
|
29 |
+
|
30 |
+
analyst = Agent(
|
31 |
+
role = 'investment analyst',
|
32 |
+
goal = f'Analyze cryptocurrency market data to extract actionable insights and investment leads. Focus on topic {topic}',
|
33 |
+
backstory = 'Draw meaningful conclusion from market data.',
|
34 |
+
verbose = True,
|
35 |
+
allow_delegation = False,
|
36 |
+
llm = llm
|
37 |
+
)
|
38 |
+
|
39 |
+
translator = Agent(
|
40 |
+
role = 'translator',
|
41 |
+
goal = 'Translate report about cryptocurrency market data into korean',
|
42 |
+
backstory = 'Translate this sentence into very natural Korean.',
|
43 |
+
verbose = True,
|
44 |
+
allow_delegation = False,
|
45 |
+
llm = llm
|
46 |
+
)
|
47 |
+
|
48 |
+
|
49 |
+
research_task = Task(
|
50 |
+
description = 'Explore the internet to pinpoint emerging trends and potential investment opportunities.',
|
51 |
+
agent = researcher,
|
52 |
+
expected_output='A detailed summary of the reserch results in string format'
|
53 |
+
)
|
54 |
+
|
55 |
+
analyze_task = Task(
|
56 |
+
description = 'Analyze the provided cryptocurrency market data to extract key insights and compile a concise report.',
|
57 |
+
agent = analyst,
|
58 |
+
expected_output='A refined finalized version of the report in string format'
|
59 |
+
)
|
60 |
+
|
61 |
+
translate_task = Task(
|
62 |
+
description = 'Translate documents written by analyst into korean.',
|
63 |
+
agent = translator,
|
64 |
+
expected_output = 'A translated report written by analyst(english into korean).'
|
65 |
+
)
|
66 |
+
|
67 |
+
crypto_crew = Crew(
|
68 |
+
agents = [researcher, analyst, translator],
|
69 |
+
tasks = [research_task, analyze_task, translate_task],
|
70 |
+
process = Process.sequential
|
71 |
+
)
|
72 |
+
|
73 |
+
result = crypto_crew.kickoff()
|
74 |
+
return result
|
75 |
+
|
76 |
+
import gradio as gr
|
77 |
+
|
78 |
+
def process_query(message, history):
|
79 |
+
return rus_crypto_crew(message)
|
80 |
+
|
81 |
+
app = gr.ChatInterface(
|
82 |
+
fn = process_query,
|
83 |
+
title = 'Crypto Investment Advisor Bot',
|
84 |
+
description = '์ํธํํ ๊ด๋ จ ํธ๋ ๋๋ฅผ ํ์
ํ์ฌ ํฌ์ ์ธ์ฌ์ดํธ๋ฅผ ์ ๊ณตํด๋๋ฆฝ๋๋ค.'
|
85 |
+
)
|
86 |
+
app.launch()
|
requirements.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|