PraisonAI 0.0.35__py3-none-any.whl → 0.0.37__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/agents_generator.py +51 -4
- praisonai/chainlit_ui.py +64 -2
- praisonai/deploy.py +1 -1
- praisonai/inbuilt_tools/autogen_tools.py +4 -2
- {praisonai-0.0.35.dist-info → praisonai-0.0.37.dist-info}/METADATA +27 -1
- {praisonai-0.0.35.dist-info → praisonai-0.0.37.dist-info}/RECORD +9 -9
- {praisonai-0.0.35.dist-info → praisonai-0.0.37.dist-info}/LICENSE +0 -0
- {praisonai-0.0.35.dist-info → praisonai-0.0.37.dist-info}/WHEEL +0 -0
- {praisonai-0.0.35.dist-info → praisonai-0.0.37.dist-info}/entry_points.txt +0 -0
praisonai/agents_generator.py
CHANGED
|
@@ -24,6 +24,14 @@ import importlib
|
|
|
24
24
|
import importlib.util
|
|
25
25
|
from praisonai_tools import BaseTool
|
|
26
26
|
import os
|
|
27
|
+
import logging
|
|
28
|
+
|
|
29
|
+
agentops_exists = False
|
|
30
|
+
try:
|
|
31
|
+
import agentops
|
|
32
|
+
agentops_exists = True
|
|
33
|
+
except ImportError:
|
|
34
|
+
agentops_exists = False
|
|
27
35
|
|
|
28
36
|
os.environ["OTEL_SDK_DISABLED"] = "true"
|
|
29
37
|
|
|
@@ -38,7 +46,7 @@ def disable_crewai_telemetry():
|
|
|
38
46
|
disable_crewai_telemetry()
|
|
39
47
|
|
|
40
48
|
class AgentsGenerator:
|
|
41
|
-
def __init__(self, agent_file, framework, config_list):
|
|
49
|
+
def __init__(self, agent_file, framework, config_list, log_level=None, agent_callback=None, task_callback=None):
|
|
42
50
|
"""
|
|
43
51
|
Initialize the AgentsGenerator object.
|
|
44
52
|
|
|
@@ -46,15 +54,31 @@ class AgentsGenerator:
|
|
|
46
54
|
agent_file (str): The path to the agent file.
|
|
47
55
|
framework (str): The framework to be used for the agents.
|
|
48
56
|
config_list (list): A list of configurations for the agents.
|
|
57
|
+
log_level (int, optional): The logging level to use. Defaults to logging.INFO.
|
|
58
|
+
agent_callback (callable, optional): A callback function to be executed after each agent step.
|
|
59
|
+
task_callback (callable, optional): A callback function to be executed after each tool run.
|
|
49
60
|
|
|
50
61
|
Attributes:
|
|
51
62
|
agent_file (str): The path to the agent file.
|
|
52
63
|
framework (str): The framework to be used for the agents.
|
|
53
64
|
config_list (list): A list of configurations for the agents.
|
|
65
|
+
log_level (int): The logging level to use.
|
|
66
|
+
agent_callback (callable, optional): A callback function to be executed after each agent step.
|
|
67
|
+
task_callback (callable, optional): A callback function to be executed after each tool run.
|
|
54
68
|
"""
|
|
55
69
|
self.agent_file = agent_file
|
|
56
70
|
self.framework = framework
|
|
57
71
|
self.config_list = config_list
|
|
72
|
+
self.log_level = log_level
|
|
73
|
+
self.agent_callback = agent_callback
|
|
74
|
+
self.task_callback = task_callback
|
|
75
|
+
self.log_level = log_level or logging.getLogger().getEffectiveLevel()
|
|
76
|
+
if self.log_level == logging.NOTSET:
|
|
77
|
+
self.log_level = os.environ.get('LOGLEVEL', 'INFO').upper()
|
|
78
|
+
|
|
79
|
+
logging.basicConfig(level=self.log_level, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
80
|
+
self.logger = logging.getLogger(__name__)
|
|
81
|
+
self.logger.setLevel(self.log_level)
|
|
58
82
|
|
|
59
83
|
def is_function_or_decorated(self, obj):
|
|
60
84
|
"""
|
|
@@ -183,10 +207,10 @@ class AgentsGenerator:
|
|
|
183
207
|
|
|
184
208
|
if os.path.isfile(tools_py_path):
|
|
185
209
|
tools_dict.update(self.load_tools_from_module_class(tools_py_path))
|
|
186
|
-
|
|
210
|
+
self.logger.debug("tools.py exists in the root directory. Loading tools.py and skipping tools folder.")
|
|
187
211
|
elif tools_dir_path.is_dir():
|
|
188
212
|
tools_dict.update(self.load_tools_from_module_class(tools_dir_path))
|
|
189
|
-
|
|
213
|
+
self.logger.debug("tools folder exists in the root directory")
|
|
190
214
|
|
|
191
215
|
framework = self.framework or config.get('framework')
|
|
192
216
|
|
|
@@ -197,6 +221,8 @@ class AgentsGenerator:
|
|
|
197
221
|
# print(self.config_list)
|
|
198
222
|
llm_config = {"config_list": self.config_list}
|
|
199
223
|
|
|
224
|
+
if agentops_exists:
|
|
225
|
+
agentops.init(os.environ.get("AGENTOPS_API_KEY"), tags=["autogen"])
|
|
200
226
|
# Assuming the user proxy agent is set up as per your requirements
|
|
201
227
|
user_proxy = autogen.UserProxyAgent(
|
|
202
228
|
name="User",
|
|
@@ -240,10 +266,13 @@ class AgentsGenerator:
|
|
|
240
266
|
# Additional fields like carryover can be added based on dependencies
|
|
241
267
|
}
|
|
242
268
|
tasks.append(chat_task)
|
|
243
|
-
|
|
244
269
|
response = user_proxy.initiate_chats(tasks)
|
|
245
270
|
result = "### Output ###\n"+response[-1].summary if hasattr(response[-1], 'summary') else ""
|
|
271
|
+
if agentops_exists:
|
|
272
|
+
agentops.end_session("Success")
|
|
246
273
|
else:
|
|
274
|
+
if agentops_exists:
|
|
275
|
+
agentops.init(os.environ.get("AGENTOPS_API_KEY"), tags=["crewai"])
|
|
247
276
|
for role, details in config['roles'].items():
|
|
248
277
|
role_filled = details['role'].format(topic=topic)
|
|
249
278
|
goal_filled = details['goal'].format(topic=topic)
|
|
@@ -252,6 +281,11 @@ class AgentsGenerator:
|
|
|
252
281
|
# Adding tools to the agent if exists
|
|
253
282
|
agent_tools = [tools_dict[tool] for tool in details.get('tools', []) if tool in tools_dict]
|
|
254
283
|
agent = Agent(role=role_filled, goal=goal_filled, backstory=backstory_filled, tools=agent_tools, allow_delegation=False)
|
|
284
|
+
|
|
285
|
+
# Set agent callback if provided
|
|
286
|
+
if self.agent_callback:
|
|
287
|
+
agent.step_callback = self.agent_callback
|
|
288
|
+
|
|
255
289
|
agents[role] = agent
|
|
256
290
|
|
|
257
291
|
for task_name, task_details in details.get('tasks', {}).items():
|
|
@@ -259,13 +293,26 @@ class AgentsGenerator:
|
|
|
259
293
|
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
|
260
294
|
|
|
261
295
|
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
|
|
296
|
+
|
|
297
|
+
# Set tool callback if provided
|
|
298
|
+
if self.task_callback:
|
|
299
|
+
task.callback = self.task_callback
|
|
300
|
+
|
|
262
301
|
tasks.append(task)
|
|
302
|
+
|
|
263
303
|
crew = Crew(
|
|
264
304
|
agents=list(agents.values()),
|
|
265
305
|
tasks=tasks,
|
|
266
306
|
verbose=2
|
|
267
307
|
)
|
|
308
|
+
|
|
309
|
+
self.logger.debug("Final Crew Configuration:")
|
|
310
|
+
self.logger.debug(f"Agents: {crew.agents}")
|
|
311
|
+
self.logger.debug(f"Tasks: {crew.tasks}")
|
|
268
312
|
|
|
269
313
|
response = crew.kickoff()
|
|
270
314
|
result = f"### Task Output ###\n{response}"
|
|
315
|
+
if agentops_exists:
|
|
316
|
+
agentops.end_session("Success")
|
|
271
317
|
return result
|
|
318
|
+
|
praisonai/chainlit_ui.py
CHANGED
|
@@ -8,6 +8,8 @@ from chainlit.input_widget import Select, TextInput
|
|
|
8
8
|
from typing import Optional
|
|
9
9
|
from dotenv import load_dotenv
|
|
10
10
|
load_dotenv()
|
|
11
|
+
from contextlib import redirect_stdout
|
|
12
|
+
from io import StringIO
|
|
11
13
|
|
|
12
14
|
framework = "crewai"
|
|
13
15
|
config_list = [
|
|
@@ -178,10 +180,57 @@ async def on_chat_resume(thread: ThreadDict):
|
|
|
178
180
|
# async def tool(data: Optional[str] = None, language: Optional[str] = None):
|
|
179
181
|
# return cl.Message(content=data, language=language)
|
|
180
182
|
|
|
183
|
+
@cl.step(type="tool", show_input=False)
|
|
184
|
+
async def run_agents(agent_file: str, framework: str):
|
|
185
|
+
"""Runs the agents and returns the result."""
|
|
186
|
+
agents_generator = AgentsGenerator(agent_file, framework, config_list)
|
|
187
|
+
current_step = cl.context.current_step
|
|
188
|
+
print("Current Step:", current_step)
|
|
189
|
+
|
|
190
|
+
stdout_buffer = StringIO()
|
|
191
|
+
with redirect_stdout(stdout_buffer):
|
|
192
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
193
|
+
|
|
194
|
+
complete_output = stdout_buffer.getvalue()
|
|
195
|
+
|
|
196
|
+
async with cl.Step(name="gpt4", type="llm", show_input=True) as step:
|
|
197
|
+
step.input = ""
|
|
198
|
+
|
|
199
|
+
for line in stdout_buffer.getvalue().splitlines():
|
|
200
|
+
print(line)
|
|
201
|
+
await step.stream_token(line)
|
|
202
|
+
|
|
203
|
+
tool_res = await output(complete_output)
|
|
204
|
+
|
|
205
|
+
yield result
|
|
206
|
+
|
|
207
|
+
@cl.step(type="tool", show_input=False, language="yaml")
|
|
208
|
+
async def output(output):
|
|
209
|
+
return output
|
|
210
|
+
|
|
211
|
+
@cl.step(type="tool", show_input=False, language="yaml")
|
|
212
|
+
def agent(output):
|
|
213
|
+
return(f"""
|
|
214
|
+
Agent Step Completed!
|
|
215
|
+
Output: {output}
|
|
216
|
+
""")
|
|
217
|
+
|
|
218
|
+
@cl.step(type="tool", show_input=False, language="yaml")
|
|
219
|
+
def task(output):
|
|
220
|
+
return(f"""
|
|
221
|
+
Task Completed!
|
|
222
|
+
Task: {output.description}
|
|
223
|
+
Output: {output.raw_output}
|
|
224
|
+
{output}
|
|
225
|
+
""")
|
|
226
|
+
|
|
181
227
|
@cl.on_message
|
|
182
228
|
async def main(message: cl.Message):
|
|
183
229
|
"""Run PraisonAI with the provided message as the topic."""
|
|
184
230
|
message_history = cl.user_session.get("message_history")
|
|
231
|
+
if message_history is None:
|
|
232
|
+
message_history = []
|
|
233
|
+
cl.user_session.set("message_history", message_history)
|
|
185
234
|
message_history.append({"role": "user", "content": message.content})
|
|
186
235
|
topic = message.content
|
|
187
236
|
chat_profile = cl.user_session.get("chat_profile")
|
|
@@ -189,9 +238,22 @@ async def main(message: cl.Message):
|
|
|
189
238
|
if chat_profile == "Auto":
|
|
190
239
|
agent_file = "agents.yaml"
|
|
191
240
|
generator = AutoGenerator(topic=topic, agent_file=agent_file, framework=framework, config_list=config_list)
|
|
241
|
+
await cl.sleep(2)
|
|
192
242
|
agent_file = generator.generate()
|
|
193
|
-
agents_generator = AgentsGenerator(
|
|
194
|
-
|
|
243
|
+
agents_generator = AgentsGenerator(
|
|
244
|
+
agent_file,
|
|
245
|
+
framework,
|
|
246
|
+
config_list,
|
|
247
|
+
# agent_callback=agent,
|
|
248
|
+
# task_callback=task
|
|
249
|
+
)
|
|
250
|
+
# Capture stdout
|
|
251
|
+
stdout_buffer = StringIO()
|
|
252
|
+
with redirect_stdout(stdout_buffer):
|
|
253
|
+
result = agents_generator.generate_crew_and_kickoff()
|
|
254
|
+
|
|
255
|
+
complete_output = stdout_buffer.getvalue()
|
|
256
|
+
tool_res = await output(complete_output)
|
|
195
257
|
msg = cl.Message(content=result)
|
|
196
258
|
await msg.send()
|
|
197
259
|
message_history.append({"role": "assistant", "content": message.content})
|
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==0.0.
|
|
59
|
+
file.write("RUN pip install flask praisonai==0.0.37 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
|
|
|
@@ -14,6 +14,8 @@ from pathlib import Path
|
|
|
14
14
|
import os
|
|
15
15
|
import inspect
|
|
16
16
|
import sys
|
|
17
|
+
import logging
|
|
18
|
+
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'), format='%(asctime)s - %(levelname)s - %(message)s')
|
|
17
19
|
|
|
18
20
|
def create_autogen_tool_function(tool_name):
|
|
19
21
|
def autogen_tool(assistant, user_proxy):
|
|
@@ -51,10 +53,10 @@ tools_dir_path = Path(root_directory) / 'tools'
|
|
|
51
53
|
tools_module = None
|
|
52
54
|
|
|
53
55
|
if os.path.isfile(tools_py_path):
|
|
54
|
-
|
|
56
|
+
logging.info(f"{tools_py_path} exists in the root directory. Loading {tools_py_path} and skipping tools folder.")
|
|
55
57
|
tools_module = importlib.import_module("tools")
|
|
56
58
|
elif tools_dir_path.is_dir():
|
|
57
|
-
|
|
59
|
+
logging.info(f"tools folder exists in the root directory. Loading {tool_name} from tools/{tool_name}.py.")
|
|
58
60
|
tools_module = importlib.import_module(f"tools.{tool_name}")
|
|
59
61
|
|
|
60
62
|
# Create autogen_TOOL_NAME_HERE function for each tool
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PraisonAI
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.37
|
|
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,11 @@ 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: agentops
|
|
11
12
|
Provides-Extra: api
|
|
12
13
|
Provides-Extra: gradio
|
|
13
14
|
Provides-Extra: ui
|
|
15
|
+
Requires-Dist: agentops (==0.2.3) ; extra == "agentops"
|
|
14
16
|
Requires-Dist: chainlit (>=1.1.301,<2.0.0) ; extra == "ui"
|
|
15
17
|
Requires-Dist: crewai (>=0.32.0)
|
|
16
18
|
Requires-Dist: flask (>=3.0.0) ; extra == "api"
|
|
@@ -297,6 +299,30 @@ gcloud run deploy praisonai-service \
|
|
|
297
299
|
--set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}
|
|
298
300
|
```
|
|
299
301
|
|
|
302
|
+
### Commands to Install Dependencies:
|
|
303
|
+
|
|
304
|
+
1. **Install all dependencies, including dev dependencies:**
|
|
305
|
+
```sh
|
|
306
|
+
poetry install
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
2. **Install only documentation dependencies:**
|
|
310
|
+
```sh
|
|
311
|
+
poetry install --with docs
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
3. **Install only test dependencies:**
|
|
315
|
+
```sh
|
|
316
|
+
poetry install --with test
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
4. **Install only dev dependencies:**
|
|
320
|
+
```sh
|
|
321
|
+
poetry install --with dev
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
This configuration ensures that your development dependencies are correctly categorized and installed as needed.
|
|
325
|
+
|
|
300
326
|
## Other Models
|
|
301
327
|
|
|
302
328
|
```bash
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
praisonai/__init__.py,sha256=JrgyPlzZfLlozoW7SHZ1nVJ63rLPR3ki2k5ZPywYrnI,175
|
|
2
2
|
praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
|
|
3
|
-
praisonai/agents_generator.py,sha256=
|
|
3
|
+
praisonai/agents_generator.py,sha256=K4I5o7UliVhIb9nSFoGsCsJpPe7Cxtsg4Mflgtp2pHE,15030
|
|
4
4
|
praisonai/auto.py,sha256=CpE9zUbdCP1wR0aLZWKVLxiLU9JOQprRNBK9WKDZVQo,7758
|
|
5
|
-
praisonai/chainlit_ui.py,sha256=
|
|
5
|
+
praisonai/chainlit_ui.py,sha256=uXo7KTuOH09cu_rLU5RU5JLVCKSc9FM5IcpuW_SVG90,12079
|
|
6
6
|
praisonai/cli.py,sha256=W_PL7bWnEEuFYBT24mh8171f7TiE_LdxVfrM16fp7Pc,10868
|
|
7
|
-
praisonai/deploy.py,sha256=
|
|
7
|
+
praisonai/deploy.py,sha256=mQkAIR4X3ZWQCgX-EIJ3rKPeft9bH4cnCj5IriHHG9o,6031
|
|
8
8
|
praisonai/inbuilt_tools/__init__.py,sha256=mUKnbL6Gram9c9f2m8wJwEzURBLmPEOcHzwySBH89YA,74
|
|
9
|
-
praisonai/inbuilt_tools/autogen_tools.py,sha256=
|
|
9
|
+
praisonai/inbuilt_tools/autogen_tools.py,sha256=svYkM2N7DVFvbiwgoAS7U_MqTOD8rHf8VD3BaFUV5_Y,14907
|
|
10
10
|
praisonai/public/fantasy.svg,sha256=4Gs3kIOux-pjGtw6ogI_rv5_viVJxnE5gRwGilsSg0o,1553
|
|
11
11
|
praisonai/public/game.svg,sha256=y2QMaA01m8XzuDjTOBWzupOC3-TpnUl9ah89mIhviUw,2406
|
|
12
12
|
praisonai/public/movie.svg,sha256=aJ2EQ8vXZusVsF2SeuAVxP4RFJzQ14T26ejrGYdBgzk,1289
|
|
13
13
|
praisonai/public/thriller.svg,sha256=2dYY72EcgbEyTxS4QzjAm37Y4srtPWEW4vCMFki98ZI,3163
|
|
14
14
|
praisonai/test.py,sha256=RZKq3UEFb6AnFFiHER3zBXfNmlteSLBlrTmOvnpnZLo,4092
|
|
15
15
|
praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
|
|
16
|
-
praisonai-0.0.
|
|
17
|
-
praisonai-0.0.
|
|
18
|
-
praisonai-0.0.
|
|
19
|
-
praisonai-0.0.
|
|
20
|
-
praisonai-0.0.
|
|
16
|
+
praisonai-0.0.37.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
|
|
17
|
+
praisonai-0.0.37.dist-info/METADATA,sha256=Xpz7nJpDWwWqRC69QYlUVUwv2ecyxdATFgwkhjxhYw0,10359
|
|
18
|
+
praisonai-0.0.37.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
19
|
+
praisonai-0.0.37.dist-info/entry_points.txt,sha256=Qg41eW3A1-dvdV5tF7LqChfYof8Rihk2rN1fiEE3vnk,53
|
|
20
|
+
praisonai-0.0.37.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|