PraisonAI 0.0.17__tar.gz → 0.0.18__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.17 → praisonai-0.0.18}/PKG-INFO +2 -2
- praisonai-0.0.18/praisonai/agents_generator.py +221 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/praisonai/auto.py +14 -8
- praisonai-0.0.18/praisonai/cli.py +164 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/praisonai/deploy.py +1 -1
- praisonai-0.0.18/praisonai/tools/__init__.py +2 -0
- praisonai-0.0.18/praisonai/tools/autogen_tools.py +147 -0
- praisonai-0.0.18/praisonai/tools/base_tool.py +146 -0
- praisonai-0.0.18/praisonai/tools/find_params.py +116 -0
- praisonai-0.0.18/praisonai/tools/tools-autogen-decorator-example-1.py +38 -0
- praisonai-0.0.18/praisonai/tools/tools-autogen-example-1.py +44 -0
- praisonai-0.0.18/praisonai/tools/tools-autogen-example-2.py +35 -0
- praisonai-0.0.18/praisonai/tools/tools-autogen-example.py +23 -0
- praisonai-0.0.18/praisonai/tools/tools-crewai-example.py +134 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/pyproject.toml +4 -6
- praisonai-0.0.17/praisonai/cli.py +0 -202
- {praisonai-0.0.17 → praisonai-0.0.18}/README.md +0 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/praisonai/__init__.py +0 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/praisonai/__main__.py +0 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/praisonai/test.py +0 -0
- {praisonai-0.0.17 → praisonai-0.0.18}/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.18
|
|
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
|
|
@@ -8,9 +8,9 @@ Classifier: Programming Language :: Python :: 3
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3.10
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
-
Provides-Extra: tools
|
|
12
11
|
Requires-Dist: Flask (>=3.0.0)
|
|
13
12
|
Requires-Dist: crewai (>=0.22.5)
|
|
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
16
|
Requires-Dist: pyautogen (>=0.2.19)
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# agents_generator.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 argparse
|
|
13
|
+
from .auto import AutoGenerator
|
|
14
|
+
from crewai_tools import *
|
|
15
|
+
from .tools import *
|
|
16
|
+
|
|
17
|
+
class AgentsGenerator:
|
|
18
|
+
def __init__(self, agent_file, framework, config_list):
|
|
19
|
+
self.agent_file = agent_file
|
|
20
|
+
self.framework = framework
|
|
21
|
+
self.config_list = config_list
|
|
22
|
+
|
|
23
|
+
def generate_crew_and_kickoff(self):
|
|
24
|
+
if self.agent_file == '/app/api:app' or self.agent_file == 'api:app':
|
|
25
|
+
self.agent_file = 'agents.yaml'
|
|
26
|
+
try:
|
|
27
|
+
with open(self.agent_file, 'r') as f:
|
|
28
|
+
config = yaml.safe_load(f)
|
|
29
|
+
except FileNotFoundError:
|
|
30
|
+
print(f"File not found: {self.agent_file}")
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
topic = config['topic']
|
|
34
|
+
tools_dict = {
|
|
35
|
+
'CodeDocsSearchTool': CodeDocsSearchTool(),
|
|
36
|
+
'CSVSearchTool': CSVSearchTool(),
|
|
37
|
+
'DirectorySearchTool': DirectorySearchTool(),
|
|
38
|
+
'DOCXSearchTool': DOCXSearchTool(),
|
|
39
|
+
'DirectoryReadTool': DirectoryReadTool(),
|
|
40
|
+
'FileReadTool': FileReadTool(),
|
|
41
|
+
# 'GithubSearchTool': GithubSearchTool(),
|
|
42
|
+
# 'SeperDevTool': SeperDevTool(),
|
|
43
|
+
'TXTSearchTool': TXTSearchTool(),
|
|
44
|
+
'JSONSearchTool': JSONSearchTool(),
|
|
45
|
+
'MDXSearchTool': MDXSearchTool(),
|
|
46
|
+
'PDFSearchTool': PDFSearchTool(),
|
|
47
|
+
# 'PGSearchTool': PGSearchTool(),
|
|
48
|
+
'RagTool': RagTool(),
|
|
49
|
+
'ScrapeElementFromWebsiteTool': ScrapeElementFromWebsiteTool(),
|
|
50
|
+
'ScrapeWebsiteTool': ScrapeWebsiteTool(),
|
|
51
|
+
'WebsiteSearchTool': WebsiteSearchTool(),
|
|
52
|
+
'XMLSearchTool': XMLSearchTool(),
|
|
53
|
+
'YoutubeChannelSearchTool': YoutubeChannelSearchTool(),
|
|
54
|
+
'YoutubeVideoSearchTool': YoutubeVideoSearchTool()
|
|
55
|
+
}
|
|
56
|
+
# config['tools'] = [tools_dict[tool] for tool in config.get('tools', []) if tool in tools_dict]
|
|
57
|
+
framework = self.framework or config.get('framework')
|
|
58
|
+
|
|
59
|
+
agents = {}
|
|
60
|
+
tasks = []
|
|
61
|
+
if framework == "autogen":
|
|
62
|
+
# Load the LLM configuration dynamically
|
|
63
|
+
# print(self.config_list)
|
|
64
|
+
llm_config = {"config_list": self.config_list}
|
|
65
|
+
|
|
66
|
+
# Assuming the user proxy agent is set up as per your requirements
|
|
67
|
+
user_proxy = autogen.UserProxyAgent(
|
|
68
|
+
name="User",
|
|
69
|
+
human_input_mode="NEVER",
|
|
70
|
+
is_termination_msg=lambda x: (x.get("content") or "").rstrip().rstrip(".").lower().endswith("terminate") or "TERMINATE" in (x.get("content") or ""),
|
|
71
|
+
code_execution_config={
|
|
72
|
+
"work_dir": "coding",
|
|
73
|
+
"use_docker": False,
|
|
74
|
+
},
|
|
75
|
+
# additional setup for the user proxy agent
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for role, details in config['roles'].items():
|
|
79
|
+
agent_name = details['role'].format(topic=topic).replace("{topic}", topic)
|
|
80
|
+
agent_goal = details['goal'].format(topic=topic)
|
|
81
|
+
# Creating an AssistantAgent for each role dynamically
|
|
82
|
+
agents[role] = autogen.AssistantAgent(
|
|
83
|
+
name=agent_name,
|
|
84
|
+
llm_config=llm_config,
|
|
85
|
+
system_message=details['backstory'].format(topic=topic)+". Must Reply \"TERMINATE\" in the end when everything is done.",
|
|
86
|
+
)
|
|
87
|
+
for tool in details.get('tools', []):
|
|
88
|
+
if tool in tools_dict:
|
|
89
|
+
tool_class = globals()[f'autogen_{type(tools_dict[tool]).__name__}']
|
|
90
|
+
tool_class(agents[role], user_proxy)
|
|
91
|
+
|
|
92
|
+
# Preparing tasks for initiate_chats
|
|
93
|
+
for task_name, task_details in details.get('tasks', {}).items():
|
|
94
|
+
description_filled = task_details['description'].format(topic=topic)
|
|
95
|
+
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
|
96
|
+
|
|
97
|
+
chat_task = {
|
|
98
|
+
"recipient": agents[role],
|
|
99
|
+
"message": description_filled,
|
|
100
|
+
"summary_method": "last_msg",
|
|
101
|
+
# Additional fields like carryover can be added based on dependencies
|
|
102
|
+
}
|
|
103
|
+
tasks.append(chat_task)
|
|
104
|
+
|
|
105
|
+
response = user_proxy.initiate_chats(tasks)
|
|
106
|
+
result = "### Output ###\n"+response[-1].summary if hasattr(response[-1], 'summary') else ""
|
|
107
|
+
else:
|
|
108
|
+
for role, details in config['roles'].items():
|
|
109
|
+
role_filled = details['role'].format(topic=topic)
|
|
110
|
+
goal_filled = details['goal'].format(topic=topic)
|
|
111
|
+
backstory_filled = details['backstory'].format(topic=topic)
|
|
112
|
+
|
|
113
|
+
# Adding tools to the agent if exists
|
|
114
|
+
agent_tools = [tools_dict[tool] for tool in details.get('tools', []) if tool in tools_dict]
|
|
115
|
+
agent = Agent(role=role_filled, goal=goal_filled, backstory=backstory_filled, tools=agent_tools, allow_delegation=False)
|
|
116
|
+
agents[role] = agent
|
|
117
|
+
|
|
118
|
+
for task_name, task_details in details.get('tasks', {}).items():
|
|
119
|
+
description_filled = task_details['description'].format(topic=topic)
|
|
120
|
+
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
|
121
|
+
|
|
122
|
+
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
|
|
123
|
+
tasks.append(task)
|
|
124
|
+
# print(agents)
|
|
125
|
+
crew = Crew(
|
|
126
|
+
agents=list(agents.values()),
|
|
127
|
+
tasks=tasks,
|
|
128
|
+
verbose=2
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
response = crew.kickoff()
|
|
132
|
+
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()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from openai import OpenAI
|
|
2
2
|
from pydantic import BaseModel
|
|
3
|
-
from typing import Dict
|
|
3
|
+
from typing import Dict, List
|
|
4
4
|
import instructor
|
|
5
5
|
import os
|
|
6
6
|
import json
|
|
@@ -17,12 +17,13 @@ class RoleDetails(BaseModel):
|
|
|
17
17
|
goal: str
|
|
18
18
|
backstory: str
|
|
19
19
|
tasks: Dict[str, TaskDetails]
|
|
20
|
+
tools: List[str]
|
|
20
21
|
|
|
21
22
|
class TeamStructure(BaseModel):
|
|
22
23
|
roles: Dict[str, RoleDetails]
|
|
23
24
|
|
|
24
25
|
class AutoGenerator:
|
|
25
|
-
def __init__(self, topic="Movie Story writing about AI",
|
|
26
|
+
def __init__(self, topic="Movie Story writing about AI", agent_file="test.yaml", framework="crewai"):
|
|
26
27
|
self.config_list = [
|
|
27
28
|
{
|
|
28
29
|
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4-turbo-preview"),
|
|
@@ -30,7 +31,7 @@ class AutoGenerator:
|
|
|
30
31
|
}
|
|
31
32
|
]
|
|
32
33
|
self.topic = topic
|
|
33
|
-
self.
|
|
34
|
+
self.agent_file = agent_file
|
|
34
35
|
self.framework = framework
|
|
35
36
|
self.client = instructor.patch(
|
|
36
37
|
OpenAI(
|
|
@@ -52,7 +53,7 @@ class AutoGenerator:
|
|
|
52
53
|
)
|
|
53
54
|
json_data = json.loads(response.model_dump_json())
|
|
54
55
|
self.convert_and_save(json_data)
|
|
55
|
-
full_path = os.path.abspath(self.
|
|
56
|
+
full_path = os.path.abspath(self.agent_file)
|
|
56
57
|
return full_path
|
|
57
58
|
|
|
58
59
|
def convert_and_save(self, json_data):
|
|
@@ -61,7 +62,7 @@ class AutoGenerator:
|
|
|
61
62
|
Args:
|
|
62
63
|
json_data (dict): The JSON data representing the team structure.
|
|
63
64
|
topic (str, optional): The topic to be inserted into the YAML. Defaults to "Artificial Intelligence".
|
|
64
|
-
|
|
65
|
+
agent_file (str, optional): The name of the YAML file to save. Defaults to "test.yaml".
|
|
65
66
|
"""
|
|
66
67
|
|
|
67
68
|
yaml_data = {
|
|
@@ -76,7 +77,9 @@ class AutoGenerator:
|
|
|
76
77
|
"backstory": "" + role_details['backstory'],
|
|
77
78
|
"goal": role_details['goal'],
|
|
78
79
|
"role": role_details['role'],
|
|
79
|
-
"tasks": {}
|
|
80
|
+
"tasks": {},
|
|
81
|
+
# "tools": role_details.get('tools', []),
|
|
82
|
+
"tools": ['']
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
for task_id, task_details in role_details['tasks'].items():
|
|
@@ -86,7 +89,7 @@ class AutoGenerator:
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
# Save to YAML file, maintaining the order
|
|
89
|
-
with open(self.
|
|
92
|
+
with open(self.agent_file, 'w') as f:
|
|
90
93
|
yaml.dump(yaml_data, f, allow_unicode=True, sort_keys=False)
|
|
91
94
|
|
|
92
95
|
def get_user_content(self):
|
|
@@ -96,6 +99,8 @@ The team will work in sequence. First role will pass the output to the next role
|
|
|
96
99
|
The last role will generate the final output.
|
|
97
100
|
Think step by step.
|
|
98
101
|
With maximum 3 roles, each with 1 task. Include role goals, backstories, task descriptions, and expected outputs.
|
|
102
|
+
List of Available Tools: CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool, FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool, ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool, YoutubeVideoSearchTool.
|
|
103
|
+
Only use Available Tools. Do Not use any other tools.
|
|
99
104
|
Example Below:
|
|
100
105
|
Use below example to understand the structure of the output.
|
|
101
106
|
The final role you create should satisfy the provided task: """ + self.topic + """.
|
|
@@ -105,9 +110,10 @@ The final role you create should satisfy the provided task: """ + self.topic + "
|
|
|
105
110
|
"role": "Narrative Designer",
|
|
106
111
|
"goal": "Create AI storylines",
|
|
107
112
|
"backstory": "Skilled in narrative development for AI, with a focus on story resonance.",
|
|
113
|
+
"tools": ["ScrapeWebsiteTool"],
|
|
108
114
|
"tasks": {
|
|
109
115
|
"story_concept_development": {
|
|
110
|
-
"description": "Craft a unique AI story concept with depth and engagement.",
|
|
116
|
+
"description": "Craft a unique AI story concept with depth and engagement using concept from this page the content https://www.asthebirdfliesblog.com/posts/how-to-write-book-story-development .",
|
|
111
117
|
"expected_output": "Document with narrative arcs, character bios, and settings."
|
|
112
118
|
}
|
|
113
119
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 argparse
|
|
13
|
+
from .auto import AutoGenerator
|
|
14
|
+
from .agents_generator import AgentsGenerator
|
|
15
|
+
from crewai_tools import *
|
|
16
|
+
from .tools import *
|
|
17
|
+
|
|
18
|
+
class PraisonAI:
|
|
19
|
+
def __init__(self, agent_file="agents.yaml", framework="crewai", auto=False, init=False):
|
|
20
|
+
self.config_list = [
|
|
21
|
+
{
|
|
22
|
+
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4-turbo-preview"),
|
|
23
|
+
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
self.agent_file = agent_file
|
|
27
|
+
self.framework = framework
|
|
28
|
+
self.auto = auto
|
|
29
|
+
self.init = init
|
|
30
|
+
|
|
31
|
+
def main(self):
|
|
32
|
+
args = self.parse_args()
|
|
33
|
+
if args is None:
|
|
34
|
+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
|
35
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
36
|
+
return result
|
|
37
|
+
if args.deploy:
|
|
38
|
+
from .deploy import CloudDeployer
|
|
39
|
+
deployer = CloudDeployer()
|
|
40
|
+
deployer.run_commands()
|
|
41
|
+
return
|
|
42
|
+
invocation_cmd = "praisonai"
|
|
43
|
+
version_string = f"PraisonAI version {__version__}"
|
|
44
|
+
|
|
45
|
+
if args.framework:
|
|
46
|
+
self.framework = args.framework
|
|
47
|
+
|
|
48
|
+
ui = args.ui
|
|
49
|
+
|
|
50
|
+
if args.agent_file:
|
|
51
|
+
if args.agent_file == "tests.test": # Argument used for testing purposes
|
|
52
|
+
full_path = os.path.abspath("agents.yaml")
|
|
53
|
+
else:
|
|
54
|
+
full_path = os.path.abspath(args.agent_file)
|
|
55
|
+
self.agent_file = full_path
|
|
56
|
+
else:
|
|
57
|
+
full_path = os.path.abspath(self.agent_file)
|
|
58
|
+
self.agent_file = full_path
|
|
59
|
+
|
|
60
|
+
if args.auto or args.init:
|
|
61
|
+
temp_topic = ' '.join(args.auto) if args.auto else ' '.join(args.init)
|
|
62
|
+
self.topic = temp_topic
|
|
63
|
+
elif self.auto or self.init: # Use the auto attribute if args.auto is not provided
|
|
64
|
+
self.topic = self.auto
|
|
65
|
+
|
|
66
|
+
if args.auto or self.auto:
|
|
67
|
+
self.agent_file = "test.yaml"
|
|
68
|
+
generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
|
|
69
|
+
self.agent_file = generator.generate()
|
|
70
|
+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
|
71
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
72
|
+
return result
|
|
73
|
+
elif args.init or self.init:
|
|
74
|
+
self.agent_file = "agents.yaml"
|
|
75
|
+
generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
|
|
76
|
+
self.agent_file = generator.generate()
|
|
77
|
+
print("File {} created successfully".format(self.agent_file))
|
|
78
|
+
return "File {} created successfully".format(self.agent_file)
|
|
79
|
+
|
|
80
|
+
if ui:
|
|
81
|
+
self.create_gradio_interface()
|
|
82
|
+
else:
|
|
83
|
+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
|
84
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
85
|
+
return result
|
|
86
|
+
|
|
87
|
+
def parse_args(self):
|
|
88
|
+
parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
|
|
89
|
+
parser.add_argument("--framework", choices=["crewai", "autogen"], default="crewai", help="Specify the framework")
|
|
90
|
+
parser.add_argument("--ui", action="store_true", help="Enable UI mode")
|
|
91
|
+
parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
|
92
|
+
parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
|
93
|
+
parser.add_argument("agent_file", nargs="?", help="Specify the agent file")
|
|
94
|
+
parser.add_argument("--deploy", action="store_true", help="Deploy the application") # New argument
|
|
95
|
+
|
|
96
|
+
args, unknown_args = parser.parse_known_args()
|
|
97
|
+
|
|
98
|
+
if unknown_args and unknown_args[0] == '-b' and unknown_args[1] == 'api:app':
|
|
99
|
+
args.agent_file = 'agents.yaml'
|
|
100
|
+
if args.agent_file == 'api:app' or args.agent_file == '/app/api:app':
|
|
101
|
+
args.agent_file = 'agents.yaml'
|
|
102
|
+
|
|
103
|
+
return args
|
|
104
|
+
|
|
105
|
+
def create_gradio_interface(self):
|
|
106
|
+
def generate_crew_and_kickoff_interface(auto_args, framework):
|
|
107
|
+
self.framework = framework
|
|
108
|
+
self.agent_file = "test.yaml"
|
|
109
|
+
generator = AutoGenerator(topic=auto_args , framework=self.framework)
|
|
110
|
+
self.agent_file = generator.generate()
|
|
111
|
+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
|
112
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
113
|
+
return result
|
|
114
|
+
|
|
115
|
+
gr.Interface(
|
|
116
|
+
fn=generate_crew_and_kickoff_interface,
|
|
117
|
+
inputs=[gr.Textbox(lines=2, label="Auto Args"), gr.Dropdown(choices=["crewai", "autogen"], label="Framework")],
|
|
118
|
+
outputs="textbox",
|
|
119
|
+
title="Praison AI Studio",
|
|
120
|
+
description="Create Agents and perform tasks",
|
|
121
|
+
theme="default"
|
|
122
|
+
).launch()
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
praison_ai = PraisonAI()
|
|
126
|
+
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.18 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
|
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
from typing import Any
|
|
8
|
+
from autogen import register_function
|
|
9
|
+
|
|
10
|
+
def autogen_CodeDocsSearchTool(assistant, user_proxy):
|
|
11
|
+
def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
12
|
+
def tool_func(docs_url: str, search_query: str) -> Any:
|
|
13
|
+
tool_instance = tool_class(docs_url=docs_url, search_query=search_query)
|
|
14
|
+
return tool_instance.run()
|
|
15
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
16
|
+
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)
|
|
17
|
+
|
|
18
|
+
def autogen_CSVSearchTool(assistant, user_proxy):
|
|
19
|
+
def register_csv_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
20
|
+
def tool_func(csv: str, search_query: str) -> Any:
|
|
21
|
+
tool_instance = tool_class(csv=csv, search_query=search_query)
|
|
22
|
+
return tool_instance.run()
|
|
23
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
24
|
+
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)
|
|
25
|
+
|
|
26
|
+
def autogen_DirectorySearchTool(assistant, user_proxy):
|
|
27
|
+
def register_directory_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
28
|
+
def tool_func(directory: str, search_query: str) -> Any:
|
|
29
|
+
tool_instance = tool_class(directory=directory, search_query=search_query)
|
|
30
|
+
return tool_instance.run()
|
|
31
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
32
|
+
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)
|
|
33
|
+
|
|
34
|
+
def autogen_DOCXSearchTool(assistant, user_proxy):
|
|
35
|
+
def register_docx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
36
|
+
def tool_func(docx: str, search_query: str) -> Any:
|
|
37
|
+
tool_instance = tool_class(docx=docx, search_query=search_query)
|
|
38
|
+
return tool_instance.run()
|
|
39
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
40
|
+
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)
|
|
41
|
+
|
|
42
|
+
# DirectoryReadTool
|
|
43
|
+
def autogen_DirectoryReadTool(assistant, user_proxy):
|
|
44
|
+
def register_directory_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
45
|
+
def tool_func(directory: str) -> Any:
|
|
46
|
+
tool_instance = tool_class(directory=directory)
|
|
47
|
+
return tool_instance.run()
|
|
48
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
49
|
+
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)
|
|
50
|
+
|
|
51
|
+
# FileReadTool
|
|
52
|
+
def autogen_FileReadTool(assistant, user_proxy):
|
|
53
|
+
def register_file_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
54
|
+
def tool_func(file_path: str) -> Any:
|
|
55
|
+
tool_instance = tool_class(file_path=file_path)
|
|
56
|
+
return tool_instance.run()
|
|
57
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
58
|
+
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)
|
|
59
|
+
|
|
60
|
+
# TXTSearchTool
|
|
61
|
+
def autogen_TXTSearchTool(assistant, user_proxy):
|
|
62
|
+
def register_txt_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
63
|
+
def tool_func(txt: str, search_query: str) -> Any:
|
|
64
|
+
tool_instance = tool_class(txt=txt, search_query=search_query)
|
|
65
|
+
return tool_instance.run()
|
|
66
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
67
|
+
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)
|
|
68
|
+
|
|
69
|
+
def autogen_JSONSearchTool(assistant, user_proxy):
|
|
70
|
+
def register_json_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
71
|
+
def tool_func(json_path: str, search_query: str) -> Any:
|
|
72
|
+
tool_instance = tool_class(json_path=json_path, search_query=search_query)
|
|
73
|
+
return tool_instance.run()
|
|
74
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
75
|
+
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)
|
|
76
|
+
|
|
77
|
+
def autogen_MDXSearchTool(assistant, user_proxy):
|
|
78
|
+
def register_mdx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
79
|
+
def tool_func(mdx: str, search_query: str) -> Any:
|
|
80
|
+
tool_instance = tool_class(mdx=mdx, search_query=search_query)
|
|
81
|
+
return tool_instance.run()
|
|
82
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
83
|
+
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)
|
|
84
|
+
|
|
85
|
+
def autogen_PDFSearchTool(assistant, user_proxy):
|
|
86
|
+
def register_pdf_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
87
|
+
def tool_func(pdf: str, search_query: str) -> Any:
|
|
88
|
+
tool_instance = tool_class(pdf=pdf, search_query=search_query)
|
|
89
|
+
return tool_instance.run()
|
|
90
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
91
|
+
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)
|
|
92
|
+
|
|
93
|
+
def autogen_RagTool(assistant, user_proxy):
|
|
94
|
+
def register_rag_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
95
|
+
def tool_func(query: str, data: Any) -> Any:
|
|
96
|
+
tool_instance = tool_class(query=query, data=data)
|
|
97
|
+
return tool_instance.run()
|
|
98
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
99
|
+
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)
|
|
100
|
+
|
|
101
|
+
def autogen_ScrapeElementFromWebsiteTool(assistant, user_proxy):
|
|
102
|
+
def register_scrape_element_from_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
103
|
+
def tool_func(website_url: str, element_query: str) -> Any:
|
|
104
|
+
tool_instance = tool_class(website_url=website_url, element_query=element_query)
|
|
105
|
+
return tool_instance.run()
|
|
106
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
107
|
+
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)
|
|
108
|
+
|
|
109
|
+
def autogen_ScrapeWebsiteTool(assistant, user_proxy):
|
|
110
|
+
def register_scrape_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
111
|
+
def tool_func(website_url: str) -> Any:
|
|
112
|
+
tool_instance = tool_class(website_url=website_url)
|
|
113
|
+
return tool_instance.run()
|
|
114
|
+
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
|
115
|
+
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)
|
|
116
|
+
|
|
117
|
+
def autogen_WebsiteSearchTool(assistant, user_proxy):
|
|
118
|
+
def register_website_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
119
|
+
def tool_func(website: str, search_query: str) -> Any:
|
|
120
|
+
tool_instance = tool_class(website=website, 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_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)
|
|
124
|
+
|
|
125
|
+
def autogen_XMLSearchTool(assistant, user_proxy):
|
|
126
|
+
def register_xml_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
127
|
+
def tool_func(xml: str, search_query: str) -> Any:
|
|
128
|
+
tool_instance = tool_class(xml=xml, 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_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)
|
|
132
|
+
|
|
133
|
+
def autogen_YoutubeChannelSearchTool(assistant, user_proxy):
|
|
134
|
+
def register_youtube_channel_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
135
|
+
def tool_func(youtube_channel_handle: str, search_query: str) -> Any:
|
|
136
|
+
tool_instance = tool_class(youtube_channel_handle=youtube_channel_handle, 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_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)
|
|
140
|
+
|
|
141
|
+
def autogen_YoutubeVideoSearchTool(assistant, user_proxy):
|
|
142
|
+
def register_youtube_video_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
|
143
|
+
def tool_func(youtube_video_url: str, search_query: str) -> Any:
|
|
144
|
+
tool_instance = tool_class(youtube_video_url=youtube_video_url, 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_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)
|