Skip to content

Commit

Permalink
Merge pull request #39 from MervinPraison/feature/PRAISON-1-add-tools
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
MervinPraison authored Jun 10, 2024
2 parents 16f04dc + 93945fd commit 9f8c60a
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 21 deletions.
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@ assets/*
praisonAI.egg-info
flagged
test.yaml
db
db
praisonai_prompt.txt
watch.sh
docs.sh
# Ignore Sphinx build directory
docs/_build/
docs/source/
docs/build/

# Ignore Sphinx cache
docs/_build/doctrees/
docs/_build/doctrees/*
docs/_build/doctrees/.doctrees

# Ignore Sphinx logs and local build files
docs/_build/.buildinfo
docs/_build/.buildinfo/*
docs/_build/.buildinfo/.buildinfo
35 changes: 35 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install flask praisonai==0.0.20 gunicorn markdown
RUN pip install flask praisonai==0.0.21 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
45 changes: 29 additions & 16 deletions agents.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
framework: crewai
topic: research about the latest AI News and prepare a detailed report
topic: research about the causes of lung disease
roles:
research_analyst:
backstory: Experienced in gathering and analyzing data related to AI news trends.
goal: Analyze AI News trends
backstory: Experienced in analyzing scientific data related to respiratory health.
goal: Analyze data on lung diseases
role: Research Analyst
tasks:
gather_data:
description: Conduct in-depth research on the latest AI News trends from reputable
sources.
expected_output: Comprehensive report on current AI News trends.
data_analysis:
description: Gather and analyze data on the causes and risk factors of lung
diseases.
expected_output: Report detailing key findings on lung disease causes.
tools:
- 'InternetSearchTool'
content_creator:
backstory: Skilled in writing informative and engaging content about AI News.
goal: Create detailed reports on AI News
role: Content Creator
- 'PubmedQueryRun'
medical_writer:
backstory: Skilled in translating complex medical information into accessible
content.
goal: Compile comprehensive content on lung disease causes
role: Medical Writer
tasks:
compile_report:
description: Compile all gathered data into a detailed report with analysis
and insights.
expected_output: Well-structured report on the latest AI News with key insights.
content_creation:
description: Create detailed content summarizing the research findings on
lung disease causes.
expected_output: Document outlining various causes and risk factors of lung
diseases.
tools:
- ''
editor:
backstory: Proficient in editing medical content for accuracy and clarity.
goal: Review and refine content on lung disease causes
role: Editor
tasks:
content_review:
description: Edit and refine the compiled content on lung disease causes for
accuracy and coherence.
expected_output: Finalized document on lung disease causes ready for dissemination.
tools:
- ''
dependencies: []
43 changes: 43 additions & 0 deletions agents_playbook/finance-research.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
framework: crewai
topic: research about nvidia growth
roles:
data_collector:
backstory: An experienced researcher with the ability to efficiently collect and
organize vast amounts of data.
goal: Gather information on Nvidia's growth
role: Data Collector
tasks:
data_collection_task:
description: Collect data on Nvidia's growth from various sources such as
financial reports, news articles, and company announcements.
expected_output: A comprehensive document detailing data points on Nvidia's
growth over the years.
tools:
- 'YouSearchTool'
data_analyst:
backstory: Specializes in extracting insights from large datasets, proficient
in quantitative and qualitative analysis.
goal: Analyze the collected data to identify trends and patterns
role: Data Analyst
tasks:
data_analysis_task:
description: Analyze the collected data to identify key trends and patterns
in Nvidia's growth.
expected_output: An analytical report summarizing trends, patterns, and key
growth metrics of Nvidia.
tools:
- ''
report_preparer:
backstory: Experienced in creating detailed reports and presentations, turning
analytical data into actionable insights.
goal: Generate a final report on Nvidia's growth
role: Report Preparer
tasks:
report_preparation_task:
description: Create a detailed report based on the analysis, highlighting
Nvidia's growth trajectory.
expected_output: A polished, comprehensive report summarizing Nvidia's growth
with visual aids and key insights.
tools:
- ''
dependencies: []
39 changes: 39 additions & 0 deletions agents_playbook/medical-research-pubmed-agents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
framework: crewai
topic: research about the causes of lung disease
roles:
research_analyst:
backstory: Experienced in analyzing scientific data related to respiratory health.
goal: Analyze data on lung diseases
role: Research Analyst
tasks:
data_analysis:
description: Gather and analyze data on the causes and risk factors of lung
diseases.
expected_output: Report detailing key findings on lung disease causes.
tools:
- 'PubmedQueryRun'
medical_writer:
backstory: Skilled in translating complex medical information into accessible
content.
goal: Compile comprehensive content on lung disease causes
role: Medical Writer
tasks:
content_creation:
description: Create detailed content summarizing the research findings on
lung disease causes.
expected_output: Document outlining various causes and risk factors of lung
diseases.
tools:
- ''
editor:
backstory: Proficient in editing medical content for accuracy and clarity.
goal: Review and refine content on lung disease causes
role: Editor
tasks:
content_review:
description: Edit and refine the compiled content on lung disease causes for
accuracy and coherence.
expected_output: Finalized document on lung disease causes ready for dissemination.
tools:
- ''
dependencies: []
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
28 changes: 28 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'PraisonAI'
copyright = '2024, Mervin Praison'
author = 'Mervin Praison'
release = '0.0.21'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx_rtd_theme']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. PraisonAI documentation master file, created by
sphinx-quickstart on Mon Jun 10 12:11:57 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to PraisonAI's documentation!
=====================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
49 changes: 49 additions & 0 deletions hub/tools/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# tools.py
from duckduckgo_search import DDGS
from praisonai_tools import BaseTool

class InternetSearchTool(BaseTool):
name: str = "InternetSearchTool"
description: str = "Search Internet for relevant information based on a query or latest news"

def _run(self, query: str):
ddgs = DDGS()
results = ddgs.text(keywords=query, region='wt-wt', safesearch='moderate', max_results=5)
return results

from langchain_community.tools.pubmed.tool import PubmedQueryRun
from langchain_community.tools.reddit_search.tool import RedditSearchRun
# pip install tavily-python
from langchain_community.utilities.tavily_search import TavilySearchAPIWrapper
from langchain_community.utilities.you import YouSearchAPIWrapper
# pip install youtube_search
from langchain_community.tools import YouTubeSearchTool
# pip install wikipedia
from langchain_community.utilities import WikipediaAPIWrapper

class TavilyTool(BaseTool):
name: str = "TavilyTool"
description: str = "Search Tavily for relevant information based on a query."

def _run(self, query: str):
api_wrapper = TavilySearchAPIWrapper()
results = api_wrapper.results(query=query, max_results=5)
return results

class YouSearchTool(BaseTool):
name: str = "You Search Tool"
description: str = "Search You.com for relevant information based on a query."

def _run(self, query: str):
api_wrapper = YouSearchAPIWrapper()
results = api_wrapper.results(query=query, max_results=5)
return results

class WikipediaSearchTool(BaseTool):
name: str = "WikipediaSearchTool"
description: str = "Search Wikipedia for relevant information based on a query."

def _run(self, query: str):
api_wrapper = WikipediaAPIWrapper(top_k_results=4, doc_content_chars_max=100)
results = api_wrapper.load(query=query)
return results
2 changes: 1 addition & 1 deletion praisonai/agents_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load_tools_from_module_class(self, module_path):
spec = importlib.util.spec_from_file_location("tools_module", module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return {name: obj() for name, obj in inspect.getmembers(module, lambda x: inspect.isclass(x) and issubclass(x, BaseTool) and x is not BaseTool)}
return {name: obj() for name, obj in inspect.getmembers(module, lambda x: inspect.isclass(x) and (x.__module__.startswith('langchain_community.tools') or issubclass(x, BaseTool)) and x is not BaseTool)}

def load_tools_from_package(self, package_path):
tools_dict = {}
Expand Down
2 changes: 1 addition & 1 deletion praisonai/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create_dockerfile(self):
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==0.0.20 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==0.0.21 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "praisonAI"
version = "0.0.20"
version = "0.0.21"
description = "praisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration."
authors = ["Mervin Praison"]
license = ""
Expand Down

0 comments on commit 9f8c60a

Please sign in to comment.