Skip to content

Commit 7af1894

Browse files
Merge pull request #27 from MervinPraison/feature/PRAISON-1-add-tools
Feature/praison 1 add tools
2 parents 7ae5f05 + c7b555a commit 7af1894

16 files changed

+986
-1523
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.11-slim
22
WORKDIR /app
33
COPY . .
4-
RUN pip install flask praisonai==0.0.18 gunicorn markdown
4+
RUN pip install flask praisonai==0.0.19 gunicorn markdown
55
EXPOSE 8080
66
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]

poetry.lock

Lines changed: 955 additions & 933 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

praisonai/agents_generator.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@
1111
import gradio as gr
1212
import argparse
1313
from .auto import AutoGenerator
14-
from crewai_tools import *
14+
from crewai_tools import (
15+
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
16+
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
17+
ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
18+
YoutubeVideoSearchTool
19+
)
1520
from .inbuilt_tools import *
1621
import inspect
1722
from pathlib import Path
1823
import importlib
1924
import importlib.util
25+
from praisonai_tools import BaseTool
2026

2127
class AgentsGenerator:
2228
def __init__(self, agent_file, framework, config_list):
@@ -88,11 +94,10 @@ def generate_crew_and_kickoff(self):
8894

8995
if os.path.isfile(tools_py_path):
9096
tools_dict.update(self.load_tools_from_module_class(tools_py_path))
91-
print("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
97+
# print("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
9298
elif tools_dir_path.is_dir():
9399
tools_dict.update(self.load_tools_from_module_class(tools_dir_path))
94-
print("tools folder exists in the root directory")
95-
# print(tools_dict)
100+
# print("tools folder exists in the root directory")
96101

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

@@ -166,7 +171,6 @@ def generate_crew_and_kickoff(self):
166171

167172
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
168173
tasks.append(task)
169-
print(agents.values())
170174
crew = Crew(
171175
agents=list(agents.values()),
172176
tasks=tasks,

praisonai/cli.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import argparse
1313
from .auto import AutoGenerator
1414
from .agents_generator import AgentsGenerator
15-
from crewai_tools import *
1615
from .inbuilt_tools import *
1716

1817
class PraisonAI:
@@ -49,7 +48,6 @@ def main(self):
4948
print("test")
5049
else:
5150
self.agent_file = args.agent_file
52-
print(self.agent_file)
5351

5452

5553
if args.auto or args.init:
@@ -119,41 +117,3 @@ def generate_crew_and_kickoff_interface(auto_args, framework):
119117
if __name__ == "__main__":
120118
praison_ai = PraisonAI()
121119
praison_ai.main()
122-
123-
124-
125-
## agents.yaml
126-
# framework: autogen
127-
# topic: create movie script about cat in mars
128-
# roles:
129-
# concept_developer:
130-
# backstory: Experienced in creating captivating and original story concepts.
131-
# goal: Generate a unique concept for a movie script about a cat in Mars
132-
# role: Concept Developer
133-
# tools:
134-
# - search_tool
135-
# tasks:
136-
# concept_generation:
137-
# description: Develop a unique and engaging concept for a movie script about
138-
# a cat in Mars.
139-
# expected_output: A detailed concept document for the movie script.
140-
# scriptwriter:
141-
# backstory: Expert in dialogue and script structure, translating concepts into
142-
# scripts.
143-
# goal: Write a script based on the movie concept
144-
# role: Scriptwriter
145-
# tasks:
146-
# scriptwriting_task:
147-
# description: Turn the movie concept into a script, including dialogue and
148-
# scenes.
149-
# expected_output: A production-ready script for the movie about a cat in Mars.
150-
# director:
151-
# backstory: Experienced in visualizing scripts and creating compelling storyboards.
152-
# goal: Create a storyboard and visualize the script
153-
# role: Director
154-
# tasks:
155-
# storyboard_creation:
156-
# description: Create a storyboard for the movie script about a cat in Mars.
157-
# expected_output: A detailed storyboard for the movie about a cat in Mars.
158-
# dependencies: []
159-

praisonai/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def create_dockerfile(self):
1313
file.write("FROM python:3.11-slim\n")
1414
file.write("WORKDIR /app\n")
1515
file.write("COPY . .\n")
16-
file.write("RUN pip install flask praisonai==0.0.18 gunicorn markdown\n")
16+
file.write("RUN pip install flask praisonai==0.0.19 gunicorn markdown\n")
1717
file.write("EXPOSE 8080\n")
1818
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
1919

praisonai/inbuilt_tools/autogen_tools.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,24 @@ def tool_func(query: str) -> Any:
4242
return autogen_tool
4343

4444
# Load tools.py
45-
tools_module = importlib.import_module("tools")
45+
root_directory = os.getcwd()
46+
tools_py_path = os.path.join(root_directory, 'tools.py')
47+
tools_dir_path = Path(root_directory) / 'tools'
48+
49+
tools_module = None
50+
51+
if os.path.isfile(tools_py_path):
52+
print(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
53+
tools_module = importlib.import_module("tools")
54+
elif tools_dir_path.is_dir():
55+
print(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
56+
tools_module = importlib.import_module(f"tools.{tool_name}")
4657

4758
# Create autogen_TOOL_NAME_HERE function for each tool
48-
for name, obj in inspect.getmembers(tools_module):
49-
if inspect.isclass(obj):
50-
globals()[f"autogen_{name}"] = create_autogen_tool_function(name)
59+
if tools_module is not None:
60+
for name, obj in inspect.getmembers(tools_module):
61+
if inspect.isclass(obj):
62+
globals()[f"autogen_{name}"] = create_autogen_tool_function(name)
5163

5264
def autogen_CodeDocsSearchTool(assistant, user_proxy):
5365
def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):

praisonai/inbuilt_tools/base_tool.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)