PraisonAI 2.0.12__cp311-cp311-macosx_15_0_arm64.whl → 2.0.53__cp311-cp311-macosx_15_0_arm64.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/agents_generator.py +64 -31
- praisonai/api/call.py +3 -3
- praisonai/cli.py +7 -1
- praisonai/deploy.py +1 -1
- praisonai/public/praison-ai-agents-architecture-dark.png +0 -0
- praisonai/public/praison-ai-agents-architecture.png +0 -0
- praisonai/ui/agents.py +822 -0
- praisonai/ui/callbacks.py +57 -0
- praisonai/ui/colab.py +474 -0
- praisonai/ui/colab_chainlit.py +81 -0
- praisonai/ui/config/chainlit.md +1 -1
- praisonai/ui/realtime.py +65 -10
- praisonai/ui/sql_alchemy.py +2 -1
- praisonai/ui/tools.md +133 -0
- {praisonai-2.0.12.dist-info → praisonai-2.0.53.dist-info}/METADATA +232 -57
- {praisonai-2.0.12.dist-info → praisonai-2.0.53.dist-info}/RECORD +19 -12
- {praisonai-2.0.12.dist-info → praisonai-2.0.53.dist-info}/WHEEL +1 -1
- {praisonai-2.0.12.dist-info → praisonai-2.0.53.dist-info}/LICENSE +0 -0
- {praisonai-2.0.12.dist-info → praisonai-2.0.53.dist-info}/entry_points.txt +0 -0
praisonai/agents_generator.py
CHANGED
|
@@ -200,6 +200,47 @@ class AgentsGenerator:
|
|
|
200
200
|
tools_dict[name] = obj
|
|
201
201
|
return tools_dict
|
|
202
202
|
|
|
203
|
+
def load_tools_from_tools_py(self):
|
|
204
|
+
"""
|
|
205
|
+
Imports and returns all contents from tools.py file.
|
|
206
|
+
Also adds the tools to the global namespace.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
list: A list of callable functions with proper formatting
|
|
210
|
+
"""
|
|
211
|
+
tools_list = []
|
|
212
|
+
try:
|
|
213
|
+
# Try to import tools.py from current directory
|
|
214
|
+
spec = importlib.util.spec_from_file_location("tools", "tools.py")
|
|
215
|
+
self.logger.debug(f"Spec: {spec}")
|
|
216
|
+
if spec is None:
|
|
217
|
+
self.logger.debug("tools.py not found in current directory")
|
|
218
|
+
return tools_list
|
|
219
|
+
|
|
220
|
+
module = importlib.util.module_from_spec(spec)
|
|
221
|
+
spec.loader.exec_module(module)
|
|
222
|
+
|
|
223
|
+
# Get all module attributes except private ones and classes
|
|
224
|
+
for name, obj in inspect.getmembers(module):
|
|
225
|
+
if (not name.startswith('_') and
|
|
226
|
+
callable(obj) and
|
|
227
|
+
not inspect.isclass(obj)):
|
|
228
|
+
# Add the function to global namespace
|
|
229
|
+
globals()[name] = obj
|
|
230
|
+
# Add to tools list
|
|
231
|
+
tools_list.append(obj)
|
|
232
|
+
self.logger.debug(f"Loaded and globalized tool function: {name}")
|
|
233
|
+
|
|
234
|
+
self.logger.debug(f"Loaded {len(tools_list)} tool functions from tools.py")
|
|
235
|
+
self.logger.debug(f"Tools list: {tools_list}")
|
|
236
|
+
|
|
237
|
+
except FileNotFoundError:
|
|
238
|
+
self.logger.debug("tools.py not found in current directory")
|
|
239
|
+
except Exception as e:
|
|
240
|
+
self.logger.warning(f"Error loading tools from tools.py: {e}")
|
|
241
|
+
|
|
242
|
+
return tools_list
|
|
243
|
+
|
|
203
244
|
def generate_crew_and_kickoff(self):
|
|
204
245
|
"""
|
|
205
246
|
Generates a crew of agents and initiates tasks based on the provided configuration.
|
|
@@ -271,7 +312,7 @@ class AgentsGenerator:
|
|
|
271
312
|
elif tools_dir_path.is_dir():
|
|
272
313
|
tools_dict.update(self.load_tools_from_module_class(tools_dir_path))
|
|
273
314
|
self.logger.debug("tools folder exists in the root directory")
|
|
274
|
-
|
|
315
|
+
|
|
275
316
|
framework = self.framework or config.get('framework')
|
|
276
317
|
|
|
277
318
|
if framework == "autogen":
|
|
@@ -498,40 +539,26 @@ class AgentsGenerator:
|
|
|
498
539
|
tasks = []
|
|
499
540
|
tasks_dict = {}
|
|
500
541
|
|
|
542
|
+
# Load tools once at the beginning
|
|
543
|
+
tools_list = self.load_tools_from_tools_py()
|
|
544
|
+
self.logger.debug(f"Loaded tools: {tools_list}")
|
|
545
|
+
|
|
501
546
|
# Create agents from config
|
|
502
547
|
for role, details in config['roles'].items():
|
|
503
548
|
role_filled = details['role'].format(topic=topic)
|
|
504
549
|
goal_filled = details['goal'].format(topic=topic)
|
|
505
550
|
backstory_filled = details['backstory'].format(topic=topic)
|
|
506
551
|
|
|
507
|
-
#
|
|
508
|
-
agent_tools = [tools_dict[tool] for tool in details.get('tools', [])
|
|
509
|
-
if tool in tools_dict]
|
|
510
|
-
|
|
511
|
-
# Configure LLM
|
|
512
|
-
llm_model = details.get('llm')
|
|
513
|
-
if llm_model:
|
|
514
|
-
llm = llm_model.get("model", os.environ.get("MODEL_NAME", "gpt-4o"))
|
|
515
|
-
else:
|
|
516
|
-
llm = os.environ.get("MODEL_NAME", "gpt-4o")
|
|
517
|
-
|
|
518
|
-
# Configure function calling LLM
|
|
519
|
-
function_calling_llm_model = details.get('function_calling_llm')
|
|
520
|
-
if function_calling_llm_model:
|
|
521
|
-
function_calling_llm = function_calling_llm_model.get("model", os.environ.get("MODEL_NAME", "openai/gpt-4o"))
|
|
522
|
-
else:
|
|
523
|
-
function_calling_llm = os.environ.get("MODEL_NAME", "gpt-4o")
|
|
524
|
-
|
|
525
|
-
# Create PraisonAI agent
|
|
552
|
+
# Pass all loaded tools to the agent
|
|
526
553
|
agent = PraisonAgent(
|
|
527
554
|
name=role_filled,
|
|
528
555
|
role=role_filled,
|
|
529
556
|
goal=goal_filled,
|
|
530
557
|
backstory=backstory_filled,
|
|
531
|
-
tools=
|
|
558
|
+
tools=tools_list, # Pass the entire tools list to the agent
|
|
532
559
|
allow_delegation=details.get('allow_delegation', False),
|
|
533
|
-
llm=llm,
|
|
534
|
-
function_calling_llm=function_calling_llm,
|
|
560
|
+
llm=details.get('llm', {}).get("model", os.environ.get("MODEL_NAME", "gpt-4o")),
|
|
561
|
+
function_calling_llm=details.get('function_calling_llm', {}).get("model", os.environ.get("MODEL_NAME", "gpt-4o")),
|
|
535
562
|
max_iter=details.get('max_iter', 15),
|
|
536
563
|
max_rpm=details.get('max_rpm'),
|
|
537
564
|
max_execution_time=details.get('max_execution_time'),
|
|
@@ -540,25 +567,27 @@ class AgentsGenerator:
|
|
|
540
567
|
system_template=details.get('system_template'),
|
|
541
568
|
prompt_template=details.get('prompt_template'),
|
|
542
569
|
response_template=details.get('response_template'),
|
|
570
|
+
reflect_llm=details.get('reflect_llm', {}).get("model", os.environ.get("MODEL_NAME", "gpt-4o")),
|
|
571
|
+
min_reflect=details.get('min_reflect', 1),
|
|
572
|
+
max_reflect=details.get('max_reflect', 3),
|
|
543
573
|
)
|
|
544
574
|
|
|
545
|
-
# Set agent callback if provided
|
|
546
575
|
if self.agent_callback:
|
|
547
576
|
agent.step_callback = self.agent_callback
|
|
548
577
|
|
|
549
578
|
agents[role] = agent
|
|
579
|
+
self.logger.debug(f"Created agent {role_filled} with tools: {agent.tools}")
|
|
550
580
|
|
|
551
581
|
# Create tasks for the agent
|
|
552
582
|
for task_name, task_details in details.get('tasks', {}).items():
|
|
553
583
|
description_filled = task_details['description'].format(topic=topic)
|
|
554
584
|
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
|
555
585
|
|
|
556
|
-
# Create task using PraisonAI Task class
|
|
557
586
|
task = PraisonTask(
|
|
558
587
|
description=description_filled,
|
|
559
588
|
expected_output=expected_output_filled,
|
|
560
589
|
agent=agent,
|
|
561
|
-
tools=
|
|
590
|
+
tools=tools_list, # Pass the same tools list to the task
|
|
562
591
|
async_execution=task_details.get('async_execution', False),
|
|
563
592
|
context=[],
|
|
564
593
|
config=task_details.get('config', {}),
|
|
@@ -568,8 +597,9 @@ class AgentsGenerator:
|
|
|
568
597
|
callback=task_details.get('callback'),
|
|
569
598
|
create_directory=task_details.get('create_directory', False)
|
|
570
599
|
)
|
|
600
|
+
|
|
601
|
+
self.logger.debug(f"Created task {task_name} with tools: {task.tools}")
|
|
571
602
|
|
|
572
|
-
# Set task callback if provided
|
|
573
603
|
if self.task_callback:
|
|
574
604
|
task.callback = self.task_callback
|
|
575
605
|
|
|
@@ -581,10 +611,12 @@ class AgentsGenerator:
|
|
|
581
611
|
for task_name, task_details in details.get('tasks', {}).items():
|
|
582
612
|
task = tasks_dict[task_name]
|
|
583
613
|
context_tasks = [tasks_dict[ctx] for ctx in task_details.get('context', [])
|
|
584
|
-
|
|
614
|
+
if ctx in tasks_dict]
|
|
585
615
|
task.context = context_tasks
|
|
586
616
|
|
|
587
617
|
# Create and run the PraisonAI agents
|
|
618
|
+
memory = config.get('memory', False)
|
|
619
|
+
self.logger.debug(f"Memory: {memory}")
|
|
588
620
|
if config.get('process') == 'hierarchical':
|
|
589
621
|
agents = PraisonAIAgents(
|
|
590
622
|
agents=list(agents.values()),
|
|
@@ -592,20 +624,21 @@ class AgentsGenerator:
|
|
|
592
624
|
verbose=True,
|
|
593
625
|
process="hierarchical",
|
|
594
626
|
manager_llm=config.get('manager_llm', 'gpt-4o'),
|
|
627
|
+
memory=memory
|
|
595
628
|
)
|
|
596
629
|
else:
|
|
597
630
|
agents = PraisonAIAgents(
|
|
598
631
|
agents=list(agents.values()),
|
|
599
632
|
tasks=tasks,
|
|
600
|
-
verbose=2
|
|
633
|
+
verbose=2,
|
|
634
|
+
memory=memory
|
|
601
635
|
)
|
|
602
|
-
|
|
636
|
+
|
|
603
637
|
self.logger.debug("Final Configuration:")
|
|
604
638
|
self.logger.debug(f"Agents: {agents.agents}")
|
|
605
639
|
self.logger.debug(f"Tasks: {agents.tasks}")
|
|
606
640
|
|
|
607
641
|
response = agents.start()
|
|
608
|
-
# result = f"### Task Output ###\n{response}"
|
|
609
642
|
self.logger.debug(f"Result: {response}")
|
|
610
643
|
result = ""
|
|
611
644
|
|
praisonai/api/call.py
CHANGED
|
@@ -50,7 +50,7 @@ logger.handlers = []
|
|
|
50
50
|
# Try to import tools from the root directory
|
|
51
51
|
tools = []
|
|
52
52
|
tools_path = os.path.join(os.getcwd(), 'tools.py')
|
|
53
|
-
logger.
|
|
53
|
+
logger.debug(f"Tools path: {tools_path}")
|
|
54
54
|
|
|
55
55
|
def import_tools_from_file(file_path):
|
|
56
56
|
spec = importlib.util.spec_from_file_location("custom_tools", file_path)
|
|
@@ -63,9 +63,9 @@ try:
|
|
|
63
63
|
if os.path.exists(tools_path):
|
|
64
64
|
# tools.py exists in the root directory, import from file
|
|
65
65
|
custom_tools_module = import_tools_from_file(tools_path)
|
|
66
|
-
logger.
|
|
66
|
+
logger.debug("Successfully imported custom tools from root tools.py")
|
|
67
67
|
else:
|
|
68
|
-
logger.
|
|
68
|
+
logger.debug("No custom tools.py file found in the root directory")
|
|
69
69
|
custom_tools_module = None
|
|
70
70
|
|
|
71
71
|
if custom_tools_module:
|
praisonai/cli.py
CHANGED
|
@@ -73,6 +73,12 @@ except ImportError:
|
|
|
73
73
|
pass
|
|
74
74
|
|
|
75
75
|
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'), format='%(asctime)s - %(levelname)s - %(message)s')
|
|
76
|
+
logging.getLogger('alembic').setLevel(logging.ERROR)
|
|
77
|
+
logging.getLogger('gradio').setLevel(logging.ERROR)
|
|
78
|
+
logging.getLogger('gradio').setLevel(os.environ.get('GRADIO_LOGLEVEL', 'WARNING'))
|
|
79
|
+
logging.getLogger('rust_logger').setLevel(logging.WARNING)
|
|
80
|
+
logging.getLogger('duckduckgo').setLevel(logging.ERROR)
|
|
81
|
+
logging.getLogger('_client').setLevel(logging.ERROR)
|
|
76
82
|
|
|
77
83
|
def stream_subprocess(command, env=None):
|
|
78
84
|
"""
|
|
@@ -478,7 +484,7 @@ class PraisonAI:
|
|
|
478
484
|
logging.info("Public folder not found in the package.")
|
|
479
485
|
else:
|
|
480
486
|
logging.info("Public folder already exists.")
|
|
481
|
-
chainlit_ui_path = os.path.join(os.path.dirname(praisonai.__file__), '
|
|
487
|
+
chainlit_ui_path = os.path.join(os.path.dirname(praisonai.__file__), 'ui', 'agents.py')
|
|
482
488
|
chainlit_run([chainlit_ui_path])
|
|
483
489
|
else:
|
|
484
490
|
print("ERROR: Chainlit is not installed. Please install it with 'pip install \"praisonai[ui]\"' to use the UI.")
|
praisonai/deploy.py
CHANGED
|
@@ -56,7 +56,7 @@ class CloudDeployer:
|
|
|
56
56
|
file.write("FROM python:3.11-slim\n")
|
|
57
57
|
file.write("WORKDIR /app\n")
|
|
58
58
|
file.write("COPY . .\n")
|
|
59
|
-
file.write("RUN pip install flask praisonai==2.0.
|
|
59
|
+
file.write("RUN pip install flask praisonai==2.0.53 gunicorn markdown\n")
|
|
60
60
|
file.write("EXPOSE 8080\n")
|
|
61
61
|
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
|
62
62
|
|
|
Binary file
|
|
Binary file
|