quocdat25 commited on
Commit
d9b1770
1 Parent(s): 1f80e0d

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/agents-checkpoint.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent
2
+ # from langchain_community.tools import DuckDuckGoSearchRun
3
+ from crewai_tools import tool, SerperDevTool
4
+ from langchain_community.llms import HuggingFaceEndpoint
5
+
6
+ from tools.crypt_news_tool import GetCryptoNews
7
+ from tools.search_duckduckgo_tool import SearchDuckDuckGo
8
+ # from tools.crypt_news_tool import GetCryptoNews
9
+
10
+
11
+ search_tool = SerperDevTool()
12
+
13
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
14
+ llm = HuggingFaceEndpoint(
15
+ repo_id = repo_id,
16
+ # huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN,
17
+ )
18
+
19
+ class CryptoAnalysisAgents():
20
+ def crypto_analyst(self):
21
+ return Agent(
22
+ role='Crypto Analyst',
23
+ goal='Scrape the latest cryptocurrency news, indicators, tweets and current price of the target coin.',
24
+ backstory=(
25
+ 'Keen on staying ahead with the most current information, '
26
+ 'the Crypto Analyst scours through various media to gather the latest news and social sentiments.'
27
+ ),
28
+ tools=[
29
+ search_tool,
30
+ # GetCryptoNews(),
31
+ SearchDuckDuckGo()
32
+ ],
33
+ allow_delegation=False,
34
+ llm=llm,
35
+ verbose=True,
36
+ cache=True,
37
+ max_iter=20,
38
+ )
39
+
40
+ def content_writer(self):
41
+ return Agent(
42
+ role='Content Writer',
43
+ goal='Synthesize data and write engaging articles on latest trend of the target coin',
44
+ backstory=(
45
+ 'Armed with a flair for storytelling, the Content Writer transforms intricate crypto data into captivating narratives,'
46
+ 'illuminating the latest trends for a wide audience.'
47
+ ),
48
+ tools=[search_tool,
49
+ # AskWolframAlpha(),
50
+ ],
51
+ allow_delegation=False,
52
+ llm=llm,
53
+ verbose=True,
54
+ cache=True,
55
+ max_iter=20,
56
+ )
.ipynb_checkpoints/chat_gradio-checkpoint.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.llms import HuggingFaceEndpoint
2
+ from langchain.prompts import PromptTemplate
3
+ from langchain.schema import AIMessage, HumanMessage
4
+ from langchain.chains import LLMChain
5
+ import gradio as gr
6
+ import os
7
+
8
+ from dotenv import load_dotenv
9
+ load_dotenv()
10
+
11
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
12
+ llm = HuggingFaceEndpoint(
13
+ repo_id = repo_id,
14
+ )
15
+
16
+ template = """You're a good chatbot. Answer this request: {question}
17
+ Answer: Let's think step by step."""
18
+ prompt = PromptTemplate.from_template(template=template)
19
+ llm_chain = LLMChain(llm=llm, prompt=prompt)
20
+
21
+
22
+ def predict(message, history):
23
+ history_langchain_format = []
24
+ # for human, ai in history:
25
+ # history_langchain_format.append(HumanMessage(content=human))
26
+ # history_langchain_format.append(AIMessage(content=ai))
27
+ # history_langchain_format.append(HumanMessage(content=message))
28
+ # gpt_response = llm(history_langchain_format)
29
+ response = llm_chain.invoke(message)['text']
30
+ return response
31
+
32
+ gr.ChatInterface(predict).launch()
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
.ipynb_checkpoints/crew-checkpoint.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv, find_dotenv
2
+ from textwrap import dedent
3
+
4
+ load_dotenv(find_dotenv())
5
+
6
+ from agents import CryptoAnalysisAgents
7
+ from tasks import CryptoAnalysisTasks
8
+ from crewai import Crew
9
+
10
+
11
+ class CryptoCrew:
12
+ def __init__(self, coin):
13
+ self.coin = coin
14
+
15
+ def run(self):
16
+ agents = CryptoAnalysisAgents()
17
+ tasks = CryptoAnalysisTasks()
18
+
19
+ crypto_analyst = agents.crypto_analyst()
20
+ content_writer = agents.content_writer()
21
+
22
+ research_task = tasks.research(crypto_analyst, self.coin)
23
+ recommend_task = tasks.recommend(content_writer, self.coin)
24
+
25
+ crew = Crew(
26
+ agents=[
27
+ crypto_analyst,
28
+ content_writer,
29
+ ],
30
+ tasks=[
31
+ research_task,
32
+ recommend_task,
33
+ ],
34
+ verbose=True
35
+ )
36
+
37
+ result = crew.kickoff()
38
+ return result
39
+
40
+ # if __name__ == "__main__":
41
+ # print("## Welcome to Crypto Analysis Crew")
42
+ # print('-------------------------------')
43
+ # company = input(
44
+ # dedent("""
45
+ # Which cryptocurrency are you looking to delve into?
46
+ # """))
47
+
48
+ # crypto_crew = CryptoCrew(company)
49
+ # result = crypto_crew.run()
50
+ # print("\n\n########################")
51
+ # print("## Here is the Report")
52
+ # print("########################\n")
53
+
54
+ # print(result)
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
.ipynb_checkpoints/requirements-checkpoint.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ crewai
3
+ wolframalpha
4
+ duckduckgo-search
5
+ crewai[tools]
6
+ beautifulsoup4
7
+ requests
8
+ lxml
9
+ langchain-community
10
+ huggingface_hub
11
+ google-api-python-client
12
+ google-auth-httplib2
13
+ google-auth-oauthlib
.ipynb_checkpoints/run_local-checkpoint.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from langchain_community.llms import HuggingFaceEndpoint
2
+ # from langchain.prompts import PromptTemplate
3
+ # from langchain.schema import AIMessage, HumanMessage
4
+ # from langchain.chains import LLMChain
5
+ import gradio as gr
6
+ import os
7
+
8
+ from crew import CryptoCrew
9
+
10
+ from dotenv import load_dotenv
11
+
12
+ load_dotenv()
13
+
14
+ def predict(message):
15
+ # company = input(
16
+ # dedent("""
17
+ # Which cryptocurrency are you looking to delve into?
18
+ # """))
19
+ # history_langchain_format = []
20
+ # for human, ai in history:
21
+ # history_langchain_format.append(HumanMessage(content=human))
22
+ # history_langchain_format.append(AIMessage(content=ai))
23
+ # history_langchain_format.append(HumanMessage(content=message))
24
+ # gpt_response = llm(history_langchain_format)
25
+ # response = llm_chain.invoke(message)['text']
26
+
27
+ crypto_crew = CryptoCrew(company)
28
+ response = "## Here is the Report\n\n" + crypto_crew.run()
29
+
30
+ return response
31
+
32
+ gr.ChatInterface(predict).launch()
33
+
34
+ # if __name__ == "__main__":
35
+ # print("## Welcome to Crypto Analysis Crew")
36
+ # print('-------------------------------')
37
+ # company = input(
38
+ # dedent("""
39
+ # Which cryptocurrency are you looking to delve into?
40
+ # """))
41
+
42
+ # crypto_crew = CryptoCrew(company)
43
+ # result = crypto_crew.run()
44
+ # print("\n\n########################")
45
+ # print("## Here is the Report")
46
+ # print("########################\n")
47
+
48
+ # print(result)
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
.ipynb_checkpoints/tasks-checkpoint.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Task
2
+ from textwrap import dedent
3
+
4
+ class CryptoAnalysisTasks():
5
+ def research(self, agent, coin):
6
+ return Task(description=dedent(f"""
7
+ Conduct a comprehensive analysis of the crypto coin {coin} .
8
+ Make sure to use the most recent data as possible.
9
+ Identify reliably potential oppotunity of the coin: {coin}.
10
+ """),
11
+ expected_output="Full analysis report in bullet points",
12
+ # tools=[GetCryptoNews()],
13
+ agent=agent,
14
+ )
15
+
16
+ def recommend(self, agent, coin):
17
+ return Task(description=dedent(f"""
18
+ Review and synthesize the analyses provided by the Crypto Analyst.
19
+ Combine these insights to form a comprehensive investment recommendation.
20
+ Answer if it's worth to invest in the coin {coin}. """),
21
+ expected_output='A article of recommendations in bullet points',
22
+ agent=agent,
23
+ )
24
+
25
+ def __tip_section(self):
26
+ return "If you do your BEST WORK, I'll give you a $10,000 commission!"
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Crypto CrewAI
3
- emoji: 😻
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.26.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: crypto_crewAI
3
+ app_file: chat_gradio.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.26.0
 
 
6
  ---
 
 
__pycache__/agents.cpython-310.pyc ADDED
Binary file (1.74 kB). View file
 
__pycache__/chat_gradio.cpython-310.pyc ADDED
Binary file (960 Bytes). View file
 
__pycache__/tasks.cpython-310.pyc ADDED
Binary file (1.71 kB). View file
 
agents.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent
2
+ # from langchain_community.tools import DuckDuckGoSearchRun
3
+ from crewai_tools import tool, SerperDevTool
4
+ from langchain_community.llms import HuggingFaceEndpoint
5
+
6
+ from tools.crypt_news_tool import GetCryptoNews
7
+ from tools.search_duckduckgo_tool import SearchDuckDuckGo
8
+ # from tools.crypt_news_tool import GetCryptoNews
9
+
10
+
11
+ search_tool = SerperDevTool()
12
+
13
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
14
+ llm = HuggingFaceEndpoint(
15
+ repo_id = repo_id,
16
+ # huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN,
17
+ )
18
+
19
+ class CryptoAnalysisAgents():
20
+ def crypto_analyst(self):
21
+ return Agent(
22
+ role='Crypto Analyst',
23
+ goal='Scrape the latest cryptocurrency news, indicators, tweets and current price of the target coin.',
24
+ backstory=(
25
+ 'Keen on staying ahead with the most current information, '
26
+ 'the Crypto Analyst scours through various media to gather the latest news and social sentiments.'
27
+ ),
28
+ tools=[
29
+ search_tool,
30
+ # GetCryptoNews(),
31
+ SearchDuckDuckGo()
32
+ ],
33
+ allow_delegation=False,
34
+ llm=llm,
35
+ verbose=True,
36
+ cache=True,
37
+ max_iter=20,
38
+ )
39
+
40
+ def content_writer(self):
41
+ return Agent(
42
+ role='Content Writer',
43
+ goal='Synthesize data and write engaging articles on latest trend of the target coin',
44
+ backstory=(
45
+ 'Armed with a flair for storytelling, the Content Writer transforms intricate crypto data into captivating narratives,'
46
+ 'illuminating the latest trends for a wide audience.'
47
+ ),
48
+ tools=[search_tool,
49
+ # AskWolframAlpha(),
50
+ ],
51
+ allow_delegation=False,
52
+ llm=llm,
53
+ verbose=True,
54
+ cache=True,
55
+ max_iter=20,
56
+ )
chat_gradio.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.llms import HuggingFaceEndpoint
2
+ from langchain.prompts import PromptTemplate
3
+ from langchain.schema import AIMessage, HumanMessage
4
+ from langchain.chains import LLMChain
5
+ import gradio as gr
6
+ import os
7
+
8
+ from dotenv import load_dotenv
9
+ load_dotenv()
10
+
11
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
12
+ llm = HuggingFaceEndpoint(
13
+ repo_id = repo_id,
14
+ )
15
+
16
+ template = """You're a good chatbot. Answer this request: {question}
17
+ Answer: Let's think step by step."""
18
+ prompt = PromptTemplate.from_template(template=template)
19
+ llm_chain = LLMChain(llm=llm, prompt=prompt)
20
+
21
+
22
+ def predict(message, history):
23
+ history_langchain_format = []
24
+ # for human, ai in history:
25
+ # history_langchain_format.append(HumanMessage(content=human))
26
+ # history_langchain_format.append(AIMessage(content=ai))
27
+ # history_langchain_format.append(HumanMessage(content=message))
28
+ # gpt_response = llm(history_langchain_format)
29
+ response = llm_chain.invoke(message)['text']
30
+ return response
31
+
32
+ gr.ChatInterface(predict).launch()
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
crew.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv, find_dotenv
2
+ from textwrap import dedent
3
+
4
+ load_dotenv(find_dotenv())
5
+
6
+ from agents import CryptoAnalysisAgents
7
+ from tasks import CryptoAnalysisTasks
8
+ from crewai import Crew
9
+
10
+
11
+ class CryptoCrew:
12
+ def __init__(self, coin):
13
+ self.coin = coin
14
+
15
+ def run(self):
16
+ agents = CryptoAnalysisAgents()
17
+ tasks = CryptoAnalysisTasks()
18
+
19
+ crypto_analyst = agents.crypto_analyst()
20
+ content_writer = agents.content_writer()
21
+
22
+ research_task = tasks.research(crypto_analyst, self.coin)
23
+ recommend_task = tasks.recommend(content_writer, self.coin)
24
+
25
+ crew = Crew(
26
+ agents=[
27
+ crypto_analyst,
28
+ content_writer,
29
+ ],
30
+ tasks=[
31
+ research_task,
32
+ recommend_task,
33
+ ],
34
+ verbose=True
35
+ )
36
+
37
+ result = crew.kickoff()
38
+ return result
39
+
40
+ # if __name__ == "__main__":
41
+ # print("## Welcome to Crypto Analysis Crew")
42
+ # print('-------------------------------')
43
+ # company = input(
44
+ # dedent("""
45
+ # Which cryptocurrency are you looking to delve into?
46
+ # """))
47
+
48
+ # crypto_crew = CryptoCrew(company)
49
+ # result = crypto_crew.run()
50
+ # print("\n\n########################")
51
+ # print("## Here is the Report")
52
+ # print("########################\n")
53
+
54
+ # print(result)
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ crewai
3
+ wolframalpha
4
+ duckduckgo-search
5
+ crewai[tools]
6
+ beautifulsoup4
7
+ requests
8
+ lxml
9
+ langchain-community
10
+ huggingface_hub
11
+ google-api-python-client
12
+ google-auth-httplib2
13
+ google-auth-oauthlib
run_local.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from langchain_community.llms import HuggingFaceEndpoint
2
+ # from langchain.prompts import PromptTemplate
3
+ # from langchain.schema import AIMessage, HumanMessage
4
+ # from langchain.chains import LLMChain
5
+ import gradio as gr
6
+ import os
7
+
8
+ from crew import CryptoCrew
9
+
10
+ from dotenv import load_dotenv
11
+
12
+ load_dotenv()
13
+
14
+ def predict(message):
15
+ # company = input(
16
+ # dedent("""
17
+ # Which cryptocurrency are you looking to delve into?
18
+ # """))
19
+ # history_langchain_format = []
20
+ # for human, ai in history:
21
+ # history_langchain_format.append(HumanMessage(content=human))
22
+ # history_langchain_format.append(AIMessage(content=ai))
23
+ # history_langchain_format.append(HumanMessage(content=message))
24
+ # gpt_response = llm(history_langchain_format)
25
+ # response = llm_chain.invoke(message)['text']
26
+
27
+ crypto_crew = CryptoCrew(company)
28
+ response = "## Here is the Report\n\n" + crypto_crew.run()
29
+
30
+ return response
31
+
32
+ gr.ChatInterface(predict).launch()
33
+
34
+ # if __name__ == "__main__":
35
+ # print("## Welcome to Crypto Analysis Crew")
36
+ # print('-------------------------------')
37
+ # company = input(
38
+ # dedent("""
39
+ # Which cryptocurrency are you looking to delve into?
40
+ # """))
41
+
42
+ # crypto_crew = CryptoCrew(company)
43
+ # result = crypto_crew.run()
44
+ # print("\n\n########################")
45
+ # print("## Here is the Report")
46
+ # print("########################\n")
47
+
48
+ # print(result)
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
tasks.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Task
2
+ from textwrap import dedent
3
+
4
+ class CryptoAnalysisTasks():
5
+ def research(self, agent, coin):
6
+ return Task(description=dedent(f"""
7
+ Conduct a comprehensive analysis of the crypto coin {coin} .
8
+ Make sure to use the most recent data as possible.
9
+ Identify reliably potential oppotunity of the coin: {coin}.
10
+ """),
11
+ expected_output="Full analysis report in bullet points",
12
+ # tools=[GetCryptoNews()],
13
+ agent=agent,
14
+ )
15
+
16
+ def recommend(self, agent, coin):
17
+ return Task(description=dedent(f"""
18
+ Review and synthesize the analyses provided by the Crypto Analyst.
19
+ Combine these insights to form a comprehensive investment recommendation.
20
+ Answer if it's worth to invest in the coin {coin}. """),
21
+ expected_output='A article of recommendations in bullet points',
22
+ agent=agent,
23
+ )
24
+
25
+ def __tip_section(self):
26
+ return "If you do your BEST WORK, I'll give you a $10,000 commission!"
tools/.ipynb_checkpoints/__init__-checkpoint.py ADDED
File without changes
tools/.ipynb_checkpoints/crypt_news_tool-checkpoint.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ from crewai_tools import BaseTool
4
+
5
+ class GetCryptoNews(BaseTool):
6
+ name: str = "GetCryptoNews"
7
+ description: str = "fetch news from https://cryptonews.com/"
8
+
9
+ def _run(self, argument: str) -> str:
10
+ url = "https://cryptonews.com/"
11
+ response = requests.get(url)
12
+ webpage = response.text
13
+ soup = BeautifulSoup(webpage,'html.parser')
14
+ articles = soup.select("#main-news-left .title-news-slider")
15
+
16
+ data = ""
17
+ for article in articles[:5]:
18
+ title = article.text.strip()
19
+ url = article['href']
20
+
21
+ response = requests.get(url)
22
+ article_page = response.text
23
+ soup = BeautifulSoup(article_page, 'html.parser')
24
+
25
+ data += f'Title: {title}, Content: '
26
+
27
+ for section in soup.find_all(['h1', 'h2', 'h3', 'p']):
28
+ data += section.text.strip()
29
+
30
+ return data
tools/.ipynb_checkpoints/search_duckduckgo_tool-checkpoint.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai_tools import BaseTool
2
+ from langchain_community.tools import DuckDuckGoSearchRun
3
+
4
+
5
+ class SearchDuckDuckGo(BaseTool):
6
+ name: str = "SearchDuckDuckGo"
7
+ description: str = "use DuckDuckGo to fetch some news"
8
+ def _run(self, question: str) -> str:
9
+ search = DuckDuckGoSearchRun()
10
+ result = search.run(question)
11
+ return result
tools/.ipynb_checkpoints/wolfram_alpha_tool-checkpoint.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai_tools import BaseTool
2
+
3
+ from langchain_community.utilities.wolfram_alpha import WolframAlphaAPIWrapper
4
+
5
+ wolfram = WolframAlphaAPIWrapper()
6
+
7
+ class AskWolframAlpha(BaseTool):
8
+ name: str = "AskWolframAlpha"
9
+ description: str = "use WolframAlpha to analyze data"
10
+
11
+ def _run(self, question: str) -> str:
12
+ "Ask Wolfram Alpha to do math, e.g : descriptive statistics {20.9,23.2,26.2,26.4}"
13
+ wolfram = WolframAlphaAPIWrapper()
14
+ return wolfram.run(question)
15
+
16
+ # Test
17
+ # print(AskWolframAlpha()._run("descriptive statistics {20.9,23.2,26.2,26.4,20.9,23.2,26.2,26.4,20.9}"))
tools/__init__.py ADDED
File without changes
tools/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (135 Bytes). View file
 
tools/__pycache__/crypt_news_tool.cpython-310.pyc ADDED
Binary file (1.12 kB). View file
 
tools/__pycache__/search_duckduckgo_tool.cpython-310.pyc ADDED
Binary file (740 Bytes). View file
 
tools/crypt_news_tool.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ from crewai_tools import BaseTool
4
+
5
+ class GetCryptoNews(BaseTool):
6
+ name: str = "GetCryptoNews"
7
+ description: str = "fetch news from https://cryptonews.com/"
8
+
9
+ def _run(self, argument: str) -> str:
10
+ url = "https://cryptonews.com/"
11
+ response = requests.get(url)
12
+ webpage = response.text
13
+ soup = BeautifulSoup(webpage,'html.parser')
14
+ articles = soup.select("#main-news-left .title-news-slider")
15
+
16
+ data = ""
17
+ for article in articles[:5]:
18
+ title = article.text.strip()
19
+ url = article['href']
20
+
21
+ response = requests.get(url)
22
+ article_page = response.text
23
+ soup = BeautifulSoup(article_page, 'html.parser')
24
+
25
+ data += f'Title: {title}, Content: '
26
+
27
+ for section in soup.find_all(['h1', 'h2', 'h3', 'p']):
28
+ data += section.text.strip()
29
+
30
+ return data
tools/search_duckduckgo_tool.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai_tools import BaseTool
2
+ from langchain_community.tools import DuckDuckGoSearchRun
3
+
4
+
5
+ class SearchDuckDuckGo(BaseTool):
6
+ name: str = "SearchDuckDuckGo"
7
+ description: str = "use DuckDuckGo to fetch some news"
8
+ def _run(self, question: str) -> str:
9
+ search = DuckDuckGoSearchRun()
10
+ result = search.run(question)
11
+ return result
tools/wolfram_alpha_tool.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai_tools import BaseTool
2
+
3
+ from langchain_community.utilities.wolfram_alpha import WolframAlphaAPIWrapper
4
+
5
+ wolfram = WolframAlphaAPIWrapper()
6
+
7
+ class AskWolframAlpha(BaseTool):
8
+ name: str = "AskWolframAlpha"
9
+ description: str = "use WolframAlpha to analyze data"
10
+
11
+ def _run(self, question: str) -> str:
12
+ "Ask Wolfram Alpha to do math, e.g : descriptive statistics {20.9,23.2,26.2,26.4}"
13
+ wolfram = WolframAlphaAPIWrapper()
14
+ return wolfram.run(question)
15
+
16
+ # Test
17
+ # print(AskWolframAlpha()._run("descriptive statistics {20.9,23.2,26.2,26.4,20.9,23.2,26.2,26.4,20.9}"))