Skip to content

Commit

Permalink
Merge pull request #27 from MervinPraison/feature/PRAISON-1-add-tools
Browse files Browse the repository at this point in the history
Feature/praison 1 add tools
  • Loading branch information
MervinPraison authored May 3, 2024
2 parents 7ae5f05 + c7b555a commit 7af1894
Show file tree
Hide file tree
Showing 16 changed files with 986 additions and 1,523 deletions.
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.18 gunicorn markdown
RUN pip install flask praisonai==0.0.19 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
1,888 changes: 955 additions & 933 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions praisonai/agents_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
import gradio as gr
import argparse
from .auto import AutoGenerator
from crewai_tools import *
from crewai_tools import (
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
YoutubeVideoSearchTool
)
from .inbuilt_tools import *
import inspect
from pathlib import Path
import importlib
import importlib.util
from praisonai_tools import BaseTool

class AgentsGenerator:
def __init__(self, agent_file, framework, config_list):
Expand Down Expand Up @@ -88,11 +94,10 @@ def generate_crew_and_kickoff(self):

if os.path.isfile(tools_py_path):
tools_dict.update(self.load_tools_from_module_class(tools_py_path))
print("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
# print("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
elif tools_dir_path.is_dir():
tools_dict.update(self.load_tools_from_module_class(tools_dir_path))
print("tools folder exists in the root directory")
# print(tools_dict)
# print("tools folder exists in the root directory")

framework = self.framework or config.get('framework')

Expand Down Expand Up @@ -166,7 +171,6 @@ def generate_crew_and_kickoff(self):

task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
tasks.append(task)
print(agents.values())
crew = Crew(
agents=list(agents.values()),
tasks=tasks,
Expand Down
40 changes: 0 additions & 40 deletions praisonai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import argparse
from .auto import AutoGenerator
from .agents_generator import AgentsGenerator
from crewai_tools import *
from .inbuilt_tools import *

class PraisonAI:
Expand Down Expand Up @@ -49,7 +48,6 @@ def main(self):
print("test")
else:
self.agent_file = args.agent_file
print(self.agent_file)


if args.auto or args.init:
Expand Down Expand Up @@ -119,41 +117,3 @@ def generate_crew_and_kickoff_interface(auto_args, framework):
if __name__ == "__main__":
praison_ai = PraisonAI()
praison_ai.main()



## agents.yaml
# framework: autogen
# topic: create movie script about cat in mars
# roles:
# concept_developer:
# backstory: Experienced in creating captivating and original story concepts.
# goal: Generate a unique concept for a movie script about a cat in Mars
# role: Concept Developer
# tools:
# - search_tool
# tasks:
# concept_generation:
# description: Develop a unique and engaging concept for a movie script about
# a cat in Mars.
# expected_output: A detailed concept document for the movie script.
# scriptwriter:
# backstory: Expert in dialogue and script structure, translating concepts into
# scripts.
# goal: Write a script based on the movie concept
# role: Scriptwriter
# tasks:
# scriptwriting_task:
# description: Turn the movie concept into a script, including dialogue and
# scenes.
# expected_output: A production-ready script for the movie about a cat in Mars.
# director:
# backstory: Experienced in visualizing scripts and creating compelling storyboards.
# goal: Create a storyboard and visualize the script
# role: Director
# tasks:
# storyboard_creation:
# description: Create a storyboard for the movie script about a cat in Mars.
# expected_output: A detailed storyboard for the movie about a cat in Mars.
# dependencies: []

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.18 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==0.0.19 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')

Expand Down
20 changes: 16 additions & 4 deletions praisonai/inbuilt_tools/autogen_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ def tool_func(query: str) -> Any:
return autogen_tool

# Load tools.py
tools_module = importlib.import_module("tools")
root_directory = os.getcwd()
tools_py_path = os.path.join(root_directory, 'tools.py')
tools_dir_path = Path(root_directory) / 'tools'

tools_module = None

if os.path.isfile(tools_py_path):
print(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
tools_module = importlib.import_module("tools")
elif tools_dir_path.is_dir():
print(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
tools_module = importlib.import_module(f"tools.{tool_name}")

# Create autogen_TOOL_NAME_HERE function for each tool
for name, obj in inspect.getmembers(tools_module):
if inspect.isclass(obj):
globals()[f"autogen_{name}"] = create_autogen_tool_function(name)
if tools_module is not None:
for name, obj in inspect.getmembers(tools_module):
if inspect.isclass(obj):
globals()[f"autogen_{name}"] = create_autogen_tool_function(name)

def autogen_CodeDocsSearchTool(assistant, user_proxy):
def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
Expand Down
146 changes: 0 additions & 146 deletions praisonai/inbuilt_tools/base_tool.py

This file was deleted.

Loading

0 comments on commit 7af1894

Please sign in to comment.