PraisonAI 0.0.18__tar.gz → 0.0.19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {praisonai-0.0.18 → praisonai-0.0.19}/PKG-INFO +2 -1
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/agents_generator.py +57 -96
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/cli.py +6 -51
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/deploy.py +1 -1
- praisonai-0.0.19/praisonai/inbuilt_tools/__init__.py +2 -0
- {praisonai-0.0.18/praisonai/tools → praisonai-0.0.19/praisonai/inbuilt_tools}/autogen_tools.py +54 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/pyproject.toml +2 -1
- praisonai-0.0.18/praisonai/tools/__init__.py +0 -2
- praisonai-0.0.18/praisonai/tools/base_tool.py +0 -146
- praisonai-0.0.18/praisonai/tools/find_params.py +0 -116
- praisonai-0.0.18/praisonai/tools/tools-autogen-decorator-example-1.py +0 -38
- praisonai-0.0.18/praisonai/tools/tools-autogen-example-1.py +0 -44
- praisonai-0.0.18/praisonai/tools/tools-autogen-example-2.py +0 -35
- praisonai-0.0.18/praisonai/tools/tools-autogen-example.py +0 -23
- praisonai-0.0.18/praisonai/tools/tools-crewai-example.py +0 -134
- {praisonai-0.0.18 → praisonai-0.0.19}/README.md +0 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/__init__.py +0 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/__main__.py +0 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/auto.py +0 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/test.py +0 -0
- {praisonai-0.0.18 → praisonai-0.0.19}/praisonai/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: praisonAI
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.19
|
|
4
4
|
Summary: 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.
|
|
5
5
|
Author: Mervin Praison
|
|
6
6
|
Requires-Python: >=3.10,<3.13
|
|
@@ -13,6 +13,7 @@ Requires-Dist: crewai (>=0.22.5)
|
|
|
13
13
|
Requires-Dist: crewai-tools (>=0.1.1,<0.2.0)
|
|
14
14
|
Requires-Dist: gradio (>=4.20.0)
|
|
15
15
|
Requires-Dist: markdown (>=3.5)
|
|
16
|
+
Requires-Dist: praisonai-tools (>=0.0.4)
|
|
16
17
|
Requires-Dist: pyautogen (>=0.2.19)
|
|
17
18
|
Requires-Dist: rich (>=13.7)
|
|
18
19
|
Project-URL: Homepage, https://github.com/mervinpraison/praisonAI
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# agents_generator.py
|
|
1
|
+
# praisonai/agents_generator.py
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
4
|
from .version import __version__
|
|
@@ -11,14 +11,49 @@ import autogen
|
|
|
11
11
|
import gradio as gr
|
|
12
12
|
import argparse
|
|
13
13
|
from .auto import AutoGenerator
|
|
14
|
-
from crewai_tools import
|
|
15
|
-
|
|
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
|
+
)
|
|
20
|
+
from .inbuilt_tools import *
|
|
21
|
+
import inspect
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
import importlib
|
|
24
|
+
import importlib.util
|
|
25
|
+
from praisonai_tools import BaseTool
|
|
16
26
|
|
|
17
27
|
class AgentsGenerator:
|
|
18
28
|
def __init__(self, agent_file, framework, config_list):
|
|
19
29
|
self.agent_file = agent_file
|
|
20
30
|
self.framework = framework
|
|
21
31
|
self.config_list = config_list
|
|
32
|
+
|
|
33
|
+
def is_function_or_decorated(self, obj):
|
|
34
|
+
return inspect.isfunction(obj) or hasattr(obj, '__call__')
|
|
35
|
+
|
|
36
|
+
def load_tools_from_module(self, module_path):
|
|
37
|
+
spec = importlib.util.spec_from_file_location("tools_module", module_path)
|
|
38
|
+
module = importlib.util.module_from_spec(spec)
|
|
39
|
+
spec.loader.exec_module(module)
|
|
40
|
+
return {name: obj for name, obj in inspect.getmembers(module, self.is_function_or_decorated)}
|
|
41
|
+
|
|
42
|
+
def load_tools_from_module_class(self, module_path):
|
|
43
|
+
spec = importlib.util.spec_from_file_location("tools_module", module_path)
|
|
44
|
+
module = importlib.util.module_from_spec(spec)
|
|
45
|
+
spec.loader.exec_module(module)
|
|
46
|
+
return {name: obj() for name, obj in inspect.getmembers(module, lambda x: inspect.isclass(x) and issubclass(x, BaseTool) and x is not BaseTool)}
|
|
47
|
+
|
|
48
|
+
def load_tools_from_package(self, package_path):
|
|
49
|
+
tools_dict = {}
|
|
50
|
+
for module_file in os.listdir(package_path):
|
|
51
|
+
if module_file.endswith('.py') and not module_file.startswith('__'):
|
|
52
|
+
module_name = f"{package_path.name}.{module_file[:-3]}" # Remove .py for import
|
|
53
|
+
module = importlib.import_module(module_name)
|
|
54
|
+
for name, obj in inspect.getmembers(module, self.is_function_or_decorated):
|
|
55
|
+
tools_dict[name] = obj
|
|
56
|
+
return tools_dict
|
|
22
57
|
|
|
23
58
|
def generate_crew_and_kickoff(self):
|
|
24
59
|
if self.agent_file == '/app/api:app' or self.agent_file == 'api:app':
|
|
@@ -51,9 +86,19 @@ class AgentsGenerator:
|
|
|
51
86
|
'WebsiteSearchTool': WebsiteSearchTool(),
|
|
52
87
|
'XMLSearchTool': XMLSearchTool(),
|
|
53
88
|
'YoutubeChannelSearchTool': YoutubeChannelSearchTool(),
|
|
54
|
-
'YoutubeVideoSearchTool': YoutubeVideoSearchTool()
|
|
89
|
+
'YoutubeVideoSearchTool': YoutubeVideoSearchTool(),
|
|
55
90
|
}
|
|
56
|
-
|
|
91
|
+
root_directory = os.getcwd()
|
|
92
|
+
tools_py_path = os.path.join(root_directory, 'tools.py')
|
|
93
|
+
tools_dir_path = Path(root_directory) / 'tools'
|
|
94
|
+
|
|
95
|
+
if os.path.isfile(tools_py_path):
|
|
96
|
+
tools_dict.update(self.load_tools_from_module_class(tools_py_path))
|
|
97
|
+
# print("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
|
|
98
|
+
elif tools_dir_path.is_dir():
|
|
99
|
+
tools_dict.update(self.load_tools_from_module_class(tools_dir_path))
|
|
100
|
+
# print("tools folder exists in the root directory")
|
|
101
|
+
|
|
57
102
|
framework = self.framework or config.get('framework')
|
|
58
103
|
|
|
59
104
|
agents = {}
|
|
@@ -86,7 +131,12 @@ class AgentsGenerator:
|
|
|
86
131
|
)
|
|
87
132
|
for tool in details.get('tools', []):
|
|
88
133
|
if tool in tools_dict:
|
|
89
|
-
|
|
134
|
+
try:
|
|
135
|
+
tool_class = globals()[f'autogen_{type(tools_dict[tool]).__name__}']
|
|
136
|
+
print(f"Found {tool_class.__name__} for {tool}")
|
|
137
|
+
except KeyError:
|
|
138
|
+
print(f"Warning: autogen_{type(tools_dict[tool]).__name__} function not found. Skipping this tool.")
|
|
139
|
+
continue
|
|
90
140
|
tool_class(agents[role], user_proxy)
|
|
91
141
|
|
|
92
142
|
# Preparing tasks for initiate_chats
|
|
@@ -121,7 +171,6 @@ class AgentsGenerator:
|
|
|
121
171
|
|
|
122
172
|
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
|
|
123
173
|
tasks.append(task)
|
|
124
|
-
# print(agents)
|
|
125
174
|
crew = Crew(
|
|
126
175
|
agents=list(agents.values()),
|
|
127
176
|
tasks=tasks,
|
|
@@ -130,92 +179,4 @@ class AgentsGenerator:
|
|
|
130
179
|
|
|
131
180
|
response = crew.kickoff()
|
|
132
181
|
result = f"### Task Output ###\n{response}"
|
|
133
|
-
return result
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
# # AutoGen Tools example below
|
|
137
|
-
# from typing import Any, Optional
|
|
138
|
-
# import os
|
|
139
|
-
# from autogen import ConversableAgent
|
|
140
|
-
# from autogen_tools import autogen_ScrapeWebsiteTool
|
|
141
|
-
|
|
142
|
-
# assistant = ConversableAgent(
|
|
143
|
-
# name="Assistant",
|
|
144
|
-
# system_message="You are a helpful AI assistant. "
|
|
145
|
-
# "You can help with website scraping. "
|
|
146
|
-
# "Return 'TERMINATE' when the task is done.",
|
|
147
|
-
# llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
|
148
|
-
# )
|
|
149
|
-
|
|
150
|
-
# user_proxy = ConversableAgent(
|
|
151
|
-
# name="User",
|
|
152
|
-
# llm_config=False,
|
|
153
|
-
# is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
|
154
|
-
# human_input_mode="NEVER",
|
|
155
|
-
# )
|
|
156
|
-
|
|
157
|
-
# autogen_ScrapeWebsiteTool(assistant, user_proxy)
|
|
158
|
-
|
|
159
|
-
# chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
|
160
|
-
|
|
161
|
-
# # CrewAI Tools example below
|
|
162
|
-
# import os
|
|
163
|
-
# from crewai import Agent, Task, Crew
|
|
164
|
-
# # Importing crewAI tools
|
|
165
|
-
# from crewai_tools import (
|
|
166
|
-
# DirectoryReadTool,
|
|
167
|
-
# FileReadTool,
|
|
168
|
-
# SerperDevTool,
|
|
169
|
-
# WebsiteSearchTool
|
|
170
|
-
# )
|
|
171
|
-
|
|
172
|
-
# # Set up API keys
|
|
173
|
-
# os.environ["SERPER_API_KEY"] = "Your Key" # serper.dev API key
|
|
174
|
-
# os.environ["OPENAI_API_KEY"] = "Your Key"
|
|
175
|
-
|
|
176
|
-
# # Instantiate tools
|
|
177
|
-
# docs_tool = DirectoryReadTool(directory='./blog-posts')
|
|
178
|
-
# file_tool = FileReadTool()
|
|
179
|
-
# search_tool = SerperDevTool()
|
|
180
|
-
# web_rag_tool = WebsiteSearchTool()
|
|
181
|
-
|
|
182
|
-
# # Create agents
|
|
183
|
-
# researcher = Agent(
|
|
184
|
-
# role='Market Research Analyst',
|
|
185
|
-
# goal='Provide up-to-date market analysis of the AI industry',
|
|
186
|
-
# backstory='An expert analyst with a keen eye for market trends.',
|
|
187
|
-
# tools=[search_tool, web_rag_tool],
|
|
188
|
-
# verbose=True
|
|
189
|
-
# )
|
|
190
|
-
|
|
191
|
-
# writer = Agent(
|
|
192
|
-
# role='Content Writer',
|
|
193
|
-
# goal='Craft engaging blog posts about the AI industry',
|
|
194
|
-
# backstory='A skilled writer with a passion for technology.',
|
|
195
|
-
# tools=[docs_tool, file_tool],
|
|
196
|
-
# verbose=True
|
|
197
|
-
# )
|
|
198
|
-
|
|
199
|
-
# # Define tasks
|
|
200
|
-
# research = Task(
|
|
201
|
-
# description='Research the latest trends in the AI industry and provide a summary.',
|
|
202
|
-
# expected_output='A summary of the top 3 trending developments in the AI industry with a unique perspective on their significance.',
|
|
203
|
-
# agent=researcher
|
|
204
|
-
# )
|
|
205
|
-
|
|
206
|
-
# write = Task(
|
|
207
|
-
# description='Write an engaging blog post about the AI industry, based on the research analyst’s summary. Draw inspiration from the latest blog posts in the directory.',
|
|
208
|
-
# expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
|
|
209
|
-
# agent=writer,
|
|
210
|
-
# output_file='blog-posts/new_post.md' # The final blog post will be saved here
|
|
211
|
-
# )
|
|
212
|
-
|
|
213
|
-
# # Assemble a crew
|
|
214
|
-
# crew = Crew(
|
|
215
|
-
# agents=[researcher, writer],
|
|
216
|
-
# tasks=[research, write],
|
|
217
|
-
# verbose=2
|
|
218
|
-
# )
|
|
219
|
-
|
|
220
|
-
# # Execute tasks
|
|
221
|
-
# crew.kickoff()
|
|
182
|
+
return result
|
|
@@ -12,8 +12,7 @@ import gradio as gr
|
|
|
12
12
|
import argparse
|
|
13
13
|
from .auto import AutoGenerator
|
|
14
14
|
from .agents_generator import AgentsGenerator
|
|
15
|
-
from
|
|
16
|
-
from .tools import *
|
|
15
|
+
from .inbuilt_tools import *
|
|
17
16
|
|
|
18
17
|
class PraisonAI:
|
|
19
18
|
def __init__(self, agent_file="agents.yaml", framework="crewai", auto=False, init=False):
|
|
@@ -41,21 +40,15 @@ class PraisonAI:
|
|
|
41
40
|
return
|
|
42
41
|
invocation_cmd = "praisonai"
|
|
43
42
|
version_string = f"PraisonAI version {__version__}"
|
|
44
|
-
|
|
45
43
|
if args.framework:
|
|
46
44
|
self.framework = args.framework
|
|
47
|
-
|
|
48
45
|
ui = args.ui
|
|
49
|
-
|
|
50
46
|
if args.agent_file:
|
|
51
|
-
if args.agent_file
|
|
52
|
-
|
|
47
|
+
if args.agent_file.startswith("tests.test"): # Argument used for testing purposes
|
|
48
|
+
print("test")
|
|
53
49
|
else:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
else:
|
|
57
|
-
full_path = os.path.abspath(self.agent_file)
|
|
58
|
-
self.agent_file = full_path
|
|
50
|
+
self.agent_file = args.agent_file
|
|
51
|
+
|
|
59
52
|
|
|
60
53
|
if args.auto or args.init:
|
|
61
54
|
temp_topic = ' '.join(args.auto) if args.auto else ' '.join(args.init)
|
|
@@ -86,7 +79,7 @@ class PraisonAI:
|
|
|
86
79
|
|
|
87
80
|
def parse_args(self):
|
|
88
81
|
parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
|
|
89
|
-
parser.add_argument("--framework", choices=["crewai", "autogen"],
|
|
82
|
+
parser.add_argument("--framework", choices=["crewai", "autogen"], help="Specify the framework")
|
|
90
83
|
parser.add_argument("--ui", action="store_true", help="Enable UI mode")
|
|
91
84
|
parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
|
92
85
|
parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
|
@@ -124,41 +117,3 @@ class PraisonAI:
|
|
|
124
117
|
if __name__ == "__main__":
|
|
125
118
|
praison_ai = PraisonAI()
|
|
126
119
|
praison_ai.main()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
## agents.yaml
|
|
131
|
-
# framework: autogen
|
|
132
|
-
# topic: create movie script about cat in mars
|
|
133
|
-
# roles:
|
|
134
|
-
# concept_developer:
|
|
135
|
-
# backstory: Experienced in creating captivating and original story concepts.
|
|
136
|
-
# goal: Generate a unique concept for a movie script about a cat in Mars
|
|
137
|
-
# role: Concept Developer
|
|
138
|
-
# tools:
|
|
139
|
-
# - search_tool
|
|
140
|
-
# tasks:
|
|
141
|
-
# concept_generation:
|
|
142
|
-
# description: Develop a unique and engaging concept for a movie script about
|
|
143
|
-
# a cat in Mars.
|
|
144
|
-
# expected_output: A detailed concept document for the movie script.
|
|
145
|
-
# scriptwriter:
|
|
146
|
-
# backstory: Expert in dialogue and script structure, translating concepts into
|
|
147
|
-
# scripts.
|
|
148
|
-
# goal: Write a script based on the movie concept
|
|
149
|
-
# role: Scriptwriter
|
|
150
|
-
# tasks:
|
|
151
|
-
# scriptwriting_task:
|
|
152
|
-
# description: Turn the movie concept into a script, including dialogue and
|
|
153
|
-
# scenes.
|
|
154
|
-
# expected_output: A production-ready script for the movie about a cat in Mars.
|
|
155
|
-
# director:
|
|
156
|
-
# backstory: Experienced in visualizing scripts and creating compelling storyboards.
|
|
157
|
-
# goal: Create a storyboard and visualize the script
|
|
158
|
-
# role: Director
|
|
159
|
-
# tasks:
|
|
160
|
-
# storyboard_creation:
|
|
161
|
-
# description: Create a storyboard for the movie script about a cat in Mars.
|
|
162
|
-
# expected_output: A detailed storyboard for the movie about a cat in Mars.
|
|
163
|
-
# dependencies: []
|
|
164
|
-
|
|
@@ -13,7 +13,7 @@ class CloudDeployer:
|
|
|
13
13
|
file.write("FROM python:3.11-slim\n")
|
|
14
14
|
file.write("WORKDIR /app\n")
|
|
15
15
|
file.write("COPY . .\n")
|
|
16
|
-
file.write("RUN pip install flask praisonai==0.0.
|
|
16
|
+
file.write("RUN pip install flask praisonai==0.0.19 gunicorn markdown\n")
|
|
17
17
|
file.write("EXPOSE 8080\n")
|
|
18
18
|
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
|
19
19
|
|
{praisonai-0.0.18/praisonai/tools → praisonai-0.0.19/praisonai/inbuilt_tools}/autogen_tools.py
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# praisonai/inbuilt_tools/autogen_tools.py
|
|
2
|
+
|
|
1
3
|
from crewai_tools import (
|
|
2
4
|
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
|
|
3
5
|
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
|
|
@@ -6,6 +8,58 @@ from crewai_tools import (
|
|
|
6
8
|
)
|
|
7
9
|
from typing import Any
|
|
8
10
|
from autogen import register_function
|
|
11
|
+
import os
|
|
12
|
+
import importlib
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
import os
|
|
15
|
+
import inspect
|
|
16
|
+
|
|
17
|
+
def create_autogen_tool_function(tool_name):
|
|
18
|
+
def autogen_tool(assistant, user_proxy):
|
|
19
|
+
def register_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
20
|
+
def tool_func(query: str) -> Any:
|
|
21
|
+
tool_instance = tool_class()
|
|
22
|
+
return tool_instance.run(query=query)
|
|
23
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
24
|
+
|
|
25
|
+
root_directory = os.getcwd()
|
|
26
|
+
tools_py_path = os.path.join(root_directory, 'tools.py')
|
|
27
|
+
tools_dir_path = Path(root_directory) / 'tools'
|
|
28
|
+
|
|
29
|
+
if os.path.isfile(tools_py_path):
|
|
30
|
+
print(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
|
|
31
|
+
tool_module = importlib.import_module("tools")
|
|
32
|
+
elif tools_dir_path.is_dir():
|
|
33
|
+
print(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
|
|
34
|
+
tool_module = importlib.import_module(f"tools.{tool_name}")
|
|
35
|
+
else:
|
|
36
|
+
raise ImportError("Neither tools.py nor tools directory found in the root directory.")
|
|
37
|
+
|
|
38
|
+
Tool = getattr(tool_module, tool_name)
|
|
39
|
+
|
|
40
|
+
register_tool(Tool, tool_name, f"Description for {tool_name}", assistant, user_proxy)
|
|
41
|
+
|
|
42
|
+
return autogen_tool
|
|
43
|
+
|
|
44
|
+
# Load tools.py
|
|
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}")
|
|
57
|
+
|
|
58
|
+
# Create autogen_TOOL_NAME_HERE function for each tool
|
|
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)
|
|
9
63
|
|
|
10
64
|
def autogen_CodeDocsSearchTool(assistant, user_proxy):
|
|
11
65
|
def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "praisonAI"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.19"
|
|
4
4
|
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."
|
|
5
5
|
authors = ["Mervin Praison"]
|
|
6
6
|
license = ""
|
|
@@ -22,6 +22,7 @@ gradio = ">=4.20.0"
|
|
|
22
22
|
Flask = ">=3.0.0"
|
|
23
23
|
markdown = ">=3.5"
|
|
24
24
|
crewai-tools = "^0.1.1"
|
|
25
|
+
praisonai-tools = ">=0.0.4"
|
|
25
26
|
|
|
26
27
|
[tool.poetry.dev-dependencies]
|
|
27
28
|
pytest = "^8.0.0"
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Any, Callable, Optional, Type
|
|
3
|
-
|
|
4
|
-
from langchain_core.tools import StructuredTool
|
|
5
|
-
from pydantic import BaseModel, ConfigDict, Field, validator
|
|
6
|
-
from pydantic.v1 import BaseModel as V1BaseModel
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class BaseTool(BaseModel, ABC):
|
|
10
|
-
class _ArgsSchemaPlaceholder(V1BaseModel):
|
|
11
|
-
pass
|
|
12
|
-
|
|
13
|
-
model_config = ConfigDict()
|
|
14
|
-
|
|
15
|
-
name: str
|
|
16
|
-
"""The unique name of the tool that clearly communicates its purpose."""
|
|
17
|
-
description: str
|
|
18
|
-
"""Used to tell the model how/when/why to use the tool."""
|
|
19
|
-
args_schema: Type[V1BaseModel] = Field(default_factory=_ArgsSchemaPlaceholder)
|
|
20
|
-
"""The schema for the arguments that the tool accepts."""
|
|
21
|
-
description_updated: bool = False
|
|
22
|
-
"""Flag to check if the description has been updated."""
|
|
23
|
-
cache_function: Optional[Callable] = lambda _args, _result: True
|
|
24
|
-
"""Function that will be used to determine if the tool should be cached, should return a boolean. If None, the tool will be cached."""
|
|
25
|
-
|
|
26
|
-
@validator("args_schema", always=True, pre=True)
|
|
27
|
-
def _default_args_schema(cls, v: Type[V1BaseModel]) -> Type[V1BaseModel]:
|
|
28
|
-
if not isinstance(v, cls._ArgsSchemaPlaceholder):
|
|
29
|
-
return v
|
|
30
|
-
|
|
31
|
-
return type(
|
|
32
|
-
f"{cls.__name__}Schema",
|
|
33
|
-
(V1BaseModel,),
|
|
34
|
-
{
|
|
35
|
-
"__annotations__": {
|
|
36
|
-
k: v for k, v in cls._run.__annotations__.items() if k != "return"
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
def model_post_init(self, __context: Any) -> None:
|
|
42
|
-
self._generate_description()
|
|
43
|
-
|
|
44
|
-
super().model_post_init(__context)
|
|
45
|
-
|
|
46
|
-
def run(
|
|
47
|
-
self,
|
|
48
|
-
*args: Any,
|
|
49
|
-
**kwargs: Any,
|
|
50
|
-
) -> Any:
|
|
51
|
-
print(f"Using Tool: {self.name}")
|
|
52
|
-
return self._run(*args, **kwargs)
|
|
53
|
-
|
|
54
|
-
@abstractmethod
|
|
55
|
-
def _run(
|
|
56
|
-
self,
|
|
57
|
-
*args: Any,
|
|
58
|
-
**kwargs: Any,
|
|
59
|
-
) -> Any:
|
|
60
|
-
"""Here goes the actual implementation of the tool."""
|
|
61
|
-
|
|
62
|
-
def to_langchain(self) -> StructuredTool:
|
|
63
|
-
self._set_args_schema()
|
|
64
|
-
return StructuredTool(
|
|
65
|
-
name=self.name,
|
|
66
|
-
description=self.description,
|
|
67
|
-
args_schema=self.args_schema,
|
|
68
|
-
func=self._run,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
def _set_args_schema(self):
|
|
72
|
-
if self.args_schema is None:
|
|
73
|
-
class_name = f"{self.__class__.__name__}Schema"
|
|
74
|
-
self.args_schema = type(
|
|
75
|
-
class_name,
|
|
76
|
-
(V1BaseModel,),
|
|
77
|
-
{
|
|
78
|
-
"__annotations__": {
|
|
79
|
-
k: v
|
|
80
|
-
for k, v in self._run.__annotations__.items()
|
|
81
|
-
if k != "return"
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
def _generate_description(self):
|
|
87
|
-
args = []
|
|
88
|
-
for arg, attribute in self.args_schema.schema()["properties"].items():
|
|
89
|
-
if "type" in attribute:
|
|
90
|
-
args.append(f"{arg}: '{attribute['type']}'")
|
|
91
|
-
|
|
92
|
-
description = self.description.replace("\n", " ")
|
|
93
|
-
self.description = f"{self.name}({', '.join(args)}) - {description}"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class Tool(BaseTool):
|
|
97
|
-
func: Callable
|
|
98
|
-
"""The function that will be executed when the tool is called."""
|
|
99
|
-
|
|
100
|
-
def _run(self, *args: Any, **kwargs: Any) -> Any:
|
|
101
|
-
return self.func(*args, **kwargs)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def to_langchain(
|
|
105
|
-
tools: list[BaseTool | StructuredTool],
|
|
106
|
-
) -> list[StructuredTool]:
|
|
107
|
-
return [t.to_langchain() if isinstance(t, BaseTool) else t for t in tools]
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def tool(*args):
|
|
111
|
-
"""
|
|
112
|
-
Decorator to create a tool from a function.
|
|
113
|
-
"""
|
|
114
|
-
|
|
115
|
-
def _make_with_name(tool_name: str) -> Callable:
|
|
116
|
-
def _make_tool(f: Callable) -> BaseTool:
|
|
117
|
-
if f.__doc__ is None:
|
|
118
|
-
raise ValueError("Function must have a docstring")
|
|
119
|
-
if f.__annotations__ is None:
|
|
120
|
-
raise ValueError("Function must have type annotations")
|
|
121
|
-
|
|
122
|
-
class_name = "".join(tool_name.split()).title()
|
|
123
|
-
args_schema = type(
|
|
124
|
-
class_name,
|
|
125
|
-
(V1BaseModel,),
|
|
126
|
-
{
|
|
127
|
-
"__annotations__": {
|
|
128
|
-
k: v for k, v in f.__annotations__.items() if k != "return"
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
return Tool(
|
|
134
|
-
name=tool_name,
|
|
135
|
-
description=f.__doc__,
|
|
136
|
-
func=f,
|
|
137
|
-
args_schema=args_schema,
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
return _make_tool
|
|
141
|
-
|
|
142
|
-
if len(args) == 1 and callable(args[0]):
|
|
143
|
-
return _make_with_name(args[0].__name__)(args[0])
|
|
144
|
-
if len(args) == 1 and isinstance(args[0], str):
|
|
145
|
-
return _make_with_name(args[0])
|
|
146
|
-
raise ValueError("Invalid arguments")
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
from crewai_tools import (
|
|
2
|
-
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
|
|
3
|
-
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
|
|
4
|
-
ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
|
|
5
|
-
YoutubeVideoSearchTool
|
|
6
|
-
)
|
|
7
|
-
import inspect
|
|
8
|
-
|
|
9
|
-
# Assuming the tool classes are imported correctly as in the original request
|
|
10
|
-
|
|
11
|
-
tools_classes = {
|
|
12
|
-
'CodeDocsSearchTool': CodeDocsSearchTool,
|
|
13
|
-
'CSVSearchTool': CSVSearchTool,
|
|
14
|
-
'DirectorySearchTool': DirectorySearchTool,
|
|
15
|
-
'DOCXSearchTool': DOCXSearchTool,
|
|
16
|
-
'DirectoryReadTool': DirectoryReadTool,
|
|
17
|
-
'FileReadTool': FileReadTool,
|
|
18
|
-
'TXTSearchTool': TXTSearchTool,
|
|
19
|
-
'JSONSearchTool': JSONSearchTool,
|
|
20
|
-
'MDXSearchTool': MDXSearchTool,
|
|
21
|
-
'PDFSearchTool': PDFSearchTool,
|
|
22
|
-
'RagTool': RagTool,
|
|
23
|
-
'ScrapeElementFromWebsiteTool': ScrapeElementFromWebsiteTool,
|
|
24
|
-
'ScrapeWebsiteTool': ScrapeWebsiteTool,
|
|
25
|
-
'WebsiteSearchTool': WebsiteSearchTool,
|
|
26
|
-
'XMLSearchTool': XMLSearchTool,
|
|
27
|
-
'YoutubeChannelSearchTool': YoutubeChannelSearchTool,
|
|
28
|
-
'YoutubeVideoSearchTool': YoutubeVideoSearchTool,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for tool_name, tool_class in tools_classes.items():
|
|
32
|
-
# Inspect the constructor (__init__) to get its parameters, excluding 'self'
|
|
33
|
-
constructor_params = inspect.signature(tool_class.__init__).parameters
|
|
34
|
-
param_names = [p for p in constructor_params if p != 'self']
|
|
35
|
-
|
|
36
|
-
# Attempt to instantiate the tool with dummy or default values for parameters
|
|
37
|
-
try:
|
|
38
|
-
# Creating a dummy parameters dict with None or empty values based on parameter name
|
|
39
|
-
dummy_params = {param: None if param != 'website_url' else 'http://example.com' for param in param_names}
|
|
40
|
-
instance = tool_class(**dummy_params)
|
|
41
|
-
tool_description = getattr(instance, "description", "No description attribute")
|
|
42
|
-
except Exception as e:
|
|
43
|
-
tool_description = f"Error instantiating tool for description extraction: {str(e)}"
|
|
44
|
-
|
|
45
|
-
# Printing tool class name, its constructor parameters, and description
|
|
46
|
-
print(f"Tool Class: {tool_name}")
|
|
47
|
-
print(f"Constructor Parameters: {', '.join(param_names)}")
|
|
48
|
-
print(f"Description: {tool_description}\n")
|
|
49
|
-
|
|
50
|
-
# Tool Class: CodeDocsSearchTool
|
|
51
|
-
# Constructor Parameters: docs_url, kwargs
|
|
52
|
-
# Description: Search a Code Docs content(search_query: 'string', docs_url: 'string') - A tool that can be used to semantic search a query from a Code Docs content.
|
|
53
|
-
|
|
54
|
-
# Tool Class: CSVSearchTool
|
|
55
|
-
# Constructor Parameters: csv, kwargs
|
|
56
|
-
# Description: Search a CSV's content(search_query: 'string', csv: 'string') - A tool that can be used to semantic search a query from a CSV's content.
|
|
57
|
-
|
|
58
|
-
# Tool Class: DirectorySearchTool
|
|
59
|
-
# Constructor Parameters: directory, kwargs
|
|
60
|
-
# Description: Search a directory's content(search_query: 'string', directory: 'string') - A tool that can be used to semantic search a query from a directory's content.
|
|
61
|
-
|
|
62
|
-
# Tool Class: DOCXSearchTool
|
|
63
|
-
# Constructor Parameters: docx, kwargs
|
|
64
|
-
# Description: Search a DOCX's content(search_query: 'string', docx: 'string') - A tool that can be used to semantic search a query from a DOCX's content.
|
|
65
|
-
|
|
66
|
-
# Tool Class: DirectoryReadTool
|
|
67
|
-
# Constructor Parameters: directory, kwargs
|
|
68
|
-
# Description: List files in directory(directory: 'string') - A tool that can be used to recursively list a directory's content.
|
|
69
|
-
|
|
70
|
-
# Tool Class: FileReadTool
|
|
71
|
-
# Constructor Parameters: file_path, kwargs
|
|
72
|
-
# Description: Read a file's content(file_path: 'string') - A tool that can be used to read a file's content.
|
|
73
|
-
|
|
74
|
-
# Tool Class: TXTSearchTool
|
|
75
|
-
# Constructor Parameters: txt, kwargs
|
|
76
|
-
# Description: Search a txt's content(search_query: 'string', txt: 'string') - A tool that can be used to semantic search a query from a txt's content.
|
|
77
|
-
|
|
78
|
-
# Tool Class: JSONSearchTool
|
|
79
|
-
# Constructor Parameters: json_path, kwargs
|
|
80
|
-
# Description: Search a JSON's content(search_query: 'string', json_path: 'string') - A tool that can be used to semantic search a query from a JSON's content.
|
|
81
|
-
|
|
82
|
-
# Tool Class: MDXSearchTool
|
|
83
|
-
# Constructor Parameters: mdx, kwargs
|
|
84
|
-
# Description: Search a MDX's content(search_query: 'string', mdx: 'string') - A tool that can be used to semantic search a query from a MDX's content.
|
|
85
|
-
|
|
86
|
-
# Tool Class: PDFSearchTool
|
|
87
|
-
# Constructor Parameters: pdf, kwargs
|
|
88
|
-
# Description: Search a PDF's content(query: 'string', pdf: 'string') - A tool that can be used to semantic search a query from a PDF's content.
|
|
89
|
-
|
|
90
|
-
# Tool Class: RagTool
|
|
91
|
-
# Constructor Parameters: data
|
|
92
|
-
# Description: Knowledge base(query: 'string') - A knowledge base that can be used to answer questions.
|
|
93
|
-
|
|
94
|
-
# Tool Class: ScrapeElementFromWebsiteTool
|
|
95
|
-
# Constructor Parameters: website_url, cookies, css_element, kwargs
|
|
96
|
-
# Description: Read a website content() - A tool that can be used to read http://example.com's content.
|
|
97
|
-
|
|
98
|
-
# Tool Class: ScrapeWebsiteTool
|
|
99
|
-
# Constructor Parameters: website_url, cookies, kwargs
|
|
100
|
-
# Description: Read website content() - A tool that can be used to read http://example.com's content.
|
|
101
|
-
|
|
102
|
-
# Tool Class: WebsiteSearchTool
|
|
103
|
-
# Constructor Parameters: website, kwargs
|
|
104
|
-
# Description: Search in a specific website(search_query: 'string', website: 'string') - A tool that can be used to semantic search a query from a specific URL content.
|
|
105
|
-
|
|
106
|
-
# Tool Class: XMLSearchTool
|
|
107
|
-
# Constructor Parameters: xml, kwargs
|
|
108
|
-
# Description: Search a XML's content(search_query: 'string', xml: 'string') - A tool that can be used to semantic search a query from a XML's content.
|
|
109
|
-
|
|
110
|
-
# Tool Class: YoutubeChannelSearchTool
|
|
111
|
-
# Constructor Parameters: youtube_channel_handle, kwargs
|
|
112
|
-
# Description: Search a Youtube Channels content(search_query: 'string', youtube_channel_handle: 'string') - A tool that can be used to semantic search a query from a Youtube Channels content.
|
|
113
|
-
|
|
114
|
-
# Tool Class: YoutubeVideoSearchTool
|
|
115
|
-
# Constructor Parameters: youtube_video_url, kwargs
|
|
116
|
-
# Description: Search a Youtube Video content(search_query: 'string', youtube_video_url: 'string') - A tool that can be used to semantic search a query from a Youtube Video content.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from typing import Any, Optional
|
|
2
|
-
import os
|
|
3
|
-
from autogen import ConversableAgent
|
|
4
|
-
from scrape_website_tool.scrape_website_tool import ScrapeWebsiteTool
|
|
5
|
-
|
|
6
|
-
assistant = ConversableAgent(
|
|
7
|
-
name="Assistant",
|
|
8
|
-
system_message="You are a helpful AI assistant. "
|
|
9
|
-
"You can help with website scraping. "
|
|
10
|
-
"Return 'TERMINATE' when the task is done.",
|
|
11
|
-
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
user_proxy = ConversableAgent(
|
|
15
|
-
name="User",
|
|
16
|
-
llm_config=False,
|
|
17
|
-
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
|
18
|
-
human_input_mode="NEVER",
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
from autogen import register_function
|
|
22
|
-
from typing import Any
|
|
23
|
-
|
|
24
|
-
def register_tool(tool_class, tool_name, tool_description):
|
|
25
|
-
def tool_func(website_url: str) -> Any:
|
|
26
|
-
tool_instance = tool_class(website_url=website_url)
|
|
27
|
-
return tool_instance.run()
|
|
28
|
-
|
|
29
|
-
register_function(
|
|
30
|
-
tool_func,
|
|
31
|
-
caller=assistant, # The assistant agent can suggest calls to the tool.
|
|
32
|
-
executor=user_proxy, # The user proxy agent can execute the tool calls.
|
|
33
|
-
name=tool_name, # By default, the function name is used as the tool name.
|
|
34
|
-
description=tool_description, # A description of the tool.
|
|
35
|
-
)
|
|
36
|
-
register_tool(ScrapeWebsiteTool, "scrape_website_tool", "A tool for scraping specific websites")
|
|
37
|
-
|
|
38
|
-
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from typing import Annotated, Literal
|
|
2
|
-
import os
|
|
3
|
-
from autogen import ConversableAgent
|
|
4
|
-
|
|
5
|
-
Operator = Literal["+", "-", "*", "/"]
|
|
6
|
-
|
|
7
|
-
def calculator(a: int, b: int, operator: Annotated[Operator, "operator"]) -> int:
|
|
8
|
-
if operator == "+":
|
|
9
|
-
return a + b
|
|
10
|
-
elif operator == "-":
|
|
11
|
-
return a - b
|
|
12
|
-
elif operator == "*":
|
|
13
|
-
return a * b
|
|
14
|
-
elif operator == "/":
|
|
15
|
-
return int(a / b)
|
|
16
|
-
else:
|
|
17
|
-
raise ValueError("Invalid operator")
|
|
18
|
-
|
|
19
|
-
assistant = ConversableAgent(
|
|
20
|
-
name="Assistant",
|
|
21
|
-
system_message="You are a helpful AI assistant. "
|
|
22
|
-
"You can help with simple calculations. "
|
|
23
|
-
"Return 'TERMINATE' when the task is done.",
|
|
24
|
-
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
user_proxy = ConversableAgent(
|
|
28
|
-
name="User",
|
|
29
|
-
llm_config=False,
|
|
30
|
-
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
|
31
|
-
human_input_mode="NEVER",
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
from autogen import register_function
|
|
35
|
-
# Register the calculator function to the agent and user proxy to add a calculator tool.
|
|
36
|
-
register_function(
|
|
37
|
-
calculator,
|
|
38
|
-
caller=assistant, # The assistant agent can suggest calls to the calculator.
|
|
39
|
-
executor=user_proxy, # The user proxy agent can execute the calculator calls.
|
|
40
|
-
name="calculator", # By default, the function name is used as the tool name.
|
|
41
|
-
description="A simple calculator", # A description of the tool.
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
chat_result = user_proxy.initiate_chat(assistant, message="What is (44232 + 13312 / (232 - 32)) * 5?")
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from typing import Any, Optional
|
|
2
|
-
import os
|
|
3
|
-
from autogen import ConversableAgent
|
|
4
|
-
from scrape_website_tool.scrape_website_tool import ScrapeWebsiteTool
|
|
5
|
-
|
|
6
|
-
def scrape_website_tool(website_url: str) -> Any:
|
|
7
|
-
scrape_tool = ScrapeWebsiteTool(website_url=website_url)
|
|
8
|
-
return scrape_tool.run()
|
|
9
|
-
|
|
10
|
-
assistant = ConversableAgent(
|
|
11
|
-
name="Assistant",
|
|
12
|
-
system_message="You are a helpful AI assistant. "
|
|
13
|
-
"You can help with website scraping. "
|
|
14
|
-
"Return 'TERMINATE' when the task is done.",
|
|
15
|
-
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
user_proxy = ConversableAgent(
|
|
19
|
-
name="User",
|
|
20
|
-
llm_config=False,
|
|
21
|
-
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
|
22
|
-
human_input_mode="NEVER",
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
from autogen import register_function
|
|
26
|
-
# Register the ScrapeWebsiteTool function to the agent and user proxy to add a website scraping tool.
|
|
27
|
-
register_function(
|
|
28
|
-
scrape_website_tool,
|
|
29
|
-
caller=assistant, # The assistant agent can suggest calls to the scrape website tool.
|
|
30
|
-
executor=user_proxy, # The user proxy agent can execute the scrape website tool calls.
|
|
31
|
-
name="scrape_website_tool", # By default, the function name is used as the tool name.
|
|
32
|
-
description="A tool for scraping specific websites", # A description of the tool.
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Python website.")
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from typing import Any, Optional
|
|
2
|
-
import os
|
|
3
|
-
from autogen import ConversableAgent
|
|
4
|
-
from autogen_tools import autogen_ScrapeWebsiteTool
|
|
5
|
-
|
|
6
|
-
assistant = ConversableAgent(
|
|
7
|
-
name="Assistant",
|
|
8
|
-
system_message="You are a helpful AI assistant. "
|
|
9
|
-
"You can help with website scraping. "
|
|
10
|
-
"Return 'TERMINATE' when the task is done.",
|
|
11
|
-
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
user_proxy = ConversableAgent(
|
|
15
|
-
name="User",
|
|
16
|
-
llm_config=False,
|
|
17
|
-
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
|
18
|
-
human_input_mode="NEVER",
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
autogen_ScrapeWebsiteTool(assistant, user_proxy)
|
|
22
|
-
|
|
23
|
-
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import os
|
|
3
|
-
from crewai import Agent, Task, Crew
|
|
4
|
-
from crewai_tools import (
|
|
5
|
-
DirectoryReadTool,
|
|
6
|
-
FileReadTool,
|
|
7
|
-
SerperDevTool,
|
|
8
|
-
WebsiteSearchTool
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
os.environ["SERPER_API_KEY"] = "Your Key"
|
|
12
|
-
os.environ["OPENAI_API_KEY"] = "Your Key"
|
|
13
|
-
|
|
14
|
-
docs_tool = DirectoryReadTool(directory='./blog-posts')
|
|
15
|
-
file_tool = FileReadTool()
|
|
16
|
-
search_tool = SerperDevTool()
|
|
17
|
-
web_rag_tool = WebsiteSearchTool()
|
|
18
|
-
|
|
19
|
-
researcher = Agent(
|
|
20
|
-
role='Market Research Analyst',
|
|
21
|
-
goal='Provide up-to-date market analysis of the AI industry',
|
|
22
|
-
backstory='An expert analyst with a keen eye for market trends.',
|
|
23
|
-
tools=[search_tool, web_rag_tool],
|
|
24
|
-
verbose=True
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
writer = Agent(
|
|
28
|
-
role='Content Writer',
|
|
29
|
-
goal='Craft engaging blog posts about the AI industry',
|
|
30
|
-
backstory='A skilled writer with a passion for technology.',
|
|
31
|
-
tools=[docs_tool, file_tool],
|
|
32
|
-
verbose=True
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
research = Task(
|
|
36
|
-
description='Research the latest trends in the AI industry and provide a summary.',
|
|
37
|
-
expected_output='A summary of the top 3 trending developments in the AI industry with a unique perspective on their significance.',
|
|
38
|
-
agent=researcher
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
write = Task(
|
|
42
|
-
description='Write an engaging blog post about the AI industry, based on the research analyst\'s summary. Draw inspiration from the latest blog posts in the directory.',
|
|
43
|
-
expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
|
|
44
|
-
agent=writer,
|
|
45
|
-
output_file='blog-posts/new_post.md'
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
crew = Crew(
|
|
49
|
-
agents=[researcher, writer],
|
|
50
|
-
tasks=[research, write],
|
|
51
|
-
verbose=2
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
crew.kickoff()
|
|
55
|
-
|
|
56
|
-
from crewai_tools import DirectoryReadTool
|
|
57
|
-
|
|
58
|
-
tool = DirectoryReadTool()
|
|
59
|
-
|
|
60
|
-
toos = DirectoryReadTool(directory='./directory')
|
|
61
|
-
|
|
62
|
-
from crewai_tools import BaseTool
|
|
63
|
-
|
|
64
|
-
class MyCustomTool(BaseTool):
|
|
65
|
-
name: str = "Name of my tool"
|
|
66
|
-
description: str = "Clear description for what this tool is useful for, you agent will need this information to use it."
|
|
67
|
-
|
|
68
|
-
def _run(self, argument: str) -> str:
|
|
69
|
-
return "Result from custom tool"
|
|
70
|
-
|
|
71
|
-
from crewai_tools import tool
|
|
72
|
-
|
|
73
|
-
@tool("Name of my tool")
|
|
74
|
-
def my_tool(question: str) -> str:
|
|
75
|
-
return "Result from my tool"
|
|
76
|
-
|
|
77
|
-
import json
|
|
78
|
-
import requests
|
|
79
|
-
from crewai import Agent
|
|
80
|
-
from crewai.tools import tool
|
|
81
|
-
from unstructured.partition.html import partition_html
|
|
82
|
-
|
|
83
|
-
@tool("Integration with a given API")
|
|
84
|
-
def integration_tool(argument: str) -> str:
|
|
85
|
-
return "Results from integration tool"
|
|
86
|
-
|
|
87
|
-
agent = Agent(
|
|
88
|
-
role='Research Analyst',
|
|
89
|
-
goal='Provide up-to-date market analysis',
|
|
90
|
-
backstory='An expert analyst with a keen eye for market trends.',
|
|
91
|
-
tools=[integration_tool]
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
from crewai import Agent
|
|
95
|
-
from langchain.agents import Tool
|
|
96
|
-
from langchain.utilities import GoogleSerperAPIWrapper
|
|
97
|
-
|
|
98
|
-
os.environ["SERPER_API_KEY"] = "Your Key"
|
|
99
|
-
|
|
100
|
-
search = GoogleSerperAPIWrapper()
|
|
101
|
-
|
|
102
|
-
serper_tool = Tool(
|
|
103
|
-
name="Intermediate Answer",
|
|
104
|
-
func=search.run,
|
|
105
|
-
description="Useful for search-based queries",
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
agent = Agent(
|
|
109
|
-
role='Research Analyst',
|
|
110
|
-
goal='Provide up-to-date market analysis',
|
|
111
|
-
backstory='An expert analyst with a keen eye for market trends.',
|
|
112
|
-
tools=[serper_tool]
|
|
113
|
-
)
|
|
114
|
-
# Tool Description
|
|
115
|
-
# CodeDocsSearchTool A RAG tool optimized for searching through code documentation and related technical documents.
|
|
116
|
-
# CSVSearchTool A RAG tool designed for searching within CSV files, tailored to handle structured data.
|
|
117
|
-
# DirectorySearchTool A RAG tool for searching within directories, useful for navigating through file systems.
|
|
118
|
-
# DOCXSearchTool A RAG tool aimed at searching within DOCX documents, ideal for processing Word files.
|
|
119
|
-
# DirectoryReadTool Facilitates reading and processing of directory structures and their contents.
|
|
120
|
-
# FileReadTool Enables reading and extracting data from files, supporting various file formats.
|
|
121
|
-
# GithubSearchTool A RAG tool for searching within GitHub repositories, useful for code and documentation search.
|
|
122
|
-
# SeperDevTool A specialized tool for development purposes, with specific functionalities under development.
|
|
123
|
-
# TXTSearchTool A RAG tool focused on searching within text (.txt) files, suitable for unstructured data.
|
|
124
|
-
# JSONSearchTool A RAG tool designed for searching within JSON files, catering to structured data handling.
|
|
125
|
-
# MDXSearchTool A RAG tool tailored for searching within Markdown (MDX) files, useful for documentation.
|
|
126
|
-
# PDFSearchTool A RAG tool aimed at searching within PDF documents, ideal for processing scanned documents.
|
|
127
|
-
# PGSearchTool A RAG tool optimized for searching within PostgreSQL databases, suitable for database queries.
|
|
128
|
-
# RagTool A general-purpose RAG tool capable of handling various data sources and types.
|
|
129
|
-
# ScrapeElementFromWebsiteTool Enables scraping specific elements from websites, useful for targeted data extraction.
|
|
130
|
-
# ScrapeWebsiteTool Facilitates scraping entire websites, ideal for comprehensive data collection.
|
|
131
|
-
# WebsiteSearchTool A RAG tool for searching website content, optimized for web data extraction.
|
|
132
|
-
# XMLSearchTool A RAG tool designed for searching within XML files, suitable for structured data formats.
|
|
133
|
-
# YoutubeChannelSearchTool A RAG tool for searching within YouTube channels, useful for video content analysis.
|
|
134
|
-
# YoutubeVideoSearchTool A RAG tool aimed at searching within YouTube videos, ideal for video data extraction.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|