PraisonAI 0.0.1__py3-none-any.whl → 0.0.23__py3-none-any.whl

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.

Potentially problematic release.


This version of PraisonAI might be problematic. Click here for more details.

praisonai/cli.py ADDED
@@ -0,0 +1,221 @@
1
+ # praisonai/cli.py
2
+
3
+ import sys
4
+ from .version import __version__
5
+ import yaml, os
6
+ from rich import print
7
+ from dotenv import load_dotenv
8
+ from crewai import Agent, Task, Crew
9
+ load_dotenv()
10
+ import autogen
11
+ import gradio as gr
12
+ import chainlit as cl
13
+ import asyncio
14
+ import uvicorn
15
+ from chainlit.cli import cli as chainlit_cli
16
+ from chainlit.server import app
17
+ import argparse
18
+ from .auto import AutoGenerator
19
+ from .agents_generator import AgentsGenerator
20
+ from .inbuilt_tools import *
21
+
22
+ class PraisonAI:
23
+ def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=False):
24
+ """
25
+ Initialize the PraisonAI object with default parameters.
26
+
27
+ Parameters:
28
+ agent_file (str): The default agent file to use. Defaults to "agents.yaml".
29
+ framework (str): The default framework to use. Defaults to "crewai".
30
+ auto (bool): A flag indicating whether to enable auto mode. Defaults to False.
31
+ init (bool): A flag indicating whether to enable initialization mode. Defaults to False.
32
+
33
+ Attributes:
34
+ config_list (list): A list of configuration dictionaries for the OpenAI API.
35
+ agent_file (str): The agent file to use.
36
+ framework (str): The framework to use.
37
+ auto (bool): A flag indicating whether to enable auto mode.
38
+ init (bool): A flag indicating whether to enable initialization mode.
39
+ """
40
+ self.config_list = [
41
+ {
42
+ 'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
43
+ 'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
44
+ }
45
+ ]
46
+ self.agent_file = agent_file
47
+ self.framework = framework
48
+ self.auto = auto
49
+ self.init = init
50
+
51
+ def main(self):
52
+ """
53
+ The main function of the PraisonAI object. It parses the command-line arguments,
54
+ initializes the necessary attributes, and then calls the appropriate methods based on the
55
+ provided arguments.
56
+
57
+ Args:
58
+ self (PraisonAI): An instance of the PraisonAI class.
59
+
60
+ Returns:
61
+ Any: Depending on the arguments provided, the function may return a result from the
62
+ AgentsGenerator, a deployment result from the CloudDeployer, or a message indicating
63
+ the successful creation of a file.
64
+ """
65
+ args = self.parse_args()
66
+ if args is None:
67
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
68
+ result = agents_generator.generate_crew_and_kickoff()
69
+ return result
70
+ if args.deploy:
71
+ from .deploy import CloudDeployer
72
+ deployer = CloudDeployer()
73
+ deployer.run_commands()
74
+ return
75
+ invocation_cmd = "praisonai"
76
+ version_string = f"PraisonAI version {__version__}"
77
+
78
+ self.framework = args.framework or self.framework
79
+
80
+ if args.agent_file:
81
+ if args.agent_file.startswith("tests.test"): # Argument used for testing purposes. eg: python -m unittest tests.test
82
+ print("test")
83
+ else:
84
+ self.agent_file = args.agent_file
85
+
86
+
87
+ if args.auto or args.init:
88
+ temp_topic = ' '.join(args.auto) if args.auto else ' '.join(args.init)
89
+ self.topic = temp_topic
90
+ elif self.auto or self.init: # Use the auto attribute if args.auto is not provided
91
+ self.topic = self.auto
92
+
93
+ if args.auto or self.auto:
94
+ self.agent_file = "test.yaml"
95
+ generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
96
+ self.agent_file = generator.generate()
97
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
98
+ result = agents_generator.generate_crew_and_kickoff()
99
+ return result
100
+ elif args.init or self.init:
101
+ self.agent_file = "agents.yaml"
102
+ generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
103
+ self.agent_file = generator.generate()
104
+ print("File {} created successfully".format(self.agent_file))
105
+ return "File {} created successfully".format(self.agent_file)
106
+
107
+ if args.ui:
108
+ if args.ui == "gradio":
109
+ self.create_gradio_interface()
110
+ elif args.ui == "chainlit":
111
+ self.create_chainlit_interface()
112
+ else:
113
+ self.create_chainlit_interface()
114
+ else:
115
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
116
+ result = agents_generator.generate_crew_and_kickoff()
117
+ return result
118
+
119
+ def parse_args(self):
120
+ """
121
+ Parse the command-line arguments for the PraisonAI CLI.
122
+
123
+ Args:
124
+ self (PraisonAI): An instance of the PraisonAI class.
125
+
126
+ Returns:
127
+ argparse.Namespace: An object containing the parsed command-line arguments.
128
+
129
+ Raises:
130
+ argparse.ArgumentError: If the arguments provided are invalid.
131
+
132
+ Example:
133
+ >>> args = praison_ai.parse_args()
134
+ >>> print(args.agent_file) # Output: 'agents.yaml'
135
+ """
136
+ parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
137
+ parser.add_argument("--framework", choices=["crewai", "autogen"], help="Specify the framework")
138
+ parser.add_argument("--ui", nargs='?', const='chainlit', default="chainlit", help="Specify the UI framework (gradio or chainlit). Default chainlit")
139
+ parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
140
+ parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
141
+ parser.add_argument("agent_file", nargs="?", help="Specify the agent file")
142
+ parser.add_argument("--deploy", action="store_true", help="Deploy the application") # New argument
143
+ args, unknown_args = parser.parse_known_args()
144
+
145
+ if unknown_args and unknown_args[0] == '-b' and unknown_args[1] == 'api:app':
146
+ args.agent_file = 'agents.yaml'
147
+ if args.agent_file == 'api:app' or args.agent_file == '/app/api:app':
148
+ args.agent_file = 'agents.yaml'
149
+
150
+ return args
151
+
152
+ def create_gradio_interface(self):
153
+ """
154
+ Create a Gradio interface for generating agents and performing tasks.
155
+
156
+ Args:
157
+ self (PraisonAI): An instance of the PraisonAI class.
158
+
159
+ Returns:
160
+ None: This method does not return any value. It launches the Gradio interface.
161
+
162
+ Raises:
163
+ None: This method does not raise any exceptions.
164
+
165
+ Example:
166
+ >>> praison_ai.create_gradio_interface()
167
+ """
168
+ def generate_crew_and_kickoff_interface(auto_args, framework):
169
+ """
170
+ Generate a crew and kick off tasks based on the provided auto arguments and framework.
171
+
172
+ Args:
173
+ auto_args (list): Topic.
174
+ framework (str): The framework to use for generating agents.
175
+
176
+ Returns:
177
+ str: A string representing the result of generating the crew and kicking off tasks.
178
+
179
+ Raises:
180
+ None: This method does not raise any exceptions.
181
+
182
+ Example:
183
+ >>> result = generate_crew_and_kickoff_interface("Create a movie about Cat in Mars", "crewai")
184
+ >>> print(result)
185
+ """
186
+ self.framework = framework
187
+ self.agent_file = "test.yaml"
188
+ generator = AutoGenerator(topic=auto_args , framework=self.framework)
189
+ self.agent_file = generator.generate()
190
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
191
+ result = agents_generator.generate_crew_and_kickoff()
192
+ return result
193
+
194
+ gr.Interface(
195
+ fn=generate_crew_and_kickoff_interface,
196
+ inputs=[gr.Textbox(lines=2, label="Auto Args"), gr.Dropdown(choices=["crewai", "autogen"], label="Framework")],
197
+ outputs="textbox",
198
+ title="Praison AI Studio",
199
+ description="Create Agents and perform tasks",
200
+ theme="default"
201
+ ).launch()
202
+
203
+ def create_chainlit_interface(self):
204
+ """
205
+ Create a Chainlit interface for generating agents and performing tasks.
206
+
207
+ This function sets up a Chainlit application that listens for messages.
208
+ When a message is received, it runs PraisonAI with the provided message as the topic.
209
+ The generated agents are then used to perform tasks.
210
+
211
+ Returns:
212
+ None: This function does not return any value. It starts the Chainlit application.
213
+ """
214
+ from chainlit.cli import chainlit_run # Import chainlit_run
215
+ os.environ["CHAINLIT_PORT"] = "8082"
216
+ chainlit_run(["praisonai/chainlit_ui.py"])
217
+
218
+
219
+ if __name__ == "__main__":
220
+ praison_ai = PraisonAI()
221
+ praison_ai.main()
praisonai/deploy.py ADDED
@@ -0,0 +1,138 @@
1
+ import subprocess
2
+ import os
3
+ from dotenv import load_dotenv
4
+
5
+ class CloudDeployer:
6
+ """
7
+ A class for deploying a cloud-based application.
8
+
9
+ Attributes:
10
+ None
11
+
12
+ Methods:
13
+ __init__(self):
14
+ Loads environment variables from .env file or system and sets them.
15
+
16
+ """
17
+ def __init__(self):
18
+ """
19
+ Loads environment variables from .env file or system and sets them.
20
+
21
+ Parameters:
22
+ self: An instance of the CloudDeployer class.
23
+
24
+ Returns:
25
+ None
26
+
27
+ Raises:
28
+ None
29
+
30
+ """
31
+ # Load environment variables from .env file or system
32
+ load_dotenv()
33
+ self.set_environment_variables()
34
+
35
+ def create_dockerfile(self):
36
+ """
37
+ Creates a Dockerfile for the application.
38
+
39
+ Parameters:
40
+ self: An instance of the CloudDeployer class.
41
+
42
+ Returns:
43
+ None
44
+
45
+ Raises:
46
+ None
47
+
48
+ This method creates a Dockerfile in the current directory with the specified content.
49
+ The Dockerfile is used to build a Docker image for the application.
50
+ The content of the Dockerfile includes instructions to use the Python 3.11-slim base image,
51
+ set the working directory to /app, copy the current directory contents into the container,
52
+ install the required Python packages (flask, praisonai, gunicorn, and markdown),
53
+ expose port 8080, and run the application using Gunicorn.
54
+ """
55
+ with open("Dockerfile", "w") as file:
56
+ file.write("FROM python:3.11-slim\n")
57
+ file.write("WORKDIR /app\n")
58
+ file.write("COPY . .\n")
59
+ file.write("RUN pip install flask praisonai==0.0.23 gunicorn markdown\n")
60
+ file.write("EXPOSE 8080\n")
61
+ file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
62
+
63
+ def create_api_file(self):
64
+ """
65
+ Creates an API file for the application.
66
+
67
+ Parameters:
68
+ self (CloudDeployer): An instance of the CloudDeployer class.
69
+
70
+ Returns:
71
+ None
72
+
73
+ This method creates an API file named "api.py" in the current directory. The file contains a basic Flask application that uses the PraisonAI library to run a simple agent and returns the output as an HTML page. The application listens on the root path ("/") and uses the Markdown library to format the output.
74
+ """
75
+ with open("api.py", "w") as file:
76
+ file.write("from flask import Flask\n")
77
+ file.write("from praisonai import PraisonAI\n")
78
+ file.write("import markdown\n\n")
79
+ file.write("app = Flask(__name__)\n\n")
80
+ file.write("def basic():\n")
81
+ file.write(" praison_ai = PraisonAI(agent_file=\"agents.yaml\")\n")
82
+ file.write(" return praison_ai.main()\n\n")
83
+ file.write("@app.route('/')\n")
84
+ file.write("def home():\n")
85
+ file.write(" output = basic()\n")
86
+ file.write(" html_output = markdown.markdown(output)\n")
87
+ file.write(" return f'<html><body>{html_output}</body></html>'\n\n")
88
+ file.write("if __name__ == \"__main__\":\n")
89
+ file.write(" app.run(debug=True)\n")
90
+
91
+ def set_environment_variables(self):
92
+ """Sets environment variables with fallback to .env values or defaults."""
93
+ os.environ["OPENAI_MODEL_NAME"] = os.getenv("OPENAI_MODEL_NAME", "gpt-4o")
94
+ os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "Enter your API key")
95
+ os.environ["OPENAI_API_BASE"] = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
96
+
97
+ def run_commands(self):
98
+ """
99
+ Sets environment variables with fallback to .env values or defaults.
100
+
101
+ Parameters:
102
+ None
103
+
104
+ Returns:
105
+ None
106
+
107
+ Raises:
108
+ None
109
+
110
+ This method sets environment variables for the application. It uses the `os.environ` dictionary to set the following environment variables:
111
+
112
+ - `OPENAI_MODEL_NAME`: The name of the OpenAI model to use. If not specified in the .env file, it defaults to "gpt-4o".
113
+ - `OPENAI_API_KEY`: The API key for accessing the OpenAI API. If not specified in the .env file, it defaults to "Enter your API key".
114
+ - `OPENAI_API_BASE`: The base URL for the OpenAI API. If not specified in the .env file, it defaults to "https://api.openai.com/v1".
115
+ """
116
+ self.create_api_file()
117
+ self.create_dockerfile()
118
+ """Runs a sequence of shell commands for deployment, continues on error."""
119
+ commands = [
120
+ "yes | gcloud auth configure-docker us-central1-docker.pkg.dev",
121
+ "gcloud artifacts repositories create praisonai-repository --repository-format=docker --location=us-central1",
122
+ "docker build --platform linux/amd64 -t gcr.io/$(gcloud config get-value project)/praisonai-app:latest .",
123
+ "docker tag gcr.io/$(gcloud config get-value project)/praisonai-app:latest us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest",
124
+ "docker push us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest",
125
+ "gcloud run deploy praisonai-service --image us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest --platform managed --region us-central1 --allow-unauthenticated --set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}"
126
+ ]
127
+
128
+ for cmd in commands:
129
+ try:
130
+ subprocess.run(cmd, shell=True, check=True)
131
+ except subprocess.CalledProcessError as e:
132
+ print(f"ERROR: Command '{e.cmd}' failed with exit status {e.returncode}")
133
+ print(f"Continuing with the next command...")
134
+
135
+ # Usage
136
+ if __name__ == "__main__":
137
+ deployer = CloudDeployer()
138
+ deployer.run_commands()
@@ -0,0 +1,2 @@
1
+ # from .base_tool import BaseTool, Tool, tool
2
+ from .autogen_tools import *
@@ -0,0 +1,203 @@
1
+ # praisonai/inbuilt_tools/autogen_tools.py
2
+
3
+ from crewai_tools import (
4
+ CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
5
+ FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
6
+ ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
7
+ YoutubeVideoSearchTool
8
+ )
9
+ from typing import Any
10
+ from autogen import register_function
11
+ import os
12
+ import importlib
13
+ from pathlib import Path
14
+ import os
15
+ import inspect
16
+ import sys
17
+
18
+ def create_autogen_tool_function(tool_name):
19
+ def autogen_tool(assistant, user_proxy):
20
+ def register_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
21
+ def tool_func(query: str) -> Any:
22
+ tool_instance = tool_class()
23
+ return tool_instance.run(query=query)
24
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
25
+
26
+ root_directory = os.getcwd()
27
+ tools_py_path = os.path.join(root_directory, 'tools.py')
28
+ tools_dir_path = Path(root_directory) / 'tools'
29
+
30
+ if os.path.isfile(tools_py_path):
31
+ print(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
32
+ tool_module = importlib.import_module("tools")
33
+ elif tools_dir_path.is_dir():
34
+ print(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
35
+ tool_module = importlib.import_module(f"tools.{tool_name}")
36
+ else:
37
+ raise ImportError("Neither tools.py nor tools directory found in the root directory.")
38
+
39
+ Tool = getattr(tool_module, tool_name)
40
+
41
+ register_tool(Tool, tool_name, f"Description for {tool_name}", assistant, user_proxy)
42
+
43
+ return autogen_tool
44
+
45
+ # Load tools.py
46
+ sys.path.insert(0, os.getcwd())
47
+ root_directory = os.getcwd()
48
+ tools_py_path = os.path.join(root_directory, 'tools.py')
49
+ tools_dir_path = Path(root_directory) / 'tools'
50
+
51
+ tools_module = None
52
+
53
+ if os.path.isfile(tools_py_path):
54
+ print(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
55
+ tools_module = importlib.import_module("tools")
56
+ elif tools_dir_path.is_dir():
57
+ print(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
58
+ tools_module = importlib.import_module(f"tools.{tool_name}")
59
+
60
+ # Create autogen_TOOL_NAME_HERE function for each tool
61
+ if tools_module is not None:
62
+ for name, obj in inspect.getmembers(tools_module):
63
+ if inspect.isclass(obj):
64
+ globals()[f"autogen_{name}"] = create_autogen_tool_function(name)
65
+
66
+ def autogen_CodeDocsSearchTool(assistant, user_proxy):
67
+ def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
68
+ def tool_func(docs_url: str, search_query: str) -> Any:
69
+ tool_instance = tool_class(docs_url=docs_url, search_query=search_query)
70
+ return tool_instance.run()
71
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
72
+ register_code_docs_search_tool(CodeDocsSearchTool, "code_docs_search_tool", "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.", assistant, user_proxy)
73
+
74
+ def autogen_CSVSearchTool(assistant, user_proxy):
75
+ def register_csv_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
76
+ def tool_func(csv: str, search_query: str) -> Any:
77
+ tool_instance = tool_class(csv=csv, search_query=search_query)
78
+ return tool_instance.run()
79
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
80
+ register_csv_search_tool(CSVSearchTool, "csv_search_tool", "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.", assistant, user_proxy)
81
+
82
+ def autogen_DirectorySearchTool(assistant, user_proxy):
83
+ def register_directory_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
84
+ def tool_func(directory: str, search_query: str) -> Any:
85
+ tool_instance = tool_class(directory=directory, search_query=search_query)
86
+ return tool_instance.run()
87
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
88
+ register_directory_search_tool(DirectorySearchTool, "directory_search_tool", "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.", assistant, user_proxy)
89
+
90
+ def autogen_DOCXSearchTool(assistant, user_proxy):
91
+ def register_docx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
92
+ def tool_func(docx: str, search_query: str) -> Any:
93
+ tool_instance = tool_class(docx=docx, search_query=search_query)
94
+ return tool_instance.run()
95
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
96
+ register_docx_search_tool(DOCXSearchTool, "docx_search_tool", "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.", assistant, user_proxy)
97
+
98
+ # DirectoryReadTool
99
+ def autogen_DirectoryReadTool(assistant, user_proxy):
100
+ def register_directory_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
101
+ def tool_func(directory: str) -> Any:
102
+ tool_instance = tool_class(directory=directory)
103
+ return tool_instance.run()
104
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
105
+ register_directory_read_tool(DirectoryReadTool, "directory_read_tool", "List files in directory(directory: 'string') - A tool that can be used to recursively list a directory's content.", assistant, user_proxy)
106
+
107
+ # FileReadTool
108
+ def autogen_FileReadTool(assistant, user_proxy):
109
+ def register_file_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
110
+ def tool_func(file_path: str) -> Any:
111
+ tool_instance = tool_class(file_path=file_path)
112
+ return tool_instance.run()
113
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
114
+ register_file_read_tool(FileReadTool, "file_read_tool", "Read a file's content(file_path: 'string') - A tool that can be used to read a file's content.", assistant, user_proxy)
115
+
116
+ # TXTSearchTool
117
+ def autogen_TXTSearchTool(assistant, user_proxy):
118
+ def register_txt_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
119
+ def tool_func(txt: str, search_query: str) -> Any:
120
+ tool_instance = tool_class(txt=txt, search_query=search_query)
121
+ return tool_instance.run()
122
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
123
+ register_txt_search_tool(TXTSearchTool, "txt_search_tool", "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.", assistant, user_proxy)
124
+
125
+ def autogen_JSONSearchTool(assistant, user_proxy):
126
+ def register_json_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
127
+ def tool_func(json_path: str, search_query: str) -> Any:
128
+ tool_instance = tool_class(json_path=json_path, search_query=search_query)
129
+ return tool_instance.run()
130
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
131
+ register_json_search_tool(JSONSearchTool, "json_search_tool", "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.", assistant, user_proxy)
132
+
133
+ def autogen_MDXSearchTool(assistant, user_proxy):
134
+ def register_mdx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
135
+ def tool_func(mdx: str, search_query: str) -> Any:
136
+ tool_instance = tool_class(mdx=mdx, search_query=search_query)
137
+ return tool_instance.run()
138
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
139
+ register_mdx_search_tool(MDXSearchTool, "mdx_search_tool", "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.", assistant, user_proxy)
140
+
141
+ def autogen_PDFSearchTool(assistant, user_proxy):
142
+ def register_pdf_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
143
+ def tool_func(pdf: str, search_query: str) -> Any:
144
+ tool_instance = tool_class(pdf=pdf, search_query=search_query)
145
+ return tool_instance.run()
146
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
147
+ register_pdf_search_tool(PDFSearchTool, "pdf_search_tool", "Search a PDF's content(search_query: 'string', pdf: 'string') - A tool that can be used to semantic search a query from a PDF's content.", assistant, user_proxy)
148
+
149
+ def autogen_RagTool(assistant, user_proxy):
150
+ def register_rag_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
151
+ def tool_func(query: str, data: Any) -> Any:
152
+ tool_instance = tool_class(query=query, data=data)
153
+ return tool_instance.run()
154
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
155
+ register_rag_tool(RagTool, "rag_tool", "Knowledge base(query: 'string', data: Any) - A knowledge base that can be used to answer questions.", assistant, user_proxy)
156
+
157
+ def autogen_ScrapeElementFromWebsiteTool(assistant, user_proxy):
158
+ def register_scrape_element_from_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
159
+ def tool_func(website_url: str, element_query: str) -> Any:
160
+ tool_instance = tool_class(website_url=website_url, element_query=element_query)
161
+ return tool_instance.run()
162
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
163
+ register_scrape_element_from_website_tool(ScrapeElementFromWebsiteTool, "scrape_element_from_website_tool", "Scrape an element from a website(element_query: 'string', website_url: 'string') - A tool that can be used to scrape an element from a website.", assistant, user_proxy)
164
+
165
+ def autogen_ScrapeWebsiteTool(assistant, user_proxy):
166
+ def register_scrape_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
167
+ def tool_func(website_url: str) -> Any:
168
+ tool_instance = tool_class(website_url=website_url)
169
+ return tool_instance.run()
170
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
171
+ register_scrape_website_tool(ScrapeWebsiteTool, "scrape_website_tool", "Read website content(website_url: 'string') - A tool that can be used to read content from a specified website.", assistant, user_proxy)
172
+
173
+ def autogen_WebsiteSearchTool(assistant, user_proxy):
174
+ def register_website_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
175
+ def tool_func(website: str, search_query: str) -> Any:
176
+ tool_instance = tool_class(website=website, search_query=search_query)
177
+ return tool_instance.run()
178
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
179
+ register_website_search_tool(WebsiteSearchTool, "website_search_tool", "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.", assistant, user_proxy)
180
+
181
+ def autogen_XMLSearchTool(assistant, user_proxy):
182
+ def register_xml_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
183
+ def tool_func(xml: str, search_query: str) -> Any:
184
+ tool_instance = tool_class(xml=xml, search_query=search_query)
185
+ return tool_instance.run()
186
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
187
+ register_xml_search_tool(XMLSearchTool, "xml_search_tool", "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.", assistant, user_proxy)
188
+
189
+ def autogen_YoutubeChannelSearchTool(assistant, user_proxy):
190
+ def register_youtube_channel_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
191
+ def tool_func(youtube_channel_handle: str, search_query: str) -> Any:
192
+ tool_instance = tool_class(youtube_channel_handle=youtube_channel_handle, search_query=search_query)
193
+ return tool_instance.run()
194
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
195
+ register_youtube_channel_search_tool(YoutubeChannelSearchTool, "youtube_channel_search_tool", "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.", assistant, user_proxy)
196
+
197
+ def autogen_YoutubeVideoSearchTool(assistant, user_proxy):
198
+ def register_youtube_video_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
199
+ def tool_func(youtube_video_url: str, search_query: str) -> Any:
200
+ tool_instance = tool_class(youtube_video_url=youtube_video_url, search_query=search_query)
201
+ return tool_instance.run()
202
+ register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
203
+ register_youtube_video_search_tool(YoutubeVideoSearchTool, "youtube_video_search_tool", "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.", assistant, user_proxy)
@@ -1,4 +1,5 @@
1
- import yaml, os
1
+ import yaml
2
+ import os
2
3
  from rich import print
3
4
  from dotenv import load_dotenv
4
5
  from crewai import Agent, Task, Crew
@@ -12,6 +13,16 @@ config_list = [
12
13
  ]
13
14
 
14
15
  def generate_crew_and_kickoff(agent_file):
16
+ """
17
+ This function generates a crew of agents and kicks off tasks based on the configuration provided in a YAML file.
18
+
19
+ Parameters:
20
+ agent_file (str): The path to the YAML file containing the configuration for the agents and tasks.
21
+
22
+ Returns:
23
+ str: The result of the last task executed by the crew.
24
+ """
25
+
15
26
  with open(agent_file, 'r') as f:
16
27
  config = yaml.safe_load(f)
17
28
 
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.